NServicebus Sagas: SagaNotFound warning even though it finds it...

755 views
Skip to first unread message

dirk.mcs...@gmail.com

unread,
Oct 22, 2014, 5:30:05 AM10/22/14
to particula...@googlegroups.com
Product name: NServicebus
Version: 4.3.3


Hi there,

I hope someone can help me with my problem as I have googled it like crazy with no result.

I am trying to implement a saga in NServicebus. The handle method in the saga calls two different handlers through the bus using the bus.Send() method (see the code below). Then, when each handler is done with its work, it sends a notify message in the same way back to the saga. The saga checks its state and calls MarkAsComplete()  when all steps are done. I am using one message queue and endpoint for all communication in this saga.

I get the following two warning lines per handler just before reaching the methods public void Handle(Notify1DataMessage message) and public void Handle(Notify2DataMessage message):

----------------------------------

Warn : Could not find a saga for the message type Notify1Message with id [GUID]. Going to invoke SagaNotFoundHandlers.

WARN: NServiceBus.Sagas.SagaPersistenceBehavior: Could not find a saga for the message type namespace.Notify1Message with id [GUID]. Going to invoke SagaNotFoundHandlers.

---------------------------------

What am I doing wrong? Everything works fine, it finds the notify handle methods in the saga, but why is it complaining? 


Relevant code:


public class RemovalSaga : Saga<SomeSagaData>,
           IAmStartedByMessages<RemoveDataMessage>,
   IHandleMessages<Notify1DataMessage>,
   IHandleMessages<Notify2DataMessage>

    // The mapping uses a string property called QueueMessage that is unique
    public override void ConfigureHowToFindSaga()
    {
        ConfigureMapping<RemoveDataMessage>(m => m.QueueMessage).ToSaga(saga => saga.QueueMessage);
        ConfigureMapping<Notify1DataMessage>(m => m.QueueMessage).ToSaga(saga => saga.QueueMessage);
        ConfigureMapping<Notify2DataMessage>(m => m.QueueMessage).ToSaga(saga => saga.QueueMessage);
    }

    public void Handle(RemoveDataMessage message)
    {
Data.QueueMessage = message.QueueMessage;
//...
              var message1 = new Handler1DataMessage
{
            QueueMessage = Data.QueueMessage
};
_bus.Send(message1);

var message2 = new Handler2DataMessage
{
    QueueMessage = Data.QueueMessage
};
_bus.Send(message2);
    }

    // The warning fires just before this Handle method is reached.
    public void Handle(Notify1DataMessage message)
    {
        //...
if (!Data.AllStepsDone) return;
MarkAsComplete();
    }

    // The warning fires just before this Handle method is reached.
    public void Handle(Notify2DataMessage message)
    {
        //...
if (!Data.AllStepsDone) return;
MarkAsComplete();
    }
}



//Both handlers have the same relevant code (showing one of them):
public class Handler1 : IHandleMessages<Handler1DataMessage>
    //...
    public void Handle(Handler1DataMessage message)
    {
        //...
var notifyMessage = new Notify1DataMessage
        {
     QueueMessage = message.QueueMessage
        };
        _bus.Send(notifyMessage);
    }
}



//Endpoint configuration:
public class EndpointConfig : IConfigureThisEndpoint, AsA_Server, IWantCustomInitialization
{
    public void Init()
    {
        //...
Configure.Features.Enable<Sagas>();
        Configure.With()
.LicensePath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "License\\License.xml"))
.NinjectBuilder(kernel)
.UseTransport<Msmq>()
                .RavenPersistence()
                .RavenSagaPersister()
.UnicastBus()
.LoadMessageHandlers()
.UseRavenTimeoutPersister();
    }
}


//SomeSagaData:
public class SomeSagaData : IContainSagaData
{
    [Unique]
    public virtual string QueueMessage { get; set; }

    public virtual Guid Id { get; set; }
    public virtual string Originator { get; set; }
    public virtual string OriginalMessageId { get; set; }
    //...
}



Andreas Öhlund

unread,
Oct 22, 2014, 8:13:24 AM10/22/14
to particula...@googlegroups.com
Do you happen to have other sagas in the same endpoint handling the same message?

Is it possible for you to try the latest v4.7? (I think we've found and fixed a similar bug but I'm struggling to find it)

--
You received this message because you are subscribed to the Google Groups "Particular Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to particularsoftw...@googlegroups.com.
To post to this group, send email to particula...@googlegroups.com.
Visit this group at http://groups.google.com/group/particularsoftware.
To view this discussion on the web visit https://groups.google.com/d/msgid/particularsoftware/06d8c2ab-0afd-4463-aab2-6e934f6db843%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

dirk.mcs...@gmail.com

unread,
Oct 22, 2014, 8:43:45 AM10/22/14
to particula...@googlegroups.com
Hi Andreas,

Thanks for your reply.

This is the only saga in the endpoint.
Are there any major changes between 4.3.3 and 4.7.0? An upgrade will affect a lot of systems. It would be really great if you could find out in which version the problem was solved.

Best Regards,
Dirk

To unsubscribe from this group and stop receiving emails from it, send an email to particularsoftware+unsub...@googlegroups.com.

Andreas Öhlund

unread,
Oct 22, 2014, 8:51:53 AM10/22/14
to particula...@googlegroups.com
>Are there any major changes between 4.3.3 and 4.7.0? An upgrade will affect a lot of systems. It would be really great if you could find out in which version the problem was solved.
We're following SemVer so there should be no breaking changes so you can safely upgrade.

I'll do my best to find the issue mentioned. Would you be able to upgrade the endpoint locally just to see if it fixes the issue?

To unsubscribe from this group and stop receiving emails from it, send an email to particularsoftw...@googlegroups.com.

To post to this group, send email to particula...@googlegroups.com.
Visit this group at http://groups.google.com/group/particularsoftware.

indu.alagarsamy

unread,
Oct 22, 2014, 9:41:11 PM10/22/14
to particula...@googlegroups.com
Hi,

I tried the following in both 4.3.3 and 4.7.1 and both seem to work.
Could it be possible that you didn't set a state in the saga data when you've received the response?
Or can you verify the logic that checks to see if all steps are done? 
If there is a bug there, and one of the responses is completing the saga, then I would expect that when the other response arrives, a saga not found would be invoked.

Here's my saga and the saga data that I used to verify.
It's possible that I could've missed something in trying to reproduce this, in which case can you send us your repro?
 
Thanks much,
Indu Alagarsamy
Particular Software

**** SAGA ****

  public class TestSaga : Saga<TestSagaData>,

        IAmStartedByMessages<StartSaga>,

        IHandleMessages<ProcessSomething1Response>,

        IHandleMessages<ProcessSomething2Response>,

        IHandleSagaNotFound


    {

        public override void ConfigureHowToFindSaga()

        {

            ConfigureMapping<ProcessSomething1Response>(message => message.MessageId).ToSaga(data => data.MessageId);

            ConfigureMapping<ProcessSomething2Response>(message => message.MessageId).ToSaga(data => data.MessageId);

        

        }


        public void Handle(StartSaga message)

        {

            Console.WriteLine("Received message StartSaga");

            Data.MessageId = message.MessageId;

           

            Bus.SendLocal(new ProcessSomething1()

            {

                MessageId = message.MessageId

            });

            Bus.SendLocal(new ProcessSomething2()

            {

                MessageId = message.MessageId

            });

            Console.WriteLine("StartSaga was successfuly processed.");

        }


        public void Handle(ProcessSomething1Response message)

        {

            Data.HasResponse1Arrived = true;

            Console.WriteLine("Received ProcessSomething1Response");

            if (Data.HasAllResponsesArrived())

            {

                Console.WriteLine("Saga is complete");

                MarkAsComplete();

            }

        }


        public void Handle(ProcessSomething2Response message)

        {

            Data.HasResponse2Arrived = true;

            Console.WriteLine("Received ProcessSomething2Response");

            if (Data.HasAllResponsesArrived())

            {

                Console.WriteLine("Saga is complete");

                MarkAsComplete();

            }

        }


        public void Handle(object message)

        {

            Console.WriteLine("Invoked SagaNotFound -- type: {0}", message.GetType());

        }

    }


*** SAGA DATA ***

  public class TestSagaData : ContainSagaData

    {

        [Unique]

        public Guid MessageId { get; set; }

    

        internal bool HasAllResponsesArrived()

        {

            if (HasResponse1Arrived && HasResponse2Arrived) return true;

            return false;

        }


        public bool HasResponse1Arrived { get; set; }


        public bool HasResponse2Arrived { get; set; }

    }

dirk.mcs...@gmail.com

unread,
Oct 23, 2014, 5:24:01 AM10/23/14
to particula...@googlegroups.com
Hi,

When I upgraded to NServicebus 4.7.0, the warning log message became an info log message instead...
To unsubscribe from this group and stop receiving emails from it, send an email to particularsoftware+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Particular Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to particularsoftware+unsub...@googlegroups.com.
To post to this group, send email to particula...@googlegroups.com.
Visit this group at http://groups.google.com/group/particularsoftware.

dirk.mcs...@gmail.com

unread,
Oct 23, 2014, 5:28:45 AM10/23/14
to particula...@googlegroups.com
Hi Indu,

How does your handler code look like? It seems that I do something wrong when sending the response, i.e. in the code where ProcessSomethingResponse1 and ProcessSomethingResponse2 is sent on the bus.
I tried to implement IHandleSagaNotFoundHandler and when hitting the Handle method, the Data object is null in the saga. But I suppose it should be?

Best Regards,
Dirk

Andreas Öhlund

unread,
Oct 23, 2014, 7:12:53 AM10/23/14
to particula...@googlegroups.com
I tried to implement IHandleSagaNotFoundHandler and when hitting the Handle method, the Data object is null in the saga. But I suppose it should be?

Yes its null since there is no saga found.

This is a bad api from our end and we're working on making it more intuitive:


Cheers,

Andreas

--
You received this message because you are subscribed to the Google Groups "Particular Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to particularsoftw...@googlegroups.com.

To post to this group, send email to particula...@googlegroups.com.
Visit this group at http://groups.google.com/group/particularsoftware.

indu.alagarsamy

unread,
Oct 23, 2014, 2:49:20 PM10/23/14
to particula...@googlegroups.com
Hi Dirk,

Here's the sample i used for my test.

If you can refit it to cause the issue or point me where i am doing something different than your scenario, that'd be awesome.

Cheers,
Indu Alagarsamy

On Wednesday, October 22, 2014 2:30:05 AM UTC-7, dirk.mcs...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages