-
Bug
-
Resolution: Unresolved
-
Undefined
-
None
-
None
-
None
-
False
-
None
-
False
-
-
The "retain" implementation for MQTT messages is not ready for a clustered AMQ. The section 3.3.1.3 from this link ( http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718038 ) says this:
If the RETAIN flag is set to 1, in a PUBLISH Packet sent by a Client to a Server, the Server MUST store the Application Message and its QoS, so that it can be delivered to future subscribers whose subscriptions match its topic name
It works well when there is one broker in the cluster: all the producers connect to the broker and a new retained message sent into the topic will replace the latest one previously sent.
When there are more than one broker running, it depends on which broker the producers are connected to.
Example scenario with two clustered brokers:
- A producer A is connected to the broker-0 and sends a retained message into the topic mytopic
- The message is stored in the topic, and the broker will deliver it to any new subscriber that subscribes to the topic as long as it connects to broker-0.
- If another subscriber connects to broker-1 and subscribes to the same topic mytopic it won't receive any message: the retained message is not redistributed from broker-0.
- A producer B connects to the broker-1 and sends a retained message into the same topic name "mytopic".
- At that point, there are two different retained messages stored in the cluster: the one on the broker-0 is outdated because there is a newer one published and stored on the other broker. Any new subscriber connecting to the broker-0 receives the old message instead of the new one.
- New clients connecting to the broker-1 and subscribing to mytopic receive the most updated message (as they are connected to the broker with the latest retained message).