Hi, I am using Paho for Java 1.0.2. My application subscribes events from devices and send back reply as device commands. So I want to use MqttClient instance in callback MqttCallback.messageArrived(String topic, MqttMessage message).
1) This method is invoked synchronously by the MQTT client. An acknowledgment is not sent back to the server until this method returns cleanly.
2) It is possible to send a new message within an implementation of this callback (for example, a response to this message), but the implementation must not disconnect the client, as it will be impossible to send an acknowledgment for the message being processed, and a deadlock will occur.
So, yes, you should be able to call publish() within the callback. The resulting message will be sent before any acknowledgement to the incoming message.