1

I working on a project using masstransit Courier. I'm trying to redeliver a message for reexecuting an activity after 1 hour. This is my code in the execute activity method:

        await context.Redeliver(TimeSpan.FromMinutes(60));
        var (success, message) = await client.performHttpRequest();
        if(!success && context.GetRedeliveryCount() < 10))
        {
            await context.Redeliver(TimeSpan.FromMinutes(60));
        }

But instead of redeliver the compensation begins. I have missed something ?

1 Answers1

3

The only way I know of doing redelivery with routing slip activities is by using the UseScheduledRedelivery middleware. You can throw an exception that is caught by the middleware (you can filter exception types, to only redeliver certain types) and MassTransit will handle the redelivery for you.

For example, if you threw a RescheduleException, you would configure scheduled redelivery as shown:

endpoint.UseScheduledRedelivery(r => 
{
    r.Handle<RescheduleException>();
    r.Intervals(TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(15), TimeSpan.FromMinutes(30)));
});
Chris Patterson
  • 28,659
  • 3
  • 47
  • 59