我的应用程序正在尝试从端点接收事件。
如果我显式订阅<>(),我会在发布端点看到订阅。如果我尝试通过配置约定来获得相同的结果,它会失败。
我错过了什么?
我的配置如下所示:
public Subscriber(int maxConcurrency)
{
var pingEventType = typeof(IMyEvent);
var pingHandlerType = typeof(MyEventHandler);
var busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("MyEndpointName");
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.EnableInstallers();
busConfiguration.UsePersistence<NHibernatePersistence>();
busConfiguration
.UseTransport<SqlServerTransport>()
.CallbackReceiverMaxConcurrency(maxConcurrency);
busConfiguration.AssembliesToScan(AllAssemblies
.Matching("NServiceBus")
.And("ServiceControl")
.And(pingHandlerType.AssemblyQualifiedName)
.And(pingEventType.AssemblyQualifiedName));
busConfiguration
.Conventions()
.DefiningEventsAs(x => x.Namespace != null && x.Namespace == pingEventType.Namespace);
var container = new ContainerBuilder().Build();
busConfiguration.UseContainer<AutofacBuilder>(customizations =>
{
customizations.ExistingLifetimeScope(container);
});
_startableBus = Bus.Create(busConfiguration);
// Uncommenting below line results in subscription on the publishing endpoint
//_startableBus.Subscribe(pingEventType);
}
最相关的文档和示例代码似乎没有提到我应该做的任何其他事情https://docs.particular.net/nservicebus/messaging/conventions?version=core_5