Configuration API - rebus-org/Rebus GitHub Wiki
The configuration API is a fluent configurer, that revolves around a bunch of configurers and the assumption that you're backing your application with an IoC container. It basically goes like this:
Configure.With(myContainerAdapter)
.SomeAspect(s => s.ChooseSomeSetting())
.Start();
where myContainerAdapter
is an instance of something that implements IContainerAdapter
, the purpose of which is to adapt the registration API and a few behavioural aspects of IoC containers to match those required by Rebus. Adapters for Castle Windsor, StructureMap, Autofac, and other containers are available in appropriately named NuGet packages.
If you don't need an IoC container for your application, you can use BuiltinHandlerActivator
and then retrieve the resulting IBus
instance from it after completing the configuration (or just use the IBus
returned from the final call to Start()
).
If you're interested, please check out the page about container adapters.
In the example above, SomeAspect
and ChooseSomeSetting()
are just shown in order to exemplify the general pattern where a method is called to choose which aspected should be configured, and in the Action<TConfigurer>
you can then call stuff in order to configure some aspect of Rebus.
There's one special case to this: The first call to Configure.With(...)
will return a special configurer, that allows for logging to be configured. This is only possible on the first call, because logging should be properly set up before all the other configurers are run, thus allowing configurers to log things properly if they want.
What's the minimum needed configuration?
Short answer: Configure a handler activator/container adapter and a transport, and then you're good to go.
It should be noted though, that subscriptions, timeouts, and sagas will then be stored in-mem, which is probably not suitable for production usage.
Check out the different bus modes for information on some more configurations.
Implementing your own container adapter
If you're interested in implementing your own adapter, please take a look at one of the existing adapter implementations. Your adapter implementation should be able to pass a suite of tests currently residing in the Contracts/Activation
namespace of Rebus.Tests
. It's very simple, however, because Rebus itself does not rely on auto-wiring or lifestyle.