Cannot persist in final state for MassTransitStateMachine

247 views
Skip to first unread message

tianyingwang

unread,
Jan 11, 2017, 12:19:41 PM1/11/17
to masstransit-discuss
I have a MassTransitStateMachine with Automatonymous.

Several states such as Process and Completed. I can save Process state into database so I think my SagaRepository is setup OK, however cannot save the completed state or final state into database.

Below is the piece of code, I can see in my debugger that the PreprocessForComplete() function get called, so I assume the Finalize() should be called. But my database still stay in Process State.

Anyone could give me some suggestions where I should check?

Thank you so much.

            DuringAny(
                ..........
                ..........
                When(ReadyForComplete)
                    .Then(PreprocessForComplete)
                    .TransitionTo(Completed)
                    .Finalize()
                    );

Alexey Zimarev

unread,
Jan 12, 2017, 1:02:08 PM1/12/17
to masstransit-discuss
Do you have 
SetCompletedWhenFinalized();
?

tianyingwang

unread,
Jan 13, 2017, 11:38:12 AM1/13/17
to masstransit-discuss
Alexey, thank you for your suggestion.

I did test with and without "SetCompletedWhenFinalized();", still cannot persist state into table.

Seems it will take some TransitionTo, but not the others, I double check the correlationid, all matched well. Very strange.

I am using NHibernate, anyone experience this kind of problem?

On Thursday, January 12, 2017 at 12:02:08 PM UTC-6, Alexey Zimarev wrote:
Do you have 
SetCompletedWhenFinalized();
?

Chris Patterson

unread,
Jan 13, 2017, 12:00:48 PM1/13/17
to masstrans...@googlegroups.com
Finalize() is the same as TransitionTo(Final), so the TransitionTo(Completed) isn't really doing anything for you, unless it's part of a composite event.


--
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/e350f035-0e7b-42a7-8d09-c880f7bd6d1c%40googlegroups.com.

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

Alexey Zimarev

unread,
Jan 13, 2017, 2:36:49 PM1/13/17
to masstransit-discuss
With NHibernate saga persistence, completed sagas are removed. If you want to have your saga in some custom "Completed" state at the end, and not being removed, you can just remove "Finalize()". 
I believe you are making two conflicting transitions and this creates issues for you.

tianyingwang

unread,
Jan 20, 2017, 10:03:16 AM1/20/17
to masstransit-discuss
Thank you Alexey. I cannot get to test since our QA is testing for a release soon. I am going to build a small project to test your suggestion. Thanks again.

tianyingwang

unread,
Jan 20, 2017, 10:05:43 AM1/20/17
to masstransit-discuss
Quick question Chris,

Do you know which api call trigger the save the state change into database?  Is that TransitionTo(State)? 

Thank you.



On Friday, January 13, 2017 at 11:00:48 AM UTC-6, Chris Patterson wrote:
Finalize() is the same as TransitionTo(Final), so the TransitionTo(Completed) isn't really doing anything for you, unless it's part of a composite event.

On Fri, Jan 13, 2017 at 8:38 AM, tianyingwang <tianyi...@gmail.com> wrote:
Alexey, thank you for your suggestion.

I did test with and without "SetCompletedWhenFinalized();", still cannot persist state into table.

Seems it will take some TransitionTo, but not the others, I double check the correlationid, all matched well. Very strange.

I am using NHibernate, anyone experience this kind of problem?

On Thursday, January 12, 2017 at 12:02:08 PM UTC-6, Alexey Zimarev wrote:
Do you have 
SetCompletedWhenFinalized();
?

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

Alexey Zimarev

unread,
Jan 20, 2017, 10:24:46 AM1/20/17
to masstransit-discuss
I am not Chris but each persistence is a filter. It retrieves one or more instances and send them further. Each Send causes RaiseEvent in Automatonymous, which triggers all During/When combinations that match the received event. When all processing is done, the new saga state is persisted at once.

Chris Patterson

unread,
Jan 20, 2017, 10:51:28 AM1/20/17
to masstrans...@googlegroups.com
Alexey is correct, the flow is:

(message received)
(saga instance loaded)
(all state machine processing performed)
(sage instance saved)
(message receive complete)


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