hivemq-mqtt-client
hivemq-mqtt-client copied to clipboard
Publish and wait for response message
Checklist
- [x ] I've searched the project's
issues. - [x ] I've searched the project's
discussions.
❓ Question
I am using Mqtt5AsyncClient, after publishing a message, is it possible to wait for a response message in publishWith statement?
For example, I am using the following codes:
client.publishWith()
.topic(DEVICE_UPDATE_TOPIC)
.payload(payload)
.responseTopic(APP_RESPONSE_TOPIC)
.qos(MqttQos.AT_LEAST_ONCE)
.send()
.whenComplete((publish, throwable) -> {
if (throwable != null)
mainActivity.updateDeviceInfoError();
}).;
Or I have to write some codes inside whenComplete and wait for response message or wait for timeout if no message is received?
📎 Additional context
Hi @eos1d3 - we have a full request/response example here. That should point out the right pattern to use - Let me know if this helps.
Hi @eos1d3 - since we haven't heard back I'll close out this issue but if anything remains, let us know. We'd be more than happy to help out!