-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration
You can configure exchanges by creating instances of the ExchangeConfig class with the appropriate arguments.
You can specify the default exchange by using the static factory method:
ExchangeConfig.Default
You can configure queues by creating instances of the QueueConfig class with the appropriate arguments.
The most simple configuration being a direct queue on the default exchange:
new QueueConfig("queueName");
But overloads are available for any possible configuration required.
It is recommended that you use an IoC container to register all required exchange and queue configurations. Then at start up resolve an instance of the TopologyBootstrapper and call Init().
This will ensure all necessary rabbit elements are in place when the application starts.
Example (with Autofac):
private static void RegisterTopologyConfiguration(ContainerBuilder builder)
{
var exchange = new ExchangeConfig("someExchange", "fanout");
builder
.Register(c => exchange)
.As<ExchangeConfig>();
builder
.Register(c => new QueueConfig("queueA"))
.As<QueueConfig>();
builder
.Register(c => new QueueConfig("queueB"))
.As<QueueConfig>();
builder
.RegisterType<TopologyBootstrapper>()
.AsSelf();
}
And in the start-up method resolve bootstrapper and call:
_topologyBootstrapper.Init();
Note: If using the WhiteRabbit.Autofac package the TopologyBootstrapper will be registered by default.