【问题标题】:MassTransit bypass retry policy when non transient error occurs发生非暂时性错误时 MassTransit 绕过重试策略
【发布时间】:2016-04-11 00:43:41
【问题描述】:

关于非暂时性错误的短路重试策略的指导是什么。

情景。

使用附加到 RabbitMq 的 MassTransit v3。 一个简单的重试策略尝试在管道中设置 5 次。 在消息的消费中,发生不可恢复的错误,而不是抛出异常并重试4次我想将此消息移动到错误队列中。

【问题讨论】:

  • 好吧,看起来就是这样。 var retryPolicy = new ExponentialRetryPolicy(filter: new PolicyExceptPolicyExceptionFilter(typeof(SchemaValidationException)), retryLimit: 5, minInterval: TimeSpan.FromSeconds(1), maxInterval: TimeSpan.FromSeconds(30), intervalDelta: TimeSpan.FromSeconds(5));

标签: rabbitmq masstransit


【解决方案1】:

你可以使用:

Retry.Except<BadException>().Immediate(5);

【讨论】:

    【解决方案2】:

    出于某种原因,克里斯的解决方案对我不起作用。也许我是从错误的上下文中拨打这个电话的。唯一有效的是进行两次 UseRetry 调用:

                configurator.ReceiveEndpoint(host, _config.QueueName, ec =>
                {
                    ...
    
                    // Configure retries to immediately fail on permanent consumer faults
                    ec.UseRetry(r => r.None().Handle<ConsumerPermanentFaultException>());
    
                    // Configure all other retries as incremental
                    ec.UseRetry(r =>
                    {
                        r.Incremental(_config.RetryCount, _config.RetryInterval, _config.RetryIntervalIncrement)
                            .Ignore<ConsumerPermanentFaultException>();
                    });
    
                    // Load consumers from the container
                    ec.LoadFrom(consumerContainer);
                });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多