Open sprior opened 2 weeks ago
There is an ID field in the request topic. You can put whatever you want in there. The same ID will be returned in the response. You can use this to multiplex message. As well, there's not a real easy way to monitor zillions of request/response topics. You can change the config file to monitor a different request/response topic if you like and use multiple instances of DOODS.
@snowzach That's my whole point, DOODS2 could trivially subscribe to doods2/request_topic/+ as a single subscription and catch requests from every requestor, but the client could post that request with their process id (1234) and then subscribe to doods2/response_topic/1234. This completely removes the need for every requestor to subscribe to EVERY response sent to every requestor and then throw away every response that doesn't have their ID in the message. That client can keep using that process id and response subscription and only get responses meant for them for the life of the client process.
I've used this technique for servers I've written and it's far more efficient and very easy to implement. This also lightens the load on the MQTT message broker because it doesn't have to send response messages to MQTT clients that aren't the original requestor.
I'll look at it whenever I get a chance.. Happy to take a PR as well..
With the structure given in the readme: request_topic: doods2/request_topic response_topic: doods2/response_topic
This means multiple clients making requests would all get the responses on the same topic. I would recommend a simple enhancement: request_topic: doods2/request_topic/+ response_topic: doods2/response_topic/+
Where the last part of the path would be a unique client ID that the client makes up and the response message would have the same ID at the end. That way multiple clients can make up their own client ids and subscribe to them and then not get responses intended for other clients.