Skip to content

ExchangeTypes

derekgreer edited this page Jun 1, 2012 · 2 revisions

RabbitBus uses a default exchange type of "direct". To specify the direct exchange type explicitly or to change to one of the other supported exchange types, you need to use an overload of the WithExchange() method. The following configures RabbitBus to publish messages to a direct exchange type named "status-update-exchange" explicitly:

Bus bus = new BusBuilder()
  .Configure(ctx => ctx.Publish<StatusUpdate>()
                         .WithExchange("status-update-exchange", cfg => cfg.Direct()))
  .Build();

The following example demonstrates how to configure the "status-update-exchange" as a topic exchange:

Bus bus = new BusBuilder()
  .Configure(ctx => ctx.Publish<StatusUpdate>()
                         .WithExchange("status-update-exchange", cfg => cfg.Topic()))
  .Build();

The following example demonstrates how to configure the "status-update-exchange" as a fanout exchange:

Bus bus = new BusBuilder()
  .Configure(ctx => ctx.Publish<StatusUpdate>()
                         .WithExchange("status-update-exchange", cfg => cfg.Fanout()))
  .Build();

The following example demonstrates how to configure the "status-update-exchange" as a headers exchange:

Bus bus = new BusBuilder()
  .Configure(ctx => ctx.Publish<StatusUpdate>()
                         .WithExchange("status-update-exchange", cfg => cfg.Headers()))
  .Build();
Clone this wiki locally