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

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.

The RabbitMQ team monitors this mailing list and only sometimes answers questions on StackOverflow.
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.

Related

RabbitMQ - posting message via MQTT doesn't publish message in exchange

I have rabbitmq with mqtt plugin enabled.
I have created publisher and subscriber in python and both seems to work.
My problem is that this messages doesn't appear in queue that I set up.
In rabbitmq I have
set up queue lets say mqtt-messages.
binded this queue in amq.topic exchange with test as routing key.
Then I'm trying to publish message on topic test which should be routed to mqtt-messages
When I publish message via rabbitmq management, those messages are propagated to queue but when I do it via my python script those messages appear in mqtt topics but not in queue. Those messages does not even appear as unroutable. They just don't exist outside of mqtt topics.

How to create a topic exchange in Qpid JMS for ActiveMQ like RabbitMQ?

I've got a Java application that uses RabbitMQ. This application creates a TOPIC exchange and pushes messages to the TOPIC with its own routing key. From this way if I want the data from any application I create a queue binding with the exchange TOPIC and the routing key I want to.
I want to do the same thing by using a Java application with Qpid JMS as the client and ActiveMQ as the server. The information says it's possible, but I don't know how. I cannot found a specific example seems to RabbitMQ. I can create queues but I don't know how to create the exchange and the binding. What steps should I follow to achieve it?
You might consider using ActiveMQ Artemis instead of ActiveMQ 5.x as the address model of Artemis is much more similar to RabbitMQ's than 5.x's address model (which is more JMS-centric).
As far as JMS goes I think what you need is:
A topic. This is analogous to the "exchange" from RabbitMQ. Any message sent to a JMS topic is delivered to every subscriber. It's basic publish/subscribe semantics.
A topic subscriber with a selector. As noted in #1, every subscriber on a topic will get any message sent to that topic, but a JMS "selector" can be used to filter messages similar to the routing key in RabbitMQ.
An agreed-upon key for a message property. In order to create a viable selector for the topic subscriber the producer and the subscriber must agree upon the property key to filter on.
If each subscription is going to have lots of messages and those messages need to be shared among multiple subscribers/consumers (e.g. for load-balancing/distribution) then you will need to use a JMS "shared subscription." However, shared subscriptions are only part of JMS 2 and only ActiveMQ Artemis implements JMS 2. You can't use ActiveMQ 5.x with JMS shared subscriptions as it only supports JMS 1.1.
Both ActiveMQ 5.x and ActiveMQ Artemis create server-side resources (e.g. topics, queues, etc.) on-demand by default so all you need to do is write your JMS application.

Subscribe to MQTT messages from an AMQP client on RabbitMQ?

I run a RabbitMQ node with the MQTT/WebMQTT plugins enabled.
All MQTT plugin settings use the default configuration.
Various MQTT clients are sending messages to MQTT channels.
The MQTT channel names follow the format of devices/{device_id_here}/{special_name_here}
I wish to subscribe to all MQTT messages that would match devices/#/logs in MQTT. How can I accomplish this using an AMQP client on the same broker as the MQTT users?
I am using Bunny as my (Ruby) AMQP client.
You can not use the # wildcard in the middle of a MQTT topic subscription as it is capable of matching multiple levels.
The correct wildcard is + as this only matches a single level in the topic hierarchy. E.g.
device/+/logs

RabbitMQ Manual Retry

How can manual retry work in RabbitMQ after a message has been put onto dead letter queue?
Does RabbitMQ provide an user interface through which you can do this? I assume here that RabbitMQ console does not provide you this capability.
The Rabbit MQ management interface would let you do this crudely, you can go into the deadletter queue, 'get' the message then copy the content. Go to the queue you want to retry the message on and 'publish' it directly to that queue.
Alternatively, you can enable the shovel plugin which allows you to move messages from one queue to another. The RabbitMQ Management plugin directly contains instructions on how to do this.
You can write a consumer / producer using a number of various client libraries. For python a popular library is pika (https://pypi.python.org/pypi/pika).
The script can consume all the messages in a queue, then publish them to another queue.

MQTT in Producer /consumer context

we are using ActiveMQ for message Queuing with openwire transport.In this context there will be one producer and one consumer with a message listener registered. We heard about MQTT protocol and its support in activeMQ. But i saw examples only for Publisher/subscriber semantics , where subscriber need to call receive method explicitly to get the published message. Can I use mqtt with Producer/Consumer envirnment. Please give a sample..
The MQTT protocol is based a publish / subscribe based model, it has no queuing semantics built into the protocol. If you need Queue's then you need to stick to openwire clients or use a STOMP based client which supports both Topics and Queues.