Package 

Interface IMqttDeliveryToken


  • 
    public interface IMqttDeliveryToken
    
                        

    Provides a mechanism for tracking the delivery of a message.

    A subclass of IMqttToken that allows the delivery of a message to be tracked. Unlike instances of IMqttToken delivery tokens can be used across connection and client restarts. This enables the delivery of a messages to be tracked after failures. There are two approaches

    • A list of delivery tokens for in-flight messages can be obtained using getPendingDeliveryTokens. The waitForCompletion method can then be used to block until the delivery is complete.
    • A MqttCallback can be set on the client. Once a message has been delivered the deliveryComplete method will be called withe delivery token being passed as a parameter.

    An action is in progress until either:

    • isComplete() returns true or
    • getException() is not null. If a client shuts down before delivery is complete an exception is returned. As long as the Java Runtime is not stopped a delivery token is valid across a connection disconnect and reconnect. In the event the client is shut down the getPendingDeliveryTokens method can be used once the client is restarted to obtain a list of delivery tokens for inflight messages.
    • Method Summary

      Modifier and Type Method Description
      abstract MqttMessage getMessage() Returns the message associated with this token.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getMessage

         abstract MqttMessage getMessage()

        Returns the message associated with this token.

        Until the message has been delivered, the message being delivered willbe returned. Once the message has been delivered null will be returned.