1
votes

I manage a RabbitMQ broker with MQTT and WebSocket MQTT enabled. While testing the servers, we unintentionally marked a client's last will and testament as retain = true. This had unintended consequences, such as always receiving the LWT message when a client would connect to the LWT topic. This also created downstream problems in the application.

No queued messages showed in the management console, even though they would appear when connecting via MQTT. After some time, the LWT messages cleared out and things went back to normal. I am still unable to identify and manually clear out retained MQTT messages from the broker when this occurs.

How can I see and purge all retained MQTT messages (and LWT messages) in RabbitMQ?

2

2 Answers

3
votes

You should be able to clear an individual retained message from a topic by publishing a message with a null payload and the retained bit set to true to the same topic.

As for clearing all retained topics I'm not sure with rabbitmq, with mosquitto the easiest way is to stop the broker and delete the persistence db (this also wipes out any queued messages and persistent subscriptions)

1
votes

The purge method depends on the retained message store that you decide to use.

In my case, I decided to disable storage of retained messages altogether via the noop store:

Disable retained MQTT messages in Rabbit MQ