Reputation: 167
I'm trying to find information on how to send a response to a publisher. I want to use the MQTT protocol. Is there any way to do this? I need the publisher to send a message to Rabbit, consumer to receive it, process it and send the result of the work back to the publisher.
On the AMQP protocol, this is implemented using Remote procedure call (RPC)
Example to AMQP:
result = channel.queue_declare(queue='', exclusive=True)
callback_queue = result.method.queue
channel.basic_publish(exchange='',
routing_key='rpc_queue',
properties=pika.BasicProperties(
reply_to = callback_queue,
),
body=request)
Upvotes: 1
Views: 704
Reputation: 59628
There is no direct publisher -> subscriber or subscriber -> publisher communication in MQTT. Everything is published to a topic.
Starting at MQTTv5 there is the option to include details of a reply topic in a published message. This is an optional field.
This would mean that the publisher can set a topic it will listen for a response message on. This can be either a generic topic, or one that is specific to that particular initial message.
If you can set this field will depend on both clients and the broker supporting MQTTv5.
Upvotes: 1