SzymonPobiega / NServiceBus.Router

Cross-transport, cross-site and possibly cross-cloud router component for NServiceBus
MIT License
5 stars 10 forks source link

An endpoint cannot use multiple routers #27

Closed robj-applied closed 3 years ago

robj-applied commented 4 years ago

Hi, apologies if I've misunderstood something here, but given the following code:

var transport = configuration.UseTransport<MsmqTransport>();
var routing = transport.Routing();

var router1 = routing.ConnectToRouter(Router1Name);
var router2 = routing.ConnectToRouter(Router2Name);

router1.RouteToEndpoint(typeof(Command1), Service1Name);
router2.RouteToEndpoint(typeof(Command2), Service2Name);

Only router2's routes would be registered in the endpoint. Anything that I think I've set up for router1 would result in a No destination specified... message.

Presumably this is because this line var router2 = routing.ConnectToRouter(Router2Name); overwrites this line var router1 = routing.ConnectToRouter(Router1Name);?

If I'm correct, just wondering is this by design or is it a bug?

In our useage of NServiceBus.Router we've come across a few occassions where we've had to roll our own solution for achieving this and it'd be great if it could be changed.

Thanks in advance for taking a look. If I'm wrong or have misunderstood, then great - just let me know.

Thanks, Rob

SzymonPobiega commented 4 years ago

@robj-applied I would say that this is a poor design choice on my side. I used some tried to mimic some NServiceBus APIs in this behavior but I didn't take into account that for the router, it actually makes sense to connect to more than one.

I'll include support for this in the next release.

robj-applied commented 4 years ago

@SzymonPobiega That's great news, thank you.

seantarogers commented 4 years ago

Hi @SzymonPobiega when is V4 due to be released? This feature would be very useful. Thanks

SzymonPobiega commented 3 years ago

Hi. Sorry to be late with this one but this feature has been shipped in 3.9.0

robj-applied commented 3 years ago

@SzymonPobiega Great, thanks Szymon.