我下面的传奇没有处理 ValidateRegistration 和 ValidateRegistration 命令。我看到“找不到消息类型 Registrations.Messages.ValidateRegistration with id ...的传奇”消息。
我查找 saga 的配置不正确吗?请帮忙!
谢谢
PS:我在注册过程中使用的是通用主机,并且我使用的是 NServiceBus.Lite 配置文件。
public class EndpointConfig : IConfigureThisEndpoint, AsA_Publisher, IWantCustomInitialization
{
#region Implementation of IWantCustomInitialization
public void Init()
{
var kernel = new StandardKernel();
kernel.Load(new BackendModule());
//Configure.Instance.Configurer.ConfigureProperty<RegistrationSaga>(x => x.Factory, kernel.Get<IAggregateRootFactory>());
Configure.With().NinjectBuilder(kernel);
}
#endregion
}
public class RegistrationSagaData : IContainSagaData
{
#region Implementation of ISagaEntity
public virtual Guid Id { get; set; }
public virtual string Originator { get; set; }
public virtual string OriginalMessageId { get; set; }
public virtual RegistrationID RegistrationID { get; set; }
public virtual bool IsValidated { get; set; }
public virtual string RegistrationType { get; set; }
#endregion
}
public class RegistrationSaga : Saga<RegistrationSagaData>,
IAmStartedByMessages<StartRegistration>,
IHandleMessages<ValidateRegistration>,
IHandleMessages<CancelRegistration>
{
public RegistrationFactory Factory { get; set; }
public override void ConfigureHowToFindSaga()
{
ConfigureMapping<StartRegistration>(data => data.RegistrationID, registration => registration.ID);
ConfigureMapping<ValidateRegistration>(data => data.RegistrationID, registration => registration.ID);
ConfigureMapping<CancelRegistration>(data => data.RegistrationID, registration => registration.ID);
}
#region Implementation of IMessageHandler<StartRegistration>
public void Handle(StartRegistration message)
{
Data.IsValidated = false;
Data.RegistrationType = message.RegistrationType;
Bus.SendLocal(new CreateRegistration
{
RegistrationType = message.RegistrationType,
ID = message.ID
});
Console.WriteLine("======> handled StartRegistration");
}
#endregion
#region Implementation of IMessageHandler<ValidateRegistration>
public void Handle(ValidateRegistration message)
{
MarkAsComplete();
Console.WriteLine("======> handled ValidateRegistration");
}
#endregion
#region Implementation of IMessageHandler<CancelRegistration>
public void Handle(CancelRegistration message)
{
Console.WriteLine("======> handled CancelRegistration");
MarkAsComplete();
}
#endregion
}