NServiceBus with RabbitMQ with Multiple Instances & Hosts running same software independently


(Brian Bak Laursen) #1

Hi everyone,

I’m looking for some expert help from you.

We’ve recently implemented NServiceBus using RabbitMQ which in general is all working fine.

A few words on our setup and challenges:

  1. In many of our development envrionments we are running many different instances of the same software. It is the same software but otherwise not connected and should publish/sub its own events.

  2. We cannot use Conventional Routing Topology because we would then share all events across the different instances (of the same software).

Our solution so far:
Queues are based on a unique prefix that defines that software instance. As example for two instances (soft1, soft2), would have the same queues, exchanges for both (soft1.queue, soft2.queue…).
We have made a Direct Routing Topology where we use the unique key + the type of the event. This creates an exhange per instance (soft1.exchange, soft2.exchange) where subscribers then bind to and get the events based on the type.

All this is working fine but now to our problem:
We want to be able to subscribe to interfaces (such as an IEvent) to all events of that type but because we publish the sub-classes and the routing key is based on this, then the subscribers never get those events if they are not also subscribing to subclasses.

Would you have a good suggestion on how to solve this? It is of course already solved by Conventional Routing Topology but then all events would we shared so we cant use that.

Could you prefix the conventional exchanges?

Looking forward to your feedback and assistance.

Best regards,

(Daniel Marbach) #2

Hi Brian,

Is there a reason that you don’t use vhosts to isolate those instances? With vhosts you could use Conventional Routing topology and the same software could run isolated inside a vhost


(Adam Ralph) #3

Seconding what @danielmarbach said, RabbitMQ Virtual Hosts are specifically designed to solve this problem.

(Brian Bak Laursen) #4

Hi Daniels,

Thanks a lot for your answer.

In all honesty I did not consider it and it makes perfect sense to use that option.

The reason I abandoned it in the first place was to avoid having to anything in the installer (creating the vhosts) but I guess it really is a very simple change with the CLI from rabbit that allows you to just use the add_vhost command.

Really do appreciate the quick reply even though it was relatively simple.

Sometimes you can’t see the forest for the trees :wink:

have a great day!