Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Rabbitmq MQTT / Persistent queue

800 views
Skip to first unread message

Nicolas Crochet

unread,
Jan 26, 2023, 4:30:48 AM1/26/23
to rabbitmq-users
Hi,

I am new to RabbitMQ and I am not certain of which concepts are required for my use case between : durable, retained, dead-letter, quorum etc.

I am setting up an mqtt broker with rabbit_mqtt and I wish for my mqtt clients to quickly connect, publish and disconnect in qos 1, while on the other side an amqp consumer might still not be connected, but would retrieve the messages when connecting.

I am trying to see in the management UI if the queue and messages are persisted, but everytime my client disconnects the queue is lost even if I set "quorum" option.

Here is my Dockerfile for rabbitmq image reference : 
FROM rabbitmq:3.11-management
RUN rabbitmq-plugins enable --offline rabbitmq_auth_backend_http rabbitmq_mqtt
COPY rabbitmq.conf etc/rabbitmq/rabbitmq.conf

Here is rabbitmq configuration : 
loopback_users.guest = false

# standard tcp configuration
listeners.tcp.default = 5672

# admin management ui tool
management.listener.port = 15672

# mqtt configuration
mqtt.listeners.tcp.default = 1883
mqtt.allow_anonymous  = false
mqtt.vhost            = /
mqtt.exchange         = amq.topic
mqtt.durable_queue_type = quorum

# authentication configuration
auth_backends.1 = http
auth_backends.2 = internal
auth_http.http_method   = post
auth_http.user_path     = http://myserver:8080/user
auth_http.vhost_path    = http://myserver:8080/vhost
auth_http.resource_path = http://myserver:8080/resource
auth_http.topic_path    = http://myserver:8080/topic

#debugging
log.console = true
log.console.level = debug

I should add that I am using mosquitto_pub locally to test the broker and everything works fine in terms of authentication, connack and puback.

Thanks,


David Ansari

unread,
Jan 27, 2023, 4:11:39 AM1/27/23
to rabbitmq-users
If you wish to consume via AMQP 0.9.1, make sure that a queue exists that binds to the default (MQTT) topic exchange with routing key being the topic name your publishers are publishing with.

Example:
1. Create a queue Q1 (e.g. via your AMQP 0.9.1 client or via the Management UI).
2. Bind Q1 to the topic exchange called "amq.topic" (that exchange is already created by RabbitMQ) with routing key for example "mytopic".
3. Create an MQTT connection which publishes with QoS 1 to topic "mytopic".
4. Optionally, disconnect your MQTT publishing connection.
5. Depending on whether your AMQP 0.9.1 client is already connected or not, make sure it connects and consumes from queue Q1. The message should then arrive in your AMQP consuming app.

The important part here is that Q1 (not created by the MQTT plugin) must exist at the point in time your MQTT connection is publishing such that the message will be routed to Q1.
(Whether Q1 is a classic queue or quorum queue does not really matter for the purpose of this test. Of course, if you want high availability and message safety, use a quorum queue.)

Note that the setting you use in 
mqtt.durable_queue_type = quorum
only applies to queues being created for MQTT connections that connect with clean_session=false and subscribe to a topic. Every MQTT subscribing connection will have its own queue created by the RabbitMQ MQTT plugin.
But in your use case, you said you want to consume via AMQP. Hence, that setting does't apply to your use case.
Reply all
Reply to author
Forward
0 new messages