【发布时间】:2017-06-14 19:09:23
【问题描述】:
我有一个相当简单的函数,可以将消息发送到 azure servicebus 队列。
public async Task<string> SendMessagesToQueue(string serviceBusConnectionString, int message, string queueName)
{
try
{
QueueClient queueClient = new QueueClient(serviceBusConnectionString, queueName, ReceiveMode.PeekLock);
// Create a new brokered message to send to the queue
var brokeredMessage = new Message($"Message {message}");
// Send the message to the queue
await queueClient.SendAsync(brokeredMessage);
await queueClient.CloseAsync();
// Delay by 10 milliseconds so that the console can keep up
await Task.Delay(10);
return brokeredMessage.MessageId;
}
catch (Exception ex)
{
return ex.ToString();
throw;
}
}
这可以正常工作并将消息放入队列中。但是,brokeredMessage.MessageId 始终为空。
是否有正确/更好的方法来检索消息 ID?
【问题讨论】:
标签: azure azureservicebus