0

This is not a problem, but a question for me to understand the "magic" that happens in NserviceBus

I have a working environment where a NServiceBus-Service is called that way:

"D:\Service\NServiceBus.Host.exe" -service  /serviceName:"MyServiceAdapter" /endpointName:"MyQueue.Adapter"

Now inside the same directory there is my application "My.Adapter.dll" which also has a config. There is NO NserviceBus.config anywhere. Still: The NserviceBus seems to know that it has to use "My.Adapter.dll"

Why does NServiceBus know that? I did not find any reference in the Queue (MSMQ) or anywhere else to my application. Is it saved in the registry? If yes: Where?

Tom
  • 7,640
  • 1
  • 23
  • 47
Ole Albers
  • 8,715
  • 10
  • 73
  • 166
  • NserviceBus really relies on convention more than anything and will scan for classes implementing certain interfaces. Do you have anything in own assemblies marked with an interface like `IConfigureThisEndpoint`, or one of the other NServiceBus interfaces? – Yannick Meeus Feb 17 '15 at 16:08
  • Yes. And it all already works. I just want to understand HOW/WHERE NServiceBus saves that information. – Ole Albers Feb 17 '15 at 16:13
  • 1
    As I understand it, on starting a `Bus`, it will scan through all assemblies that you've told it to, reflect over all objects and retrieve those implementing it's interfaces. It runs through those configuration classes, configures itself and keeps that information in memory for the duration of it's lifetime. For Pub/Sub type stuff, it can maintain a Subscription table within SQL, amongst other places, depending on your configuration. Unless I've missed something when working with it prior, there's no registry entries it maintains, by default. – Yannick Meeus Feb 17 '15 at 16:22

1 Answers1

5

By default NServiceBus scans all assemblies that are located in the same folder with NServiceBus.Host.exe and looks for its own markers (interfaces) like IWantCustomInitialization, IHandleMessage and so on. It either uses its default IoC container builder (Autofac) or the one that you supply.

You can also limit, which assemblies will be scanned by using Configure.With(assemblies) for V4 and configuration.AssembliesToScan(myListOfAssemblies) for V5.

More to read here http://docs.particular.net/nservicebus/assembly-scanning

Alexey Zimarev
  • 17,944
  • 2
  • 55
  • 83