IoC, containers and confusion NServiceBus

Hey guys here is my setup

  • Windsor Castle - My Container
  • NServiceBus itself uses its own container inside Spring by default
  • I am implementing PubSub configuration.

Well, if I have my Bus.Publish, which happens in my IWantToRunAtStartup class, then everything is fine. As a test, for example, in Run (), we can start the timer, and it will go into the service style loop.

However, if I want to abstract from NServiceBus from my application, and I have an application:

new CustomPulisherClass().Notify(ISomeMessage msg); 

In this situation, how to implement CustomPublisherClass.

My misunderstanding comes from the fact that NServiceBus is already running as a Service, it is already "running". How can I get the correct instance of a bus object?

amuses

Andy

+4
source share
1 answer

You must configure NServiceBus to use Windsor as an internal container:

http://sourceforge.net/apps/mediawiki/nservicebus/index.php?title=Additional_containers

If you do this, the correct IBus will be available in your Windsor instance.

+3
source

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


All Articles