com.eurotech.framework.core.data
Interface DataStore

All Known Implementing Classes:
DbDataStore

public interface DataStore

DataStore implementation have the responsibility of doing the bookkeeping of the messages that are in transient in the system. A message in the system normally flows through the following states: stored -> published -> confirmed (or dropped). The data store should be able to store messages, track and update their state, and perform certain queries for messages in a given state.


Method Summary
 List<DataMessage> allDroppedInFlightMessagesNoPayload()
          Finds the list of all published messages that will not be confirmed and returns them WITHOUT loading the payload.
 List<DataMessage> allInFlightMessagesNoPayload()
          Finds the list of all published but not yet confirmed messages and returns them WITHOUT loading the payload.
 List<DataMessage> allUnpublishedMessagesNoPayload()
          Finds the list of all unpublished messages and returns them WITHOUT loading the payload.
 void checkpoint()
          Performs a checkpoint of the store.
 void confirmed(int msgId)
          Acknowledges the delivery of the DataMessage published with the given protocol (e.g.
 void defrag()
          Defragments the store.
 void deleteStaleMessages(int purgeAge)
          Deletes stale messages.
 void dropAllInFlightMessages()
          Drops all in-flight messages.
 DataMessage get(int msgId)
          Returns a message from the DataStore by its message id.
 DataMessage getNextMessage()
          Gets the next unpublished message.
 void published(int msgId)
          Acknowledges the publication of the DataMessage with the given ID.
 void published(int msgId, int publishedMsgId, String sessionId)
          Acknowledges the publication of the DataMessage with the given ID associating it to the protocol (e.g.
 void start(DbService dbService, int houseKeeperInterval, int purgeAge, int capacity)
           
 void stop()
           
 DataMessage store(String topic, byte[] payload, int qos, boolean retain, int priority)
          Stores an MQTT message for deferred publication.
 void unpublishAllInFlighMessages()
          Marks all in-flight messages as unpublished.
 void update(int houseKeeperInterval, int purgeAge, int capacity)
           
 

Method Detail

start

void start(DbService dbService,
           int houseKeeperInterval,
           int purgeAge,
           int capacity)
           throws EsfStoreException
Throws:
EsfStoreException

update

void update(int houseKeeperInterval,
            int purgeAge,
            int capacity)

stop

void stop()

store

DataMessage store(String topic,
                  byte[] payload,
                  int qos,
                  boolean retain,
                  int priority)
                  throws EsfStoreException
Stores an MQTT message for deferred publication. An identifier is always generated and returned, even for messages published with QoS = 0. The store policy is FIFO within each priority level, 0 being the highest priority.

Parameters:
topic -
payload -
qos -
retain -
priority -
Returns:
Throws:
EsfStoreException

published

void published(int msgId,
               int publishedMsgId,
               String sessionId)
               throws EsfStoreException
Acknowledges the publication of the DataMessage with the given ID associating it to the protocol (e.g. MQTT) message ID (QoS > 0).

Parameters:
msgId -
publishedMsgId -
sessionId - TODO
Throws:
EsfStoreException

published

void published(int msgId)
               throws EsfStoreException
Acknowledges the publication of the DataMessage with the given ID. This is typically called for messages published with QoS = 0.

Parameters:
msgId -
publishedMsgId -
Throws:
EsfStoreException

confirmed

void confirmed(int msgId)
               throws EsfStoreException
Acknowledges the delivery of the DataMessage published with the given protocol (e.g. MQTT) message ID. This method is only called for messages published with QoS > 0.

Parameters:
msgId -
Throws:
EsfStoreException

getNextMessage

DataMessage getNextMessage()
                           throws EsfStoreException
Gets the next unpublished message. Messages with higher priority (0 is the highest priority) are returned first. Within each priority level the oldest unpublished message is returned first.

Returns:
Throws:
EsfStoreException

get

DataMessage get(int msgId)
                throws EsfStoreException
Returns a message from the DataStore by its message id.

Parameters:
msgId - ID of the message to be loaded
Returns:
Loaded message or null if not found.
Throws:
EsfStoreException

allUnpublishedMessagesNoPayload

List<DataMessage> allUnpublishedMessagesNoPayload()
                                                  throws EsfStoreException
Finds the list of all unpublished messages and returns them WITHOUT loading the payload.

Returns:
Throws:
EsfStoreException

allInFlightMessagesNoPayload

List<DataMessage> allInFlightMessagesNoPayload()
                                               throws EsfStoreException
Finds the list of all published but not yet confirmed messages and returns them WITHOUT loading the payload. These are only messages published with QoS > 0. Messages published with QoS = 0 do not belong to the results list.

Returns:
Throws:
EsfStoreException

allDroppedInFlightMessagesNoPayload

List<DataMessage> allDroppedInFlightMessagesNoPayload()
                                                      throws EsfStoreException
Finds the list of all published messages that will not be confirmed and returns them WITHOUT loading the payload. These are only messages published with QoS > 0. Messages published with QoS = 0 do not belong to the results list.

Returns:
Throws:
EsfStoreException

unpublishAllInFlighMessages

void unpublishAllInFlighMessages()
                                 throws EsfStoreException
Marks all in-flight messages as unpublished.

Throws:
EsfStoreException

dropAllInFlightMessages

void dropAllInFlightMessages()
                             throws EsfStoreException
Drops all in-flight messages.

Throws:
EsfStoreException

deleteStaleMessages

void deleteStaleMessages(int purgeAge)
                         throws EsfStoreException
Deletes stale messages. These are either published messages with QoS = 0 or confirmed messages with QoS > 0, whose age exceeds the argument.

Parameters:
purgeAge -
Throws:
EsfStoreException

defrag

void defrag()
            throws EsfStoreException
Defragments the store.

Throws:
EsfStoreException - TODO

checkpoint

void checkpoint()
                throws EsfStoreException
Performs a checkpoint of the store.

Throws:
EsfStoreException


Copyright © 2013. All Rights Reserved.