public interface MqttClientPersistence
MqttClient.MqttClient(String, String, MqttClientPersistence)
,
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(String, MqttPersistable)
throws an exception at any point then the data will be assumed to not be in the persistent store.
Similarly if remove(String)
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.
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears persistence, so that it no longer contains any persisted data.
|
void |
close()
Close the persistent store that was previously opened.
|
boolean |
containsKey(java.lang.String key)
Returns whether or not data is persisted using the specified key.
|
MqttPersistable |
get(java.lang.String key)
Gets the specified data out of the persistent store.
|
java.util.Enumeration |
keys()
Returns an Enumeration over the keys in this persistent data store.
|
void |
open(java.lang.String clientId,
java.lang.String serverURI)
Initialise the persistent store.
|
void |
put(java.lang.String key,
MqttPersistable persistable)
Puts the specified data into the persistent store.
|
void |
remove(java.lang.String key)
Remove the data for the specified key.
|
void open(java.lang.String clientId, java.lang.String serverURI) throws MqttPersistenceException
clientId
- The client for which the persistent store should be opened.serverURI
- The connection string as specified when the MQTT client instance was created.MqttPersistenceException
- if there was a problem opening the persistent store.void close() throws MqttPersistenceException
MqttPersistenceException
void put(java.lang.String key, MqttPersistable persistable) throws MqttPersistenceException
key
- the key for the data, which will be used later to retrieve it.persistable
- the data to persistMqttPersistenceException
- if there was a problem putting the data
into the persistent store.MqttPersistable get(java.lang.String key) throws MqttPersistenceException
key
- the key for the data, which was used when originally saving it.MqttPersistenceException
- if there was a problem getting the data
from the persistent store.void remove(java.lang.String key) throws MqttPersistenceException
MqttPersistenceException
java.util.Enumeration keys() throws MqttPersistenceException
String
objects.MqttPersistenceException
void clear() throws MqttPersistenceException
MqttPersistenceException
boolean containsKey(java.lang.String key) throws MqttPersistenceException
key
- the key for data, which was used when originally saving it.MqttPersistenceException