简体   繁体   中英

Web application not subscribing to NServiceBus events

We have an ASP.NET MVC application that currently sends commands to a NServiceBus (v3) service.

The service publishes events that we need to subscribe to within the web application so that we can display real time notifications to our users.

The bus is currently initialised as below within the web application:

private static IBus ConfigureBus()
{
    return NServiceBus.Configure.With()
        .DefaultBuilder()
        .XmlSerializer()
        .MsmqTransport()
            .IsTransactional(false)
            .PurgeOnStartup(true)
        .UnicastBus()
            .LoadMessageHandlers()
        .CreateBus()
        .Start(() => Configure.Instance.ForInstallationOn<Windows>().Install());
}

With the following configuration in web.config:

  <!-- NServiceBus -->
  <MessageForwardingInCaseOfFaultConfig ErrorQueue="error" />
  <UnicastBusConfig ForwardReceivedMessagesTo="audit">
    <MessageEndpointMappings>
      <add Assembly="Foo.DocumentService.Messages" Endpoint="Foo.DocumentService.Host" />
    </MessageEndpointMappings>
  </UnicastBusConfig>

However, the event handler I have created within the web application is not invoked, no queue is created for the web application and I don't see any subscription messages sent to the host.

Am I missing something?

After enabling logging I could see that NServiceBus was not actually getting initialised (which is why no queues were created).

The issue turned out to be how I had configured Ninject as the bus was being lazily initialised. A quick change to my bindings and everything worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM