Combining retries and redelivery

756 views
Skip to first unread message

Alex Wheat

unread,
Feb 20, 2018, 1:22:05 PM2/20/18
to masstransit-discuss
Documentation here says that it's possible to combine first- and second-level retries. But it's not very clear how to do that. 

The aim, that I'm trying to achieve, is to try redelivery problem message using first-level UseRetry and, if wasn't successfully consumed, try to redeliver it later using the second-level retry mechanism. 

Here is my configuration that I'm playing with
x.UseDelayedExchangeMessageScheduler();

x.ReceiveEndpoint(host, "receiver_queue", e =>
{
    e
.Consumer<TestHandler>(c => c.Message<TestCommand>(m =>
   
{
        m
.UseRetry(r => r.Incremental(2, TimeSpan.FromMilliseconds(10), TimeSpan.FromMilliseconds(5)));
        m
.UseDelayedRedelivery(r => r.Incremental(2, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(5)));
   
}));
});


in this case I get message redelivered two times using second-level retry. How can I get it redelivered using first-level retry as well? 

Chris Patterson

unread,
Feb 20, 2018, 1:28:25 PM2/20/18
to masstrans...@googlegroups.com
Switch the order, it's a pipeline, so you need to have the delayed redelivery first, followed by the immediate retry policy.



--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstransit-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/d815cb23-6a36-4ae0-8cf4-72dd3bd213c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Wheat

unread,
Feb 20, 2018, 2:22:45 PM2/20/18
to masstransit-discuss
Hi Chris,

yes, I was thinking about it but it doesn't help... 

if I switch the order the message almost immediately redelivered to the consumer 2 times and after that moved to error and skipped queues.

Here is the message from error queue (there is no MT-Redelivery-Count header inside)


Exchange receiver_queue_error
Routing Key
Redelivered
Properties
message_id: c8290000-65f8-1c6f-39ac-08d578961752
delivery_mode: 2
headers:
Content-Type: application/vnd.masstransit+json
publishId: 1
MT-Host-MachineName: DESKTOP-FCRE1G3
MT-Host-ProcessName: dotnet
MT-Host-ProcessId: 24332
MT-Host-Assembly: Receiver
MT-Host-AssemblyVersion: 1.0.0.0
MT-Host-MassTransitVersion: 4.1.0.1412
MT-Host-FrameworkVersion: 4.0.30319.42000
MT-Host-OperatingSystemVersion: Microsoft Windows NT 6.2.9200.0
MT-Reason: fault
MT-Fault-ExceptionType: System.Exception
MT-Fault-Message: Something went wrong...
MT-Fault-Timestamp: 2018-02-20T19:14:00.7783148Z
MT-Fault-StackTrace: at Receiver.TestHandler.Consume(ConsumeContext`1 context) in D:\Projects\SDS\sandbox\EventsConcurrencyTest\Receiver\CommandHandlers\TestHandler.cs:line 15 
at MassTransit.Pipeline.ConsumerFactories.DefaultConstructorConsumerFactory`1.<Send>d__0`1.MoveNext() 
at MassTransit.Pipeline.Filters.ConsumerMessageFilter`2.<GreenPipes-IFilter<MassTransit-ConsumeContext<TMessage>>-Send>d__4.MoveNext() 
at MassTransit.Pipeline.Filters.ConsumerMessageFilter`2.<GreenPipes-IFilter<MassTransit-ConsumeContext<TMessage>>-Send>d__4.MoveNext() 
at GreenPipes.Filters.RetryFilter`1.<Attempt>d__5.MoveNext() 
at GreenPipes.Filters.RetryFilter`1.<Attempt>d__5.MoveNext() 
at GreenPipes.Filters.RetryFilter`1.<GreenPipes-IFilter<TContext>-Send>d__4.MoveNext() 
at MassTransit.Pipeline.Filters.RedeliveryRetryFilter`1.<Send>d__4.MoveNext() 
at MassTransit.Pipeline.Filters.RedeliveryRetryFilter`1.<Send>d__4.MoveNext() 
at GreenPipes.Filters.TeeFilter`1.<Send>d__5.MoveNext() 
at GreenPipes.Filters.OutputPipeFilter`2.<GreenPipes-IFilter<TInput>-Send>d__6.MoveNext() 
at GreenPipes.Filters.OutputPipeFilter`2.<GreenPipes-IFilter<TInput>-Send>d__6.MoveNext() 
at MassTransit.Pipeline.Filters.DeserializeFilter.<Send>d__4.MoveNext() 
at GreenPipes.Filters.RescueFilter`2.<GreenPipes-IFilter<TContext>-Send>d__5.MoveNext()
content_type: application/vnd.masstransit+json
Payload
831 bytes
Encoding: string
{
  "messageId": "c8290000-65f8-1c6f-39ac-08d578961752",
  "conversationId": "c8290000-65f8-1c6f-9eb0-08d57896175b",
  "sourceAddress": "rabbitmq://localhost/osdr_dev/bus-DESKTOP-FCRE1G3-dotnet-3ywoyydf9yqg6efebdkztfosdx?durable=false&autodelete=true",
  "destinationAddress": "rabbitmq://localhost/osdr_dev/Domain.Commands:TestCommand",
  "messageType": [
    "urn:message:Domain.Commands:TestCommand"
  ],
  "message": {
    "id": "449d4107-53fa-4fb6-b122-9be73ff6c3fd"
  },
  "headers": {},
  "host": {
    "machineName": "DESKTOP-FCRE1G3",
    "processName": "dotnet",
    "processId": 24864,
    "assembly": "Sender",
    "assemblyVersion": "1.0.0.0",
    "frameworkVersion": "4.0.30319.42000",
    "massTransitVersion": "4.1.0.1412",
    "operatingSystemVersion": "Microsoft Windows NT 6.2.9200.0"
  }
}


On Tuesday, February 20, 2018 at 1:28:25 PM UTC-5, Chris Patterson wrote:
Switch the order, it's a pipeline, so you need to have the delayed redelivery first, followed by the immediate retry policy.


On Tue, Feb 20, 2018 at 10:22 AM, Alex Wheat <alekse...@gmail.com> wrote:
Documentation here says that it's possible to combine first- and second-level retries. But it's not very clear how to do that. 

The aim, that I'm trying to achieve, is to try redelivery problem message using first-level UseRetry and, if wasn't successfully consumed, try to redeliver it later using the second-level retry mechanism. 

Here is my configuration that I'm playing with
x.UseDelayedExchangeMessageScheduler();

x.ReceiveEndpoint(host, "receiver_queue", e =>
{
    e
.Consumer<TestHandler>(c => c.Message<TestCommand>(m =>
   
{
        m
.UseRetry(r => r.Incremental(2, TimeSpan.FromMilliseconds(10), TimeSpan.FromMilliseconds(5)));
        m
.UseDelayedRedelivery(r => r.Incremental(2, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(5)));
   
}));
});


in this case I get message redelivered two times using second-level retry. How can I get it redelivered using first-level retry as well? 

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.

Chris Patterson

unread,
Feb 20, 2018, 4:13:55 PM2/20/18
to masstrans...@googlegroups.com
Yeah, something isn't right here, well, it's actually exactly right, but the way it's built is wrong...

Since the inner retry policy is exhausted, and the outer retry policy finds the existing RetryContext in the payload, it's recognizing that the retry for that message type has already tried and failed, so it isn't triggering the redelivery code.

I'll have to dig into this further and come up with a solution.



To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsubscribe...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.

Alex Wheat

unread,
Feb 21, 2018, 9:18:20 AM2/21/18
to masstransit-discuss
Thank you, Chris! 
Appreciate your quick response and paying attention to this case.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.

Alex Wheat

unread,
Mar 5, 2018, 7:50:59 PM3/5/18
to masstransit-discuss
Hi Chris,

Did you have any chance to take a look into the issue?

Regards,
Alex

Chris Patterson

unread,
Mar 6, 2018, 12:43:18 AM3/6/18
to masstrans...@googlegroups.com

Alex
Thank you, Chris! 
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsubscribe...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsubscribe...@googlegroups.com.

To post to this group, send email to masstrans...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages