Getting Started

NServiceBus Router multi-way direct topology

NuGet Package: NServiceBus.Router (2.x)

This is a community-maintained project
Target Version: NServiceBus 7.x
Particular Software's NServiceBus.MessagingBridge package offers similar functionality to the NService.Router community package and should be considered for multi-transport operations.


The router is not limited to only two interfaces but, in case there are more than two interfaces, the routing protocol rules will be more complex and specific. The following snippet configures the built-in static routing protocol to forward messages to interfaces based on the prefix of the destination endpoint's name.

var routerConfig = new RouterConfiguration("MyRouter");

routerConfig.AddInterface<SqlTransport>("A", transportExtensions => {});
routerConfig.AddInterface<SqlTransport>("B", transportExtensions => {});
routerConfig.AddInterface<SqlTransport>("C", transportExtensions => {});

var staticRouting = routerConfig.UseStaticRoutingProtocol();
//Send all messages to endpoints which name starts with Sales via interface A
    destinationFilter: (iface, destination) => destination.Endpoint.StartsWith("Sales."),
    destinationFilterDescription: "To Sales", 
    gateway: null, 
    iface: "A");

    (iface, destination) => destination.Endpoint.StartsWith("Shipping."), 
    "To Shipping", null, "B");

    (iface, destination) => destination.Endpoint.StartsWith("Billing."),
    "To Billing", null, "C");
All three interfaces use the same transport type (SQL Server Transport) but may use different settings, e.g. different database instances. This way, each part of the system (Sales, Shipping and Billing) can be autonomous and own its database server yet they can still exchange messages in the same way as if they were connected to a single shared instance.

For more information about using the Router in multi-way direct topology with SQL Server transport, see the sample.

Case study: SQL Server multi-instance mode migration

In the past, prior to Version 4, the SQL Server transport supported the multi-instance mode. In this mode a single NServiceBus endpoint was able to send messages to queues hosted in SQL Server instances different than the one that hosts that endpoint's own input queue. Due to complex configuration requirements this mode of operation has been removed.

The Router in the multi-way topology can be used to forward messages between multiple SQL Server instances after upgrading to the version of SQL Server transport that no longer supports the multi-instance mode.


Last modified