我目前正在開發一個依賴于 .net 4.5 的項目,這就是我被迫使用 Microsoft.Servicebus 的原因——因此是消息工廠創建一個 messagefactory 對象似乎不是問題,但創建消息發送者似乎是這里的問題。我不確定我的 azure 消息隊列的實體路徑是什么,也不知道應該如何查找?我這樣初始化了我的消息工廠;public Microsoft.ServiceBus.Messaging.MessagingFactory client = Microsoft.ServiceBus.Messaging.MessagingFactory.CreateFromConnectionString(ServiceBusConnectString);其中 servicebusconnectionstring 是從 azure 隊列中提取的主要連接字符串,或遵循本指南:https : //docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-dotnet-get-started -with-queues#1-create-a-namespace-using-the-azure-portal消息發送者是這樣創建的:Microsoft.ServiceBus.Messaging.MessageSender sender = client.CreateMessageSender(destinationQueue,queueName);再一次,destinationQueue 和 queueName 是字符串,它們是從 azure 定義的?要發送的消息是這樣創建的:Microsoft.ServiceBus.Messaging.BrokeredMessage message = new Microsoft.ServiceBus.Messaging.BrokeredMessage(e.ToXml());e 只是一個對象,它具有可以將其轉換為 xml 字符串的 publich 函數。這是我發送消息的地方:try{ IntegrationLogger.Write(LogLevel.Verbose, "Sending message to azure"); sender.Send(message);}catch(System.Exception ex){ if(ex is System.TimeoutException) { IntegrationLogger.Write(LogLevel.Error, "Timeout exeption"); } if (ex is System.ArgumentException) { IntegrationLogger.Write(LogLevel.Error, "Message is empty"); }}IntegrationLogger是我使用的日志功能 - 記錄的最后一條消息是“向 azure 發送消息”,這意味著當我發送消息時會出錯。即使 catch 也沒有捕獲異常?..這里可能有什么問題?我是否錯誤地使用了發件人?
- 1 回答
- 0 關注
- 198 瀏覽
添加回答
舉報
0/150
提交
取消