rabbitmqpahopikapython-pika

Publish/Subscribe MQTT message over RabbitMQ using pika (python client)


I have existing RabittMQ server set-up and we enabled MQTT plug-in to publish/subscribe mqtt messages. We have pika client to process the existing queue messages . Right now , we want to use the same pika on_message() handler to process the mqtt message. I am able to publish and subscribe mqtt message over eclipse paho client . We want to use the existing RabittMQ client(pika). MQTT plug-in by default publish to amq.topic exchange . I want to publish the same message to my own exchange. Please let me know , how to get this.


Solution

  • If you want a consumer using the Pika library to receive MQTT messages that consumer must subscribe to the appropriate queue to which the MQTT messages are being published. Comprehensive documentation of how MQTT and AMQP can interoperate is available here.

    You then say "I want to publish the same message to my own exchange". If you wish to use your own exchange instead of amq.topic, please see the "Custom Exchanges" section of this document. You must specify the name of the exchange in the rabbitmq.config file and create the exchange prior to publishing any messages. Note that this custom exchange must be a topic exchange.

    The RabbitMQ documentation is a good resource and I suggest searching there when you have questions.