我想不断检查 azure servicebus/iothub 是否有消息。但是,当我这样做时,我收到以下错误
“在 mscorlib.dll 中发生了‘Amqp.AmqpException’类型的异常,但未在用户代码中处理附加信息:操作‘接收’在状态下无效:结束。”
有什么想法我应该如何实现不断提取消息和/或解决此错误?
var connection = new Connection(address);
var session = new Session(connection);
var entity = Fx.Format("/devices/{0}/messages/deviceBound", _deviceId);
var receiveLink = new ReceiverLink(session, "receive-link", entity);
while (true)
{
await Task.Delay(1000);
var message = await receiveLink.ReceiveAsync();
if (message == null) continue;
//else do things with message
}