Multiple MQTT Brokers

Hi All,

Hopefully this is a quick one. Is there a way to configure multiple MQTT brokers.

Basically so I can publish some commands out of Openhab on to localhost (internal) and some on to another IP address on my LAN so they can be read by another device.

And in reverse, subscribing to readings from local host and another IP address although I think this is simpler as the remote device can just publish on to the IP address of the device running Openhab and the messages will get mixed in with the messages from the local host? Is that correct?


Yes, you can use several different MQTT brokers if you give them different names in the openhab.cfg.

For example if you configure two brokers mqtt:localhost.url=tcp://localhost:1883 and mqtt:otherbroker.url=tcp:// you can then link your items (in- and outbound) to them by using the broker name (in this case localhost or otherbroker) the binding configuration { mqtt="<[localhost:/test/topic:state:default]" }

You can publish to several brokers simultaneously and you can also subscribe to different topics on different brokers (I am not sure what happens in this case, but I could imagine the last received message will be written to the item).