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 just in case:
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; }
//...
}