【问题标题】:Max retry count not working in RetryExponential class最大重试次数在 RetryExponential 类中不起作用
【发布时间】:2017-02-16 01:56:01
【问题描述】:
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

【问题讨论】:

    标签: azure azureservicebus azure-service-fabric servicebus


    【解决方案1】:

    您似乎将transient fault 处理与dead lettering. 混淆了

    您使用的重试机制是为了应对分布式计算问题。比如节流和服务不可用。

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

    (并且您没有使用“x”变量)

    【讨论】:

    • aha 错过了这段代码 receiver.RetryPolicy = x;我正在为接收方分配重试策略。这将控制现在的 maxretry 尝试?
    • SubscriptionClient 接收者 = messageFactory.CreateSubscriptionClient("NewTopic",subscriberId); receiver.RetryPolicy = new RetryExponential(minBackoff:TimeSpan.FromSeconds(0),maxBackoff:TimeSpan.FromSeconds(30),deltaBackoff:TimeSpan.FromSeconds(3),terminationTimeBuffer:TimeSpan.FromSeconds(3),maxRetryCount:3);即使它重试了10次。重试我放弃了消息
    • 我正在使用主题订阅。我没有看到任何可以设置 MaxDeliveryCount 属性的地方。
    猜你喜欢
    • 2020-05-14
    • 1970-01-01
    • 2016-05-10
    • 1970-01-01
    • 2016-10-12
    • 2016-11-17
    • 1970-01-01
    • 1970-01-01
    • 2018-11-04
    相关资源
    最近更新 更多