Example for mt3 saga that uses Automatonymous, nhibernate and sql server

237 views
Skip to first unread message

Brian Weeres

unread,
Apr 15, 2015, 12:13:47 PM4/15/15
to masstrans...@googlegroups.com
Does anyone have an example for an MT3 saga that uses Automatonymous, nhibernate and sql server? I can't seem to get it to work and I am not sure how to configure the repository and sessionfactory.
I can get and Automatonymous saga to work with an in memory repository but not one using nhibernate and sql server. My saga's start fine and save to sql server but they never receive a second message.

I am not even sure which objects to use. There is an Automatonymous.SqlServerSessionFactoryProvider and a MassTransit.NHibernateIntegration.SqlServerSessionFactoryProvider. 
There is a NHibernateSagaRepository and an Automatonymous.AutomatonymousStateMachineSagaRepository. Am I supposed to create a NHibernateSagaRepository and pass that to the Automatonymous.AutomatonymousStateMachineSagaRepository ?
If I am supposed to use AutomatonymouseStateMachineSagaRespository what is the completed expression and what goes in the correlations? My saga class already has correlations in the Events.

I have looked at the Riktig sample but that is mt2 and use completely different objects. I have also looked at the tests in the source for MT3 but they don't use Automatonymous and nhibernate and sql server.

Thanks for any help,
Brian

Chris Patterson

unread,
Apr 15, 2015, 12:45:26 PM4/15/15
to masstrans...@googlegroups.com
They do use it with SQLite though, which is just a matter of changing the connection strings.



--
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/16299ee9-2880-44c8-8174-5313cfff7cca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Brian Weeres

unread,
Apr 15, 2015, 3:12:58 PM4/15/15
to masstrans...@googlegroups.com
Looked at that code many times but revisited again. I had three issues that resulted from carrying the saga over from magnum to automatonymous
1. No CurrentState defined in my instance  public State CurrentState { getset; }
1. No call to StateProperty in my DataMap:  this.StateProperty<TutorialSagaInstanceTutorialSaga>(x => x.CurrentState);
2. No declaration of the states in the saga :   State(() => WaitingForMessageOneResult); (I had WaitingForMessageOneResult defined but didn't call State.)

With those three changes my nhibernate, sql server, automatonymous MT3 sagas work like a charm. Without those three changes the automatonymous saga seemed to work fine with the InMemoryRepository which was sort of a red herring.

Thanks for the quick response Chris!




On Wednesday, April 15, 2015 at 11:45:26 AM UTC-5, Chris Patterson wrote:
They do use it with SQLite though, which is just a matter of changing the connection strings.


On Wed, Apr 15, 2015 at 9:13 AM, Brian Weeres <bwe...@gmail.com> wrote:
Does anyone have an example for an MT3 saga that uses Automatonymous, nhibernate and sql server? I can't seem to get it to work and I am not sure how to configure the repository and sessionfactory.
I can get and Automatonymous saga to work with an in memory repository but not one using nhibernate and sql server. My saga's start fine and save to sql server but they never receive a second message.

I am not even sure which objects to use. There is an Automatonymous.SqlServerSessionFactoryProvider and a MassTransit.NHibernateIntegration.SqlServerSessionFactoryProvider. 
There is a NHibernateSagaRepository and an Automatonymous.AutomatonymousStateMachineSagaRepository. Am I supposed to create a NHibernateSagaRepository and pass that to the Automatonymous.AutomatonymousStateMachineSagaRepository ?
If I am supposed to use AutomatonymouseStateMachineSagaRespository what is the completed expression and what goes in the correlations? My saga class already has correlations in the Events.

I have looked at the Riktig sample but that is mt2 and use completely different objects. I have also looked at the tests in the source for MT3 but they don't use Automatonymous and nhibernate and sql server.

Thanks for any help,
Brian

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

Chris Patterson

unread,
Apr 15, 2015, 4:40:34 PM4/15/15
to masstrans...@googlegroups.com
Glad you got it working! And yes, without those extra mapping NHibernate sort of pukes up a lung.

The declaring of the states should no longer be mandatory, however. I've made them initialize by themselves I think unless they are special or uncorrelated.


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.

Brian Weeres

unread,
Apr 16, 2015, 11:11:38 AM4/16/15
to masstrans...@googlegroups.com
Can confirm I do not need the state declarations anymore.


On Wednesday, April 15, 2015 at 3:40:34 PM UTC-5, Chris Patterson wrote:
Glad you got it working! And yes, without those extra mapping NHibernate sort of pukes up a lung.

The declaring of the states should no longer be mandatory, however. I've made them initialize by themselves I think unless they are special or uncorrelated.

On Wed, Apr 15, 2015 at 12:12 PM, Brian Weeres <bwe...@gmail.com> wrote:
Looked at that code many times but revisited again. I had three issues that resulted from carrying the saga over from magnum to automatonymous
1. No CurrentState defined in my instance  public State CurrentState { getset; }
1. No call to StateProperty in my DataMap:  this.StateProperty<TutorialSagaInstanceTutorialSaga>(x => x.CurrentState);
2. No declaration of the states in the saga :   State(() => WaitingForMessageOneResult); (I had WaitingForMessageOneResult defined but didn't call State.)

With those three changes my nhibernate, sql server, automatonymous MT3 sagas work like a charm. Without those three changes the automatonymous saga seemed to work fine with the InMemoryRepository which was sort of a red herring.

Thanks for the quick response Chris!




On Wednesday, April 15, 2015 at 11:45:26 AM UTC-5, Chris Patterson wrote:
They do use it with SQLite though, which is just a matter of changing the connection strings.


On Wed, Apr 15, 2015 at 9:13 AM, Brian Weeres <bwe...@gmail.com> wrote:
Does anyone have an example for an MT3 saga that uses Automatonymous, nhibernate and sql server? I can't seem to get it to work and I am not sure how to configure the repository and sessionfactory.
I can get and Automatonymous saga to work with an in memory repository but not one using nhibernate and sql server. My saga's start fine and save to sql server but they never receive a second message.

I am not even sure which objects to use. There is an Automatonymous.SqlServerSessionFactoryProvider and a MassTransit.NHibernateIntegration.SqlServerSessionFactoryProvider. 
There is a NHibernateSagaRepository and an Automatonymous.AutomatonymousStateMachineSagaRepository. Am I supposed to create a NHibernateSagaRepository and pass that to the Automatonymous.AutomatonymousStateMachineSagaRepository ?
If I am supposed to use AutomatonymouseStateMachineSagaRespository what is the completed expression and what goes in the correlations? My saga class already has correlations in the Events.

I have looked at the Riktig sample but that is mt2 and use completely different objects. I have also looked at the tests in the source for MT3 but they don't use Automatonymous and nhibernate and sql server.

Thanks for any help,
Brian

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

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

Chris Patterson

unread,
Apr 16, 2015, 6:47:09 PM4/16/15
to masstrans...@googlegroups.com
With MT3, you no longer need to declare the states.

The events, however, must be specified so that they are initialized properly.


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