【问题标题】:Whats the TTL for a message if the message receiving mode is ReceiveAndDelete in Azure Service Bus?如果消息接收模式是 Azure 服务总线中的 ReceiveAndDelete,那么消息的 TTL 是多少?
【发布时间】:2019-03-05 01:34:37
【问题描述】:

我在 ReceiveAndDelete 模式下从服务总线收到一条消息,并开始运行一个很长的计算过程,完成后会发送一封邮件。在我的长期运行方法中,我的所有方法都有错误记录。但是,该方法运行 10-15 分钟,之后变得无响应,既不记录错误也不发送电子邮件。我想知道这可能与消息的 TTL 有关。

请指教我该怎么办?

    private static async Task ProcessMessagesAsync(Message message, CancellationToken token)
    {
       try
         {

           IQueueClient queueClient = new QueueClient(serviceBusConnectionString, serviceBusQueueName, ReceiveMode.ReceiveAndDelete);


            var receivedMessageTrasactionId = Convert.ToInt64(Encoding.UTF8.GetString(message.Body));

            // Very Long Running Method  
            await DataCleanse.PerformDataCleanse(receivedMessageTrasactionId);
                         // to avoid unnecessary exceptions.
          }

        catch (Exception ex)
        {
          Log4NetErrorLogger(ex);
          throw ex;
        }
    }

【问题讨论】:

    标签: c# azure azureservicebus long-running-processes


    【解决方案1】:

    在ReceiveAndDelete 模式下接收消息时,消息的生存时间无关紧要。一旦在客户端收到消息,它将从代理中删除。如果出现错误,消息就会消失。这就是为什么当您想要一个更安全的机制来检索和处理消息时建议使用PeekLock 接收模式的原因。需要注意的是处理时间。因为有足够的信息,我不打算深入讨论,但您可以更新消息的锁定或卸载处理以消除锁定更新的需要。您可以在此answer 中找到替代方案。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-16
      相关资源
      最近更新 更多