NServiceBus "CreateBus ()" returns null

I am using NServiceBus 2.6.0.1504 on a 32 bit Windows Server.

The generated log file indicates that everything is connecting, but for some reason "CreateBus ()" returns null. Ignore my debug code :)

SetLoggingLibrary.Log4Net(log4net.Config.XmlConfigurator.Configure); var one = Configure.With(typeFinder.GetAssemblies()); var two = one.DefaultBuilder(); var three = two.MsmqSubscriptionStorage(); var four = three.XmlSerializer(); var five = four.MsmqTransport(); var six = five.IsTransactional(false); var seven = six.PurgeOnStartup(true); var eight = seven.UnicastBus(); var nine = eight.LoadMessageHandlers(); var ten = nine.ImpersonateSender(false); var eleven = ten.CreateBus(); if (eleven == null) throw new Exception("createbus"); var twelve = eleven.Start(); 

An exception is always thrown with a "createbus" message.

This works in my dev block with 64-bit Windows Server 2008 R2.

Here is my configuration for the web application.

  <MsmqSubscriptionStorageConfig Queue="MedXChangeSubcriptions" /> <MsmqTransportConfig InputQueue="MedXChangeForms" ErrorQueue="error" NumberOfWorkerThreads="1" MaxRetries="5" /> <UnicastBusConfig> <MessageEndpointMappings> <add Messages="MethodFactory.MedXChange.Library" Endpoint="MedXChangeWeb" /> </MessageEndpointMappings> </UnicastBusConfig> 

Any ideas? Any help would be greatly appreciated.

+4
source share
1 answer

NServiceBus will return null if the bus is already created . Therefore, determine someone is already creating a bus for you.

In my scenario, we were inconsistently defining endpoint configurations. In one process, we will implement IConfigureThisEndpoint , and then explicitly configure and instantiate the bus. In another process, we would inherit from AsA_Publisher , which implicitly creates a bus for you; and when it came time to explicitly define our bus configuration for this other process, we would throw a NullReferenceException on the free CreateBus method. Removing the AsA_Publisher inheritance resolved the issue.

Hope this helps!

0
source

Source: https://habr.com/ru/post/1393887/


All Articles