5

I am currently exploring the possibility of using MQTT protocol in my program and the system has found out that there are several different MQTT Brokers. So, my question is that can you mix and match brokers for this communication? For instance, Mosquitto broker on device 1 and ActiveMQ Broker on device 2. Will this work?

Abdul Alim Shakir
  • 1,128
  • 13
  • 26
ThN
  • 3,235
  • 3
  • 57
  • 115

2 Answers2

5

I think there might be a slight misunderstanding here.

In a simple deployment there would only be 1 MQTT broker that multiple MQTT clients (on one or many devices) would connect to this one broker and exchange messages on any topics. As long as all the client conforms to the MQTT specifications then they should be able to connect successfully to any broker implementation.

If you want a more complex deployment then it is possible to have multiple brokers and have groups of clients connect to different brokers. You can then set up what is known as a bridge between the brokers which allow the to share some/all of the topics. This allows messages to be shared by all clients regardless of which broker they connect to.

Assuming all the brokers conform to the MQTT spec (which is very likely) then it all should just work, but how you configure bridges differs between broker implementation.

Be aware that a new version of the MQTT spec (v5) just went live (end of 2017), brokers and client libraries will be updating to support this over the coming weeks/months. So check what versions you try and connect with.

hardillb
  • 54,545
  • 11
  • 67
  • 105
  • hardillb - what I meant to ask was "can different clients communicate with different brokers like Mosquitto broker to ActiveMQ clients? Your answer still cleared a lot of my doubts. – ThN Jan 16 '18 at 20:05
  • I've updated answer, but yes any client should connect to any broker (with matching spec versions, and probably backward compatible) – hardillb Jan 16 '18 at 20:11
3

Usually there's a bridge mode to connect brokers together, even for different kind of brokers such as Mosquitto and ActiveMQ, this is not only a concept in MQTT brokers but also in other message queue. Also, some kinds of brokers support with clustered, such as RabbitMQ. Official Mosquitto only support bridge, but there's a clustered mosquitto implementation on hui6075/mosquitto-cluster, it is easy to deploy. Besides, the most significant different with "cluster" and "bridge" is that with clustered, the whole brokers looks like one logic broker for external clients, such as session, retain, qos, etc.

jianhui
  • 133
  • 6