我希望有人可以帮助我解决我的问题,因为我用疯狂搜索它并没有结果。
我正在尝试在NServicebus中实现一个传奇。 saga中的handle方法使用bus.Send()方法通过总线调用两个不同的处理程序(请参阅下面的代码)。然后,当每个处理程序完成其工作时,它以相同的方式发送回传给saga的通知消息。传奇检查其状态并在完成所有步骤后调用MarkAsComplete()。我在这个传奇中使用一个消息队列和端点进行所有通信。
在到达方法public void Handle(Notify1DataMessage message)和public void Handle(Notify2DataMessage message)之前,每个处理程序得到以下两个警告行:
警告:无法找到ID为[GUID]的Notify1Message消息类型的传奇。要调用SagaNotFoundHandlers。
警告:NServiceBus.Sagas.SagaPersistenceBehavior:找不到具有id [GUID]的消息类型namespace.Notify1Message的传奇。要调用SagaNotFoundHandlers。
我做错了什么?一切正常,它在传奇中找到了通知句柄方法,但为什么它在抱怨?
相关代码:
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; }
//...
}