Package 

Class MemoryPersistence

  • All Implemented Interfaces:
    org.eclipse.paho.client.mqttv3.MqttClientPersistence

    
    public class MemoryPersistence
     implements MqttClientPersistence
                        

    Persistence that uses memory In cases where reliability is not required across client or device restarts memory this memory peristence can be used. In cases where reliability is required like when clean session is set to false then a non-volatile form of persistence should be used.

    • Method Summary

      Modifier and Type Method Description
      void close() Close the persistent store that was previously opened.
      Enumeration keys() Returns an Enumeration over the keys in this persistent data store.
      MqttPersistable get(String key) Gets the specified data out of the persistent store.
      void open(String clientId, String serverURI) Initialise the persistent store.
      void put(String key, MqttPersistable persistable) Puts the specified data into the persistent store.
      void remove(String key) Remove the data for the specified key.
      void clear() Clears persistence, so that it no longer contains any persisted data.
      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

      • close

         void close()

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

      • keys

         Enumeration keys()

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

      • get

         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.
      • open

         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.
      • put

         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
      • remove

         void remove(String key)

        Remove the data for the specified key.

      • clear

         void clear()

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

      • containsKey

         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.