Retry mechanism for activities in Courier

112 views
Skip to first unread message

Emir Ključanin

unread,
Jan 20, 2018, 7:30:30 AM1/20/18
to masstransit-discuss
In the Sample-Courier app if I add UseRetry when registering 'ValidateActivity'  and then throw exception in Execute method of ValidateActivity it never calls Execute again.
This is the changed code for registering endpoint:

x.ReceiveEndpoint(host, ConfigurationManager.AppSettings["ValidateActivityQueue"], e =>
                {
                    e.UseRetry(c =>
                    {
                        c.Interval(5, TimeSpan.FromSeconds(3));
                    });
                    e.PrefetchCount = 100;
                    e.ExecuteActivityHost<ValidateActivity, ValidateArguments>(
                        DefaultConstructorExecuteActivityFactory<ValidateActivity, ValidateArguments>.ExecuteFactory);
                });


Should this work as I described or is it intended to work differently. Should the exception thrown in Execute method of an activity that has retry policy automatically call Compensate of activity that was executed before in the routing slip or should that be done if the last retry fails?

Thank you

Emir Ključanin

unread,
Jan 21, 2018, 5:51:27 PM1/21/18
to masstransit-discuss
Well after playing around it seems that UseRetry needs to be used on ExecuteActivityHost configuration.
So changing the above code to:
x.ReceiveEndpoint(host, ConfigurationManager.AppSettings["RetrieveActivityQueue"], e =>
                {
                    e.PrefetchCount = 100;
                   
                    e.ExecuteActivityHost<RetrieveActivity, RetrieveArguments>(compAddress, c => c.UseRetry(r => r.Immediate(5)));
                });

seems to work (and also I needed to upgrade mass transit to 4.0.

Is this the right approach?

Thank you

Emir Ključanin

unread,
Jan 21, 2018, 6:13:48 PM1/21/18
to masstransit-discuss
Here is the fork with the changes if anyone needs it https://github.com/kljuco/Sample-Courier

Chris Patterson

unread,
Jan 22, 2018, 3:15:23 PM1/22/18
to masstrans...@googlegroups.com
Yes, that's correct. It was added in v4


--
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/34b112ad-375d-4258-bf93-59f234dd4f40%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Emir Ključanin

unread,
Jan 22, 2018, 4:29:20 PM1/22/18
to masstransit-discuss
Thank you very much for the info :)
To post to this group, send email to masstrans...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages