Interface ContinuousQueryListener<T>

  • Type Parameters:
    T - Type of returned attribute from the datastore.

    public interface ContinuousQueryListener<T>
    Interface for an object that listens to changes resulting from a continuous query. Continuous Queries will activate immediately when they are added to the CTSPersistentStore via the addContinuousQueryListener method. Once configured via the CTS a continuous query is intended to be persistent. Though it is possible to stop and remove ContinuousQueries from the connection they are being executed on - whether through the query having completed or otherwise, the main intention is to relay messages to the listener from the point of server startup through to shutdown. Any number of listeners may be registered against a given ContinuousQuery, but all must be removed should the query be stopped. In the event of a connection failure to the underlying datastore, the ContinuousQuery should call connectionLost to ensure that the caller can respond appropriately (clearing caches, etc). Implementations of this should handle their own exceptions. Any runtime exceptions which are thrown will be logged, and the logic for handling a lost connection will be triggered in order to reset the listener.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void connectionLost()
      Notify the listener that a connection error has occurred, and object change notifications will not be received until the connectionReestablished() has been triggered.
      void connectionReestablished()
      Notify the listener that the connection to the data layer has been re-established, and that they should expect to receive object change notifications again.
      void objectChanged​(String tokenId, Map<String,​T> changeSet, ChangeType changeType)
      Notify the listener that the following token has been altered.
      void objectsChanged​(Set<String> tokenIds)
      Notify the listener that the following tokens have been altered.
      void processError​(DataLayerException error)
      If an error occurred initiating the task from the DataLayer (e.g.
    • Method Detail

      • objectChanged

        void objectChanged​(String tokenId,
                           Map<String,​T> changeSet,
                           ChangeType changeType)
        Notify the listener that the following token has been altered.
        Parameters:
        tokenId - the identifier of the token which has changed.
        changeSet - the set of changes to the token from the query result.
        changeType - the type of change made to the token.
      • objectsChanged

        void objectsChanged​(Set<String> tokenIds)
        Notify the listener that the following tokens have been altered.
        Parameters:
        tokenIds - the identifiers of the tokens which have changed.
      • connectionLost

        void connectionLost()
        Notify the listener that a connection error has occurred, and object change notifications will not be received until the connectionReestablished() has been triggered. Callers which depend on continuous observation of these notifications should take appropriate action - e.g. to wipe a dirty cache. The opposite of connectionReestablished().
      • processError

        void processError​(DataLayerException error)
        If an error occurred initiating the task from the DataLayer (e.g. failing to achieve a connection to the underlying data store), this method should be called with the error passed in.
        Parameters:
        error - Details of the issue.
      • connectionReestablished

        void connectionReestablished()
        Notify the listener that the connection to the data layer has been re-established, and that they should expect to receive object change notifications again. Callers which depend on the continuous observation of these results may want to reconcile any data which depends on the object changed notifications to avoid stale data. The opposite of connectionLost().