NServiceBus
NServiceBus copied to clipboard
Overriding existing message route
While moving from NSB 5 to NSB 7 we faced to issue with overriding existing message routes. In NSB 5 we were using configuration-based rouing and were able to route all messages from assembly to one endpoint and single message from assembly to another endpoint e.g.:
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="MessagesAssembly" Endpoint="endpoint" />
<add Messages="MessagesAssembly.SpecificMessage, MessagesAssembly" Endpoint="another-endpoint" />
</MessageEndpointMappings>
</UnicastBusConfig>
Now in NSB 7 we are trying to do the same with file-based routing:
<endpoints>
<endpoint name="endpoint">
<handles>
<commands assembly="MessagesAssembly" />
</handles>
</endpoint>
<endpoint name="another-endpoint">
<handles>
<command type="MessagesAssembly.SpecificMessage, MessagesAssembly" />
</handles>
</endpoint>
</endpoints>
but it throws an Exception:
Route for type MessagesAssembly.SpecificMessage already exists.
Before PR 4041 there was argument bool overrideExistingRoute in method RouteTo of class UnicastRoutingTable:
public void RouteTo(Type messageType, IUnicastRoute route, bool overrideExistingRoute)
but now it's just
public void AddOrReplaceRoutes(string sourceKey, IList<RouteTableEntry> entries)
Is there any alternative to bool overrideExistingRoute in current NSB version to override routes for specific messages? Thanks.
@mvoronin-eastwind: @timbussmann has taken over the File Based Routing as a community project. If you would like you can raise an issue about enabling file-based routing to provide the type of override you are seeking here: https://github.com/timbussmann/NServiceBus.FileBasedRouting
Otherwise, I would encourage you to switch to using our routing API which allows you to override routes: https://docs.particular.net/nservicebus/messaging/routing#command-routing.