在天蓝色服务总线上窥视DLQ时出现MessagingEntityNotFoundException

时间:2019-02-22 12:32:36

标签: azure azure-functions azureservicebus azure-servicebus-queues

最近两天,当我的代码在死信队列消息接收器上调用Microsoft.Azure.ServiceBus.Core.MessageReceiver.PeekAsync时,我开始收到MessagingEntityNotFoundException。在异常开始发生之前,代码没有更改,并且在过去两个月中一直正常运行。

完整的异常消息是

Microsoft.Azure.ServiceBus.MessagingEntityNotFoundException: A request handler with id '56216' was not found in the entity management node $management. 

代码在时间触发的Azure函数中运行。

设置消息接收者的代码:

    using Microsoft.Azure.ServiceBus;
    using Microsoft.Azure.ServiceBus.Core;
    using Microsoft.Azure.ServiceBus.Management;

    public class DeadLetterQueueMonitor {
       private static List<MessageReceiver> _messageReceivers;

       private async Task<List<MessageReceiver>> GetMessageReceivers(ILogger logger)
       {
         if (_messageReceivers == null)
         {
            _messageReceivers = new List<MessageReceiver>();
            var managementClient = new ManagementClient(ConnectionStrings.ServiceBusConnectionString);
            var topics = await managementClient.GetTopicsAsync();

            foreach (var topic in topics)
            {
                var subscriptions = await managementClient.GetSubscriptionsAsync(topic.Path);
                _messageReceivers.AddRange(subscriptions.Select(subscription =>
                {
                    string entityPath = EntityNameHelper.FormatDeadLetterPath(EntityNameHelper.FormatSubscriptionPath(topic.Path, subscription.SubscriptionName));

                    return new MessageReceiver(ConnectionStrings.ServiceBusConnectionString, entityPath);
                }));
            }
         }

         _messageReceivers = _messageReceivers
             .Select(r => r.IsClosedOrClosing ? new MessageReceiver(ConnectionStrings.ServiceBusConnectionString, r.Path) : r)
             .ToList();

         return _messageReceivers;
      }
   }

有什么建议可能有问题吗?

编辑25 / 2-2019(作为对评论的答复):

我正在使用以下Nuget软件包:

Microsoft.Azure.Amqp 2.3.0
Microsoft.Azure.ServiceBus 3.1.0
Microsoft.Azure.Services.AppAuthentication 1.0.3

我为创建MessageReceivers的方法添加了一些上下文。

0 个答案:

没有答案