We previously used magnum saga's in MT2 but we are transitioning to automatonymous for mt3. My saga fires up properly when a SagaStartMessage is published but the original start message stays as unacked in the queue. Not sure if I am supposed to do something to get it acked. I created a simple saga that will demonstrate. It is a one state saga that publishes a message and then finishes. The TestMessageFromSaga does get sent properly and that consumer does get it but the original SagaStartMessage is still in the queue as unacked.
public class SimpleTestSagaInstance : SagaStateMachineInstance
{
public SimpleTestSagaInstance(Guid correlationId)
{
CorrelationId = correlationId;
}
protected SimpleTestSagaInstance()
{
}
public int CurrentState { get; set; }
public Guid CorrelationId { get; private set; }
}
public class SimpleTestSaga : MassTransitStateMachine<SimpleTestSagaInstance>
{
//States
public Event<SagaStartMessage> Start { get; private set; }
public SimpleTestSaga()
{
InstanceState(x => x.CurrentState);
Event(() => Start, x => x.CorrelateById(m => m.Message.CorrelationId));
Initially(
When(Start)
.Publish(context => new TestMessageFromSaga(context.Instance.CorrelationId))
.Finalize());
}
}
Here is how I register the saga
x.ReceiveEndpoint(host, "saga_queue", e =>
{
var repo = new InMemorySagaRepository<SimpleTestSagaInstance>();
e.StateMachineSaga(new SimpleTestSaga(), repo);
});