使用
Microsoft.Azure.ServiceBus
包,有没有一种方法可以在当前线程上等待从队列接收消息?可能更多的是我理解上的问题和希望以一种技术不打算使用的方式使用技术,但我想做的是将以下 Microsoft 示例 中的发送和接收示例结合起来,以便您可以向各个队列发送消息,并能够侦听并处理“回复”(即您正在队列上侦听的消息),并在完成接收消息时关闭连接。以下是一些伪代码: // send message(s) that will be consumed by other processes / applications, and by doing so later on we will expect some messages back
await SendMessagesAsync(numberOfMessages);
var receivedMessages = 0;
while (receivedMessages < numberOfMessages)
{
// there is no "ReceiveAsync" method, this is what I would be looking for
Message message = await queueClient.ReceiveAsync(TimeSpan.FromSeconds(30));
receivedMessages++;
// do something with the message here
}
await queueClient.CloseAsync();
这个可能吗,还是我"做错了"?