0

In the Single Call Multiple Answer Pattern you can send a request and recieve more than one response to this request. A mqtt client can send a request with a response topic and some correlation data. can one client answer to this request with more than one response (every response include the correlation data of the first and only request), or is this a protocol error?

1 Answers1

1

MQTT is a Publish/Subscribe protocol, very much different from requenst/response protocols like HTTP.

The broker is the middle-man for all clients. It distributes published messages to all clients that are subscribed to its topic.

So what you can do is have client "Master" send to topic "REQUEST/" and have all your slave programs be subscribed to that topic. If they receive a message, the can publish their response to "RESPONSE/" which the master is subscribed to. The master will invoke its on_message callback for each message that arrives on topics it has previously subscribed to.

See the github of the implementation of your choice for examples. Here is the eclipse-paho-python-github.

EDIT:

For MQTT5 the response-topic-property was added. Here a publisher/requester can instead pass information on where to publish the response instead of encoding it in the payload, which was the way to do it now. It doesn't really change the workflow though, it appears. Instead of the responders hard-coding their topic or reading it form the payload they can extract it as part of the message object they receive.

jaaq
  • 1,188
  • 11
  • 29
  • 1
    in MQTT 5 you can use the Request/Response Pattern. You can send a Request with a Response-Topic and some Correlation Data. The Reciever sends a Response on the Response-Topic and adds Correaltion Data to the message. This is possible in MQTT 5. My answer is if you can send more than one response with this correlation data –  Jul 24 '19 at 10:51
  • oh, I didn't know mqtt5 had any good implementations yet. Can you link any? I updated my answer. – jaaq Jul 24 '19 at 11:17