-
Notifications
You must be signed in to change notification settings - Fork 10
Route Table
The messages with send, subscribe and unsubscribe intent are routed using a RouteTable. The route table is a collection of rules that are evaluated in the context of a given incoming message and, if matched, describe the action to be taken with that message. Each RouteTable entry consists of:
- destination filter
- outgoing interface
- designated gateway
The destination filter takes the incoming interface and the destination endpoint/site name extracted from the incoming message and returns bool if that destination matches a given entry.
If the entry matches the destination then the outgoing interface and designated gateway are used to route the message.
Sometimes the message cannot be routed directly to the destination endpoint -- it has to go through another router. In these cases the route table entry contains the designated gateway property pointing to the next router. The message is routed to that router with the NServiceBus.Bridge.DestinationEndpoint header containing the ultimate destination endpoint.
The main API of the RouteTable is the AddRoute method
public void AddRoute(
Func<string, Destination, bool> destinationFilter,
string destinationFilterDescription,
string gateway,
string iface)
It adds a new entry with given properties. An additional parameter destinationFilterDescription is used for diagnostic purposes. Is is meant to provide a human-readable description of the entry.
A simpler convenience method AddForwardRoute is also available
public static void AddForwardRoute(
this RouteTable routeTable,
string incomingInterface,
string outgoingInterface,
string gateway = null)
It creates a forward table rule between two interfaces. Because there is no destination filter, this method is only useful when the forwarding between interfaces is defined statically and does not depend on the message content or headers.