NServiceBus Router multi-way bridge topology

Component: NServiceBus.Router
NuGet Package NServiceBus.Router (2.x)
This is a community maintained project
Target NServiceBus Version: 7.x

Multi-way

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
staticRouting.AddRoute(
    destinationFilter: (iface, destination) => destination.Endpoint.StartsWith("Sales."),
    destinationFilterDescription: "To Sales", 
    gateway: null, 
    iface: "A");

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

staticRouting.AddRoute(
    (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 bridge 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.

Samples


Last modified