我的事件处理程序不是自动订阅的。我正在使用NServiceBus-CI 3.0.2044。我对NServiceBus-CI 3.0.2027也有同样的问题。
<MsmqTransportConfig ErrorQueue="dwh.projectmanagement.documents.notifications.error" NumberOfWorkerThreads="1" MaxRetries="5" />
<UnicastBusConfig ForwardReceivedMessagesTo="dwh.admin.auditor">
<MessageEndpointMappings>
<add Messages="DWH.Login.EmployeeLoggedInToTIPS, DWH.Events" Endpoint="dwh.webeventpublisher" />
<add Messages="DWH.Login.BuyerLoggedIn, DWH.Events" Endpoint="dwh.webeventpublisher" />
<add Messages="DWH.ProjectManagement.Events" Endpoint="dwh.projectmanagement.commandhandlers" />
<add Messages="DWH.ProjectManagement.Documents.DocumentDistributor.Events" Endpoint="dwh.projectmanagement.documents.documentdistributor" />
</MessageEndpointMappings>
</UnicastBusConfig>
class EndpointConfig : IConfigureThisEndpoint, AsA_Server , IWantCustomInitialization
{
public void Init()
{
log4net.Config.XmlConfigurator.Configure();
var kernel = new StandardKernel();
Configure.With()
.NinjectBuilder(kernel)
.CustomJsonSerializer();
.MsmqTransport()
.IsTransactional(true)
.UnicastBus()
.LoadMessageHandlers()
.CreateBus()
.Start();
// Other DI bindings
}
}
DocumentVersionSignedByBuyer
位于DWH.ProjectManagement.Events
汇编中。
public class SalesConsultantNotification :
IHandleMessages<DocumentVersionSignedByBuyer>
{
public IBus Bus { get; set; }
private readonly ISalesQueries _salesQueries;
public SalesConsultantNotification(ISalesQueries salesQueries)
{
_salesQueries = salesQueries;
}
public void Handle(DocumentVersionSignedByBuyer message)
{
var salesConsultants = _salesQueries.GetSalesConsultants(message.SaleId);
foreach (var salesConsultant in salesConsultants)
{
var cmd = new NotifySalesConsultantBuyerSigned(salesConsultant, message);
Bus.Send(cmd);
}
}
}