Search code examples
rabbitmqmqttrabbitmq-exchange

Purging retained MQTT last will messages from RabbitMQ?


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?


Solution

  • 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