NService.Router
community package and should be considered for multi-transport operations.The Router is not limited to only two interfaces. If 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");
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, before Version 4, the SQL Server transport supported the multi-instance mode. In this mode, a single NServiceBus endpoint could send messages to queues hosted in SQL Server instances different than the one that hosts that endpoint's 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.