I'm able to add messages to the queue but when I try to receive them nothing is received.
I've used the Azure Service Bus in linqpad with C# sample code so I know the queue works, but I'm probably missing something on the F# implementation with CloudAgent.
I tried serializing the object before adding it to the queue so that the content would just be a string that I could deserialize on receipt, but still had the same issue.
If I set a breakpoint on the line inbox.Receive() it gets hit, but a breakpoint on the following line never does.
Thanks for the help.
I'm not sure if it'd be more helpful to put the code in this issue or point you to my project so here are both.
https://github.com/talbottmike/TalBot/tree/AzureServiceBus
The type I'm posting is in TalBot.Types...
type IncomingMessage =
{
token : string;
teamId : string;
teamDomain : string;
channelId : string;
channelName : string;
timestamp : decimal;
userId : string;
userName : string;
text : string;
triggerWord : string;
}
I'm accessing the queue in TalBot.BotHelper around the beginning of the module.
let createResilientAgent agentId =
MailboxProcessor.Start(fun inbox ->
async {
while true do
let! message, replyChannel = inbox.Receive()
printfn "%s is the channelName." message.channelName
printfn "%s" (agentId.ToString())
match message with
| { channelName = "#bot-log" } ->
printfn "success"
replyChannel Completed // all good, message was processed
| { channelName = "snapple" } ->
printfn "snapple failed"
replyChannel Failed // error occurred, try again
| _ ->
printfn "abandoned"
replyChannel Abandoned // give up with this message.
})
let readFromServiceQueue () =
let serviceBusReadConnection () = ServiceBusConnection serviceBusReadConnectionString
let cloudReadConnection () = WorkerCloudConnection(serviceBusReadConnection (), Queue "queue")
printfn "trying to read from the queue"
let disposable = ConnectionFactory.StartListening(cloudReadConnection (), createResilientAgent >> Messaging.CloudAgentKind.ResilientCloudAgent)
disposable.Dispose()