MQTT with Horizontal Scaling

We would like to horizontally scale our Mendix Cloud over 2 Instances.  We are also using the MQTT  Connector.   We are getting duplicate messages because each instance is listening on the Broker.  Is it possible to have one instance listening and the other one not?
2 answers

To follow up, the solution for us was to subscribe using a shared subscription:




This initially didn’t work with the MQTT Connector because the topic coming in did not match but I modified the java slightly to do a contains instead of a match when it was trying to figure out which microflow to use for the topic.


This only works if your MQTT Broker supports Shared Subscriptions.


Hi Amy,


Interesting. I’m under the impression that the QoS 2 is taking care of that:

Use QoS 2 when …

  • It is critical to your application to receive all messages exactly once. This is often the case if a duplicate delivery can harm application users or subscribing clients. Be aware of the overhead and that the QoS 2 interaction takes more time to complete.


But I never tested it on a multi-node application. In that case, the node that replies,s first should get the Pubrec and the Pubcomp answers, the other not. 


Can you test changing it to QoS 2 (Exactly once) and tell me if it worked? IF not, you could implement something on top to duplicate … (but that is a lot of overhead).


Go Make IT.