Package 

Interface MqttClientPersistence


  • 
    public interface MqttClientPersistence
    
                        

    Represents a persistent data store, used to store outbound and inbound messages while they are in flight, enabling delivery to the QoS specified. You can specify an implementation of this interface using MqttClient, which the MqttClient will use to persist QoS 1 and 2 messages.

    If the methods defined throw the MqttPersistenceException then the state of the data persisted should remain as prior to the method being called. For example, if put throws an exception at any point then the data will be assumed to not be in the persistent store. Similarly if remove throws an exception then the data will be assumed to still be held in the persistent store.

    It is up to the persistence interface to log any exceptions or error information which may be required when diagnosing a persistence failure.

    • Method Summary

      Modifier and Type Method Description
      abstract void open(String clientId, String serverURI) Initialise the persistent store.
      abstract void close() Close the persistent store that was previously opened.
      abstract void put(String key, MqttPersistable persistable) Puts the specified data into the persistent store.
      abstract MqttPersistable get(String key) Gets the specified data out of the persistent store.
      abstract void remove(String key) Remove the data for the specified key.
      abstract Enumeration keys() Returns an Enumeration over the keys in this persistent data store.
      abstract void clear() Clears persistence, so that it no longer contains any persisted data.
      abstract boolean containsKey(String key) Returns whether or not data is persisted using the specified key.
      • Methods inherited from class java.lang.Object

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

      • open

         abstract void open(String clientId, String serverURI)

        Initialise the persistent store. If a persistent store exists for this client ID then open it, otherwise create a new one. If the persistent store is already open then just return. An application may use the same client ID to connect to many different servers, so the client ID in conjunction with the connection will uniquely identify the persistence store required.

        Parameters:
        clientId - The client for which the persistent store should be opened.
        serverURI - The connection string as specified when the MQTT client instance was created.
      • close

         abstract void close()

        Close the persistent store that was previously opened. This will be called when a client application disconnects from the broker.

      • put

         abstract void put(String key, MqttPersistable persistable)

        Puts the specified data into the persistent store.

        Parameters:
        key - the key for the data, which will be used later to retrieve it.
        persistable - the data to persist
      • get

         abstract MqttPersistable get(String key)

        Gets the specified data out of the persistent store.

        Parameters:
        key - the key for the data, which was used when originally saving it.
      • remove

         abstract void remove(String key)

        Remove the data for the specified key.

      • keys

         abstract Enumeration keys()

        Returns an Enumeration over the keys in this persistent data store.

      • clear

         abstract void clear()

        Clears persistence, so that it no longer contains any persisted data.

      • containsKey

         abstract boolean containsKey(String key)

        Returns whether or not data is persisted using the specified key.

        Parameters:
        key - the key for data, which was used when originally saving it.