Skip to content

Rebus configuration section

Mogens Heller Grabe edited this page Dec 16, 2015 · 8 revisions

If you include the Rebus.XmlConfig package, you can configure Rebus' endpoint mappings in XML.

This can make your application slightly more flexible because this important aspect of message routing does not require the application to be compiled again.

Do this at the top of your app.config/web.config:

<configSections>
  <section name="rebus" type="Rebus.XmlConfig.RebusConfigurationSection, Rebus.XmlConfig" />
</configSections>

and then, some place further down in the file:

<rebus>
  <endpoints>
    <add messages="AnotherService.Messages" endpoint="anotherService.input@yetAnotherMachine" />
  </endpoints>
</rebus>

which will declare that all messages from the AnotherService.Messages assembly are owned by the service with the input queue anotherService.input on the yetAnotherMachine machine.

Then, when the bus does a bus.Send or a bus.Subscribe with a message type from the AnotherService.Messages assembly, the message (or, when subscribing: the subscription request) will be routed to anotherService.input on host yetAnotherMachine.

Last thing to do is to tell Rebus to pick up the endpoint mappings from the configuration file - this is how you do it:

Configure.With(....)
    .Routing(t => t.TypeBased().AddEndpointMappingsFromAppConfig())
    .(...)
Clone this wiki locally