RabbitMQ: MQTT subscriptions fail with 'precondition_failed: invalid property 'exclusive-owner'
search cancel

RabbitMQ: MQTT subscriptions fail with 'precondition_failed: invalid property 'exclusive-owner'

book

Article ID: 442241

calendar_today

Updated On:

Products

RabbitMQ VMware Tanzu RabbitMQ

Issue/Introduction

MQTT subscriptions fail with 'precondition_failed: invalid property 'exclusive-owner' during patching or a rolling restart.

 

Environment

All supported RabbitMQ versions.

Cause

When a RabbitMQ node undergoes a rolling restart or patching, MQTT clients utilizing persistent sessions lose their TCP connection. They immediately reconnect  to a different, healthy node in the cluster.

By default for Qo1 subscriptions, the MQTT plugin creates backing classic queues(mqtt-subscription-xxxxqos1) that are exclusive to the connection. When the client attempts to reconnect and re-declare its subscription queue on the new node, a property mismatch occurs regarding the exclusive-owner attribute. Because exclusive classic queues cannot be declared or transferred across different nodes in this manner, RabbitMQ rejects the operation with a PRECONDITION_FAILED error.

Resolution

Options to avoid the PRECONDITION_FAILED error are:

  • Switch to Clean Session=0
  • Use a non-zero session expiry(available in MQTT 5) 
  • If you cannot switch to Clean Session =0 or use a non-zero session expiry(available in MQTT 5) the option is to switch to quorum queues..
    • Steps to  migrate to Quorum queues are:
        • All existing exclusive queues must be deleted before and/or after all nodes are configured to use mqtt.durable_queue_type = quorum and restarted. See more info on configuring quorum queues for MQTT here.
        • For bulk deletion of queues using a pattern a new command has been introduced. You will have to download the new tool and pick the binary for your environment.

        • See example below. 

          rabbitmqadmin --username "your_admin_user" --password "your_password" --vhost "/" queues delete_multiple --name-pattern "^mqtt-subscription-.*" --approve
    •