最大重试次数在RetryExponential类中不起作用

时间:2016-10-07 06:39:30

标签: azure azureservicebus azure-service-fabric servicebus

SubscriptionClient receiver = messageFactory.CreateSubscriptionClient("NewTopic", subscriberId);
        TimeSpan e = new TimeSpan(0, 0, 5, 0, 0);
        RetryExponential x = new RetryExponential(e,e,e,e,2);
            OnMessageOptions options = new OnMessageOptions();
            options.AutoComplete = false; 
            //options.AutoRenewTimeout = TimeSpan.FromMinutes(1);
            options.ExceptionReceived += options_ExceptionReceived;
            receiver.OnMessage(receivedMessage =>
            {
                try
                {

                    Console.WriteLine(receivedMessage.Label);

                    bool t = receivedMessage.IsBodyConsumed;
                    Console.WriteLine(string.Format("Message received: {0}", receivedMessage.GetBody<string>()));
                    Console.WriteLine(receivedMessage.SequenceNumber);
                    Console.WriteLine(receivedMessage.TimeToLive);
                    Console.WriteLine(receivedMessage.To);

                    Console.WriteLine(receivedMessage.DeliveryCount);



                    receivedMessage.Abandon();
                }
                catch (Exception)
                {
                    // Indicates a problem, unlock message in subscription.
                    receivedMessage.Abandon();
                }
            }, options);

大家好, 在retryExponential构造函数中,我将maxRetryCount设置为2。 而且我很遗憾地放弃Onmessage中的消息来检查最大重试次数。即使将重试次数设置为2,我也会收到超过2次的消息。 --TIA

1 个答案:

答案 0 :(得分:0)

您似乎对transient fault处理dead lettering.感到困惑

您正在使用的重试机制是应对分布式计算问题。像限制和服务不可用。

如果您无法处理收到的消息,通常会在一些尝试后将其移至DLQ。

(并且您没有使用&#39; x&#39;变量)