org.eclipse.paho.client.mqttv3
Interface MqttDeliveryToken


public interface MqttDeliveryToken

Provides a mechanism for tracking the delivery of messages. Calls to MqttTopic.publish(MqttMessage) return after the message has been sent, but do not wait for acknowledgements to be received. This allows the client to have multiple messages in-flight at one time. In order to track the delivery of a message, those methods return an instance of this class which can be used in one of two ways:


Method Summary
 MqttMessage getMessage()
          Returns the message associated with this token, or null if the message has already been successfully sent.
 boolean isComplete()
          Returns whether or not the delivery has finished.
 void waitForCompletion()
          Blocks the current thread until the message this is the token for completes delivery.
 void waitForCompletion(long timeout)
          Blocks the current thread until the message this is the token for completes delivery.
 

Method Detail

waitForCompletion

public void waitForCompletion()
                       throws MqttException,
                              MqttSecurityException
Blocks the current thread until the message this is the token for completes delivery.

Throws:
MqttException - if there was a problem completing delivery of the message.
MqttSecurityException

waitForCompletion

public void waitForCompletion(long timeout)
                       throws MqttException,
                              MqttSecurityException
Blocks the current thread until the message this is the token for completes delivery. This will only block for specified timeout period. If the delivery has not completed before the timeout occurs, this method will return - the isComplete() method can be used to determine if the delivery is complete, or if the wait has timed out.

Parameters:
timeout - the maximum amount of time to wait for, in milliseconds.
Throws:
MqttException - if there was a problem completing delivery of the message
MqttSecurityException

isComplete

public boolean isComplete()
Returns whether or not the delivery has finished. Note that a token will be marked as complete even if the delivery failed.


getMessage

public MqttMessage getMessage()
                       throws MqttException
Returns the message associated with this token, or null if the message has already been successfully sent.

Returns:
the message associated with this token
Throws:
MqttException - if there was a problem completing retrieving the message