I have a scenario where an mqtt-client (java application) publishes message to the mqtt-broker using the below code.
mqttClient
.toAsync()
.publishWith()
.topic(“topic”)
.payload(“message”.getBytes(StandardCharsets.UTF_8))
.send()
.whenComplete((connAck, throwable) → {
LOGGER.info(“Debug: connAck=” + connAck);
});
-
Is this “whenComplete()” invoked when the message has reached the mqtt-broker? or just after publish method is invoked by the publisher-client? or broker has send the message to the subscriber-client? or after subscriber has received the message?
-
Can I consider this whenComplete() as an acknowledgement?
-
In case of successful ack → throwable is null
In case of failure ack → throwable is not null
In either case (success/failure ack), the publishing-client has to perform certain operation (application-level operation) on the message?
Problem:
a. In successful ack - how to uniquely identify acknowledgement corresponding to a message? (Suppose, the publisher-client has published 100 msgs, how the publisher-client will uniquely identify for which message the acknowledge has been received?)
b. In failure ack - the publishing-client is not getting the message, it is just getting a throwable object.