Automatonymous saga in mt3 - not acked

106 views
Skip to first unread message

Brian Weeres

unread,
Apr 9, 2015, 6:29:27 PM4/9/15
to masstrans...@googlegroups.com
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 { getset; }
        public Guid CorrelationId { getprivate set; }
    }
 
    public class SimpleTestSaga : MassTransitStateMachine<SimpleTestSagaInstance>
    {
        //States
        public Event<SagaStartMessage> Start { getprivate 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);
    });









Brian Weeres

unread,
Apr 10, 2015, 3:59:28 PM4/10/15
to masstrans...@googlegroups.com
The issue seems to be related to the publish message

  .Publish(context => new TestMessageFromSaga(context.Instance.CorrelationId))

If I replace that publish with a publish from a saved instance of the bus then the saga works properly.


Brian Weeres

unread,
Apr 10, 2015, 4:01:30 PM4/10/15
to masstrans...@googlegroups.com
The code change is 

 Initially(
                When(Start)
                .Then( (context) => MyBusInstance.Publish(new TestMessageFromSaga(context.Instance.CorrelationId)))
                .Finalize());

Brian Weeres

unread,
Apr 10, 2015, 4:42:37 PM4/10/15
to masstrans...@googlegroups.com
Sorry to keep replying to my own post. I just wanted to provide more info. The issue seems to be caused by a SynchronizationLockException that happens in the InMemorySagaRepository. We only use InMemorySagaRepository for testing/POC so I will be checking soon if the NhibernateSagaRepository has a similar issue.

> MassTransit.dll!MassTransit.Saga.InMemorySagaRepository<SendMessage.Saga.Instance>.MassTransit.Saga.ISagaRepository<TSaga>.Send<Test.Messaging.SagaStartMessage>.MoveNext() + 0xab6 bytes

Chris Patterson

unread,
Apr 12, 2015, 11:52:26 PM4/12/15
to masstrans...@googlegroups.com
That's a strange catch, thanks for picking up on it. We should create an issue to make sure I get to it before MT3 is released. Seems strange that Publish would fault with an exception in this case, but I'll check into it.


--
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/d8564cb9-d4b0-49b6-8092-b96036ebfe46%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages