Request activity fails when transition is due to internal RaiseEvent

63 views
Skip to first unread message

Alex Michel

unread,
Oct 21, 2015, 9:31:46 AM10/21/15
to masstransit-discuss
Hi,
In MT3 Saga if I call RaiseEvent inside Then or ThenAsync activity and there is a Request called during handling of this event, 
Request is not executed and fails with following exception:

Exception thrown: 'System.ArgumentException' in MassTransit.AutomatonymousIntegration.dll
Additional information: The ConsumeContext was not available

E.g.:

Initially(When(WorkRequested)                
                .TransitionTo(Validating)
                .Then(context => this.RaiseEvent(context.Instance,RequestValidated,context.Data)));
During(Validating, 
When(RequestValidated, filter => filter.Data.IsValid)
                    .TransitionTo(SomeWorkFlow.Pending)
                    .Request(SomeWorkFlow,context=>context.Data)));

Somehow it looses the context.
Hope it makes sense. 

Chris Patterson

unread,
Oct 21, 2015, 9:39:43 AM10/21/15
to masstrans...@googlegroups.com
Yeah I see what's happening and it is going to require some under the hood glue to make it do what you expect. Or you can pass the ConsumeContext as an argument on the tail end of the RaiseEvent call to store it in the payload of the event. That's what the under the hood tweaks are going to do anyway. 

__
Chris Patterson




--
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-dis...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/7824ca02-67ed-4c5a-b3ff-ecd1cdd13186%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Michel

unread,
Oct 21, 2015, 9:56:59 AM10/21/15
to masstransit-discuss
I see. I think I will do another Request instead but host the validation logic in same process.


On Wednesday, October 21, 2015 at 4:39:43 PM UTC+3, Chris Patterson wrote:
Yeah I see what's happening and it is going to require some under the hood glue to make it do what you expect. Or you can pass the ConsumeContext as an argument on the tail end of the RaiseEvent call to store it in the payload of the event. That's what the under the hood tweaks are going to do anyway. 

__
Chris Patterson




On Wed, Oct 21, 2015 at 6:31 AM -0700, "Alex Michel" <ami...@gmail.com> wrote:

Hi,
In MT3 Saga if I call RaiseEvent inside Then or ThenAsync activity and there is a Request called during handling of this event, 
Request is not executed and fails with following exception:

Exception thrown: 'System.ArgumentException' in MassTransit.AutomatonymousIntegration.dll
Additional information: The ConsumeContext was not available

E.g.:

Initially(When(WorkRequested)                
                .TransitionTo(Validating)
                .Then(context => this.RaiseEvent(context.Instance,RequestValidated,context.Data)));
During(Validating, 
When(RequestValidated, filter => filter.Data.IsValid)
                    .TransitionTo(SomeWorkFlow.Pending)
                    .Request(SomeWorkFlow,context=>context.Data)));

Somehow it looses the context.
Hope it makes sense. 

--
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 Michel

unread,
Oct 21, 2015, 9:59:26 AM10/21/15
to masstransit-discuss
Actually I don't think I have access to ConsumeContext inside Then.

Chris Patterson

unread,
Oct 21, 2015, 12:22:36 PM10/21/15
to masstrans...@googlegroups.com
You do, you just have to GetPayload<ConsumeContext> (or TryGetPayload, either way) - as it is part of the eventContext payload collection. That's what it is doing under the hood.


These are going to be in the next release, but you can duplicate the logic for now.


On Wed, Oct 21, 2015 at 6:59 AM, Alex Michel <ami...@gmail.com> wrote:
Actually I don't think I have access to ConsumeContext inside Then.

--
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-dis...@googlegroups.com.

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

Punella Carmine

unread,
Jan 22, 2017, 10:03:44 AM1/22/17
to masstransit-discuss
Hi, 

I'm writing Unit Test in order to test the saga. I want to set the saga at a specific state before test only a particular state, but the problem is that when I use the RaiseEvent mehod the same exception (Exception thrown: 'System.ArgumentException' in MassTransit.AutomatonymousIntegration.dll Additional information: The ConsumeContext was not available) is thrown. 

I read that I have to pass the ConsumeContext, but I don't find the way I can get it. I'm using the MassTransit.TestFramework and my TestClass inherits from InMemoryTestFixture. 

Any help?

Thanks 

On Wednesday, October 21, 2015 at 6:22:36 PM UTC+2, Chris Patterson wrote:
You do, you just have to GetPayload<ConsumeContext> (or TryGetPayload, either way) - as it is part of the eventContext payload collection. That's what it is doing under the hood.


These are going to be in the next release, but you can duplicate the logic for now.

On Wed, Oct 21, 2015 at 6:59 AM, Alex Michel <ami...@gmail.com> wrote:
Actually I don't think I have access to ConsumeContext inside Then.

--
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.
Reply all
Reply to author
Forward
0 new messages