StateMachine is registred as Transient, but works as Singleton

92 views
Skip to first unread message

Roman Prykhodko

unread,
Oct 4, 2019, 3:27:32 AM10/4/19
to masstransit-discuss
Hi. My statemachine is registered (.net Core imbedded IOC) as follows:

            .AddTransient<SmLotConfiscatedProperty>()
           
I expect, that every time new event is coming, new statemachine instance is created and process the event.

But now statemachine's constructor is called only once, and all events are processed by single instance! Please advice!

Chris Patterson

unread,
Oct 4, 2019, 11:02:38 AM10/4/19
to masstrans...@googlegroups.com
The state machine is just behavior, it shouldn't have any constructor dependencies. If you have them, you should move them to a state machine activity which is created for each message when events are consumed.


--
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 view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/e4c7c171-99eb-422f-91e1-d1e8fafc1640%40googlegroups.com.

Roman Prykhodko

unread,
Oct 4, 2019, 4:27:22 PM10/4/19
to masstransit-discuss
I have created an simple activity, registered it in IOC and have got exeption:

GreenPipes.PayloadNotFoundException: The payload was not found: Automatonymous.IStateMachineActivityFactory
   at GreenPipes.PipeExtensions.GetPayload[TPayload](PipeContext context)
   at Automatonymous.Activities.ContainerFactoryActivity`3.Automatonymous.Activity<TInstance,TData>.Execute(BehaviorContext`2 context, Behavior`2 next)
   at Automatonymous.Activities.DataConverterActivity`2.Automatonymous.Activity<TInstance>.Execute[T](BehaviorContext`2 context, Behavior`2 next)
   at Automatonymous.Behaviors.LastBehavior`1.Automatonymous.Behavior<TInstance>.Execute[T](BehaviorContext`2 context)
   at Automatonymous.States.StateMachineState`1.Automatonymous.State<TInstance>.Raise[T](EventContext`2 context)
   at Automatonymous.States.StateMachineState`1.Automatonymous.State<TInstance>.Raise[T](EventContext`2 context)
   at Automatonymous.AutomatonymousStateMachine`1.Automatonymous.StateMachine<TInstance>.RaiseEvent[T](EventContext`2 context)
   at Automatonymous.Pipeline.StateMachineSagaMessageFilter`2.Send(SagaConsumeContext`2 context, IPipe`1 next)
   at MassTransit.EntityFrameworkCoreIntegration.Saga.EntityFrameworkSagaRepository`1.MassTransit.Saga.ISagaRepository<TSaga>.Send[T](ConsumeContext`1 context, ISagaPolicy`2 policy, IPipe`1 next)

What's wrong?

On Friday, October 4, 2019 at 6:02:38 PM UTC+3, Chris Patterson wrote:
The state machine is just behavior, it shouldn't have any constructor dependencies. If you have them, you should move them to a state machine activity which is created for each message when events are consumed.


On Fri, Oct 4, 2019 at 2:27 AM Roman Prykhodko <prykhod...@gmail.com> wrote:
Hi. My statemachine is registered (.net Core imbedded IOC) as follows:

            .AddTransient<SmLotConfiscatedProperty>()
           
I expect, that every time new event is coming, new statemachine instance is created and process the event.

But now statemachine's constructor is called only once, and all events are processed by single instance! Please advice!

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