Closed shakai2 closed 5 months ago
No, you can not manipulate RabbitMQ queues using this (or any MQTT) library.
If you want to specify a particular queue, you need to connect to RabbitMQ using an AMQP connection (using an AMQP library, of course, not MQTT).
If you attach to the MQTT plugin using an MQTT connection, you are limited to the capabilities of the MQTT protocol, and the subset of it that is supported by RabbitMQ... remembering that Rabbit is not 100% MQTT compliant. But it is often good enough for many use cases.
With MQTT you can not have a broker store messages before your first connection. But when you do connect for the first time, you can tell it to form a persistent session (clean start or clean session set to false in the CONNECT message), and then subscribe to the message topics that you want. After that, the broker will remember your messages even if you disconnect and re-connect.
The RabbitMQ plugin does that by creating one or more queues for your client's subscriptions. I don't remember the details, but I do know it's been changing recently with the latest 3.12 and 3.13 versions to make the plugin more efficient and support MQTT v5.
Check the documentation for the version you're using.
Thank you very much for the explanation.
Hi I am using rabbitmq as a broker.
The mqtt plugin is installed and configured, my producers send messages and they go to the queue as expected.
I'm testing an environment where producers send messages to the broker where there is no consumer connected yet.
When I connect the consumer and call
client.subscribe("topic");
it creates a new queue in the broker, even though I configure the same 'topic' that the producer is using.I expected the consumer consume queue messages.
Is creating a new queue the expected behavior ? Or am I missing something ?
Is it possible to consume an existing queue?