How to get new instance of routing slip activity or consumer when using retry

31 views
Skip to first unread message

Emir Ključanin

unread,
Jan 22, 2018, 9:59:26 AM1/22/18
to masstransit-discuss
Hi all,
As I've noticed if we use retry policy on routing slip activity or even on a consumer the instance is not recreated, but only Execute/Consume methods are called reusing initial instance of Activity/Consumer.
Is there a way to avoid this behavior (I'm more interested in avoiding this for Activity). We need this because of dependency injection, as we don't get updated EF dbcontext when retrying activity because it is injected trough constructor.

Thank you

Emir Ključanin

unread,
Jan 22, 2018, 12:00:36 PM1/22/18
to masstransit-discuss
Actually it seems that consumer has new instance every time it's retrying, but I cannot manage to figure out how to do this for activities. Is this even possible?
Thank you

Emir Ključanin

unread,
Jan 22, 2018, 4:20:17 PM1/22/18
to masstransit-discuss
So when debugging RetryActivity_Specs.cs (When_using_retry_middleware_for_courier) FaultyActivity constructor is actually called only once and Execute is called multiple times. Does this mean that my assumption was right? That retry mechanism for activity will reuse the same activity? Is there a proper way to handle constructor DI? 
Thank you
Reply all
Reply to author
Forward
0 new messages