PayloadNotFoundException in Statemachine Activity

336 views
Skip to first unread message

Roman Prykhodko

unread,
Oct 7, 2019, 10:31:53 AM10/7/19
to masstransit-discuss
1. I have created simple Activity

public class PublishLotActivity : Activity<LotSaga, SmLotPublishEvent>
{
 
private ILotManager _lotManager;
 
public PublishLotActivity(ILotManager lotManager)
 
{
 _lotManager
= lotManager;
 
}
 
public async Task Execute(BehaviorContext<LotSaga, SmLotPublishEvent> context, Behavior<LotSaga, SmLotPublishEvent> next)
 
{
 await
next.Execute(context).ConfigureAwait(false);
 
throw new NotImplementedException();
 
}
 
public async Task Faulted<TException>(BehaviorExceptionContext<LotSaga, SmLotPublishEvent, TException> context, Behavior<LotSaga, SmLotPublishEvent> next) where TException : Exception
 
{
 
throw new NotImplementedException();
 
}
 
public void Probe(ProbeContext context)
 
{
 
throw new NotImplementedException();
 
}
 
public void Accept(StateMachineVisitor visitor)
 
{
 
throw new NotImplementedException();
 
}
}


2. Registered it in IOC 

.AddTransient<PublishLotActivity>()

3. Used in StateMachine (which worked fine before Activity adding)

During(Initial,
 
When(PublishEvent)
 
.TransitionTo(PreCreated)
 
.Activity(ctx => ctx.OfType<PublishLotActivity>())

Here is event declaration

Event(() => PublishEvent, x => x.CorrelateById(context => context.Message.Id));

Result: exception:

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)

Please help!
Thanks!

 

Chris Patterson

unread,
Oct 7, 2019, 3:03:50 PM10/7/19
to masstrans...@googlegroups.com
How are you configuring your state machine on the receive endpoint? It should be using the extension method for Automatonymous:

endpoint.StateMachineSaga<LotStateMachine, LotSaga>(provider);

Or something to that effect.

--
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/e727c7d6-610b-42d3-839f-ab45fc3175a1%40googlegroups.com.

Roman Prykhodko

unread,
Oct 8, 2019, 2:56:48 AM10/8/19
to masstransit-discuss
busConfig.Add($"{StateMachineQueuePrefixes.TradingLotStateMachineQueuePrefix}.{auctionType}",
 e
=>
 
{
     e
.UseInMemoryOutbox();
     
e.StateMachineSaga(serviceProvider.GetRequiredService<TLotStateMachine>(), GetLotSagaRepository(ContextFactory));
     e
.UseRetry(RetryConfigurator);
 
});

public static EntityFrameworkSagaRepository<LotSaga> GetLotSagaRepository(Func<DbContext> contextFactory)
{
   
return new EntityFrameworkSagaRepository<LotSaga>(contextFactory, IsolationLevel.RepeatableRead, true, null, GetPostgresRelationalMetadataHelper());
}

private static EntityFrameworkMetadataHelper GetPostgresRelationalMetadataHelper()
{
 
return new EntityFrameworkMetadataHelper(defaultSchema: "public", relationalEntityTypeAnnotations: ta => ta.Npgsql());
}

DbContext ContextFactory()
{
 
return serviceProvider.GetRequiredService<TradingContext>();
}
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.

Chris Patterson

unread,
Oct 9, 2019, 1:37:07 PM10/9/19
to masstrans...@googlegroups.com
Use the property extension package for your container, and configure it using?

e.UseMessageRetry();
e.UseInMemoryOutbox();
e.StateMachineSaga<TMachine, TInstance>(serviceProvider);

Also, notice the order matters.


To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@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-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/000626e0-dd77-42e3-9cfd-3caa7a8d55bb%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages