0

In one of my statemachine actions I create a routing slip to carry out a series of commands. This is done by calling

_busControl.Execute(routingSlip);

But sometimes the saga commit fails due to concurrency issues. Is there a "outbox" like mechanism to defer sending the routing slip to the bus until the saga is committed successfully?

zyq
  • 41
  • 9

1 Answers1

0

Yes, you can use the outbox to defer sends:

http://masstransit-project.com/MassTransit/usage/exceptions.html#outbox

cfg.ReceiveEndpoint("input-queue", e =>
{
    e.UseInMemoryOutbox();

    e.StateMachineSaga(...);
});

You will, however, need to execute the routing slip using the ConsumeContext in the state machine event handler, and not using _busControl. IBus or IBusControl should never be used inside a consumer. The documentation has more details.

Chris Patterson
  • 28,659
  • 3
  • 47
  • 59
  • 1
    Thanks for your help. I got it working with `var consumerContext = ctx.CreateConsumeContext(); await consumerContext.Execute(routingSlip);` where ctx is the BehaviorContext – zyq Nov 15 '19 at 04:05