Interface QueryListener

All Superinterfaces:
EventListener
All Known Implementing Classes:
AbstractBatchedQueryListener, AbstractQueryListener, CompositeQueryListener, DeleteQueryListener, LiveResult, QueryListenerWrapper, SnapshotQueryListener

public interface QueryListener extends EventListener
A query listener interface must be provided when registering a query. The server will make call backs to this interface with query events. If you are only interested in a subset of events consider using the AbstractQueryListener.

All tuple events between snapshotBegin(BeginSnapshotEvent) and snapshotEnd(EndSnapshotEvent) are tupleAdded(TupleAddedEvent) events.

If the LiveViewQueryType of the query is SNAPSHOT_AND_CONTINUOUS, then the QueryListener after the snapshotEnd(EndSnapshotEvent) can receive any number of tupleAdded(TupleAddedEvent), tupleUpdated(TupleUpdatedEvent), and tupleRemoved(TupleRemovedEvent), in any order.

It is also possible that the query results will need to be reset, in which case the QueryListener might receive a new snapshotBegin(BeginSnapshotEvent). This signals that all previous data should be discarded, and the entire process will start fresh. For example, if the query was made through a LiveViewMultiConnection, and the server that was servicing the query has gone down, and a new server has since picked the connection back up, the snapshotBegin(BeginSnapshotEvent) will signal the beginning of a new result set coming from the new server.

At any point the QueryListener might receive a exceptionRaised(QueryExceptionEvent), if some unrecoverable failure has happened. In that case, the query will be closed and no more TupleEvents will happen. If snapshotEnd(EndSnapshotEvent) has not yet been called, it won't be. The exception will be the final callback made to the QueryListener.

Note that callbacks should return quickly. In some situations, long running callbacks can trigger heartbeat failures and/or other connection problems, particularly in the face of high data rates.

  • Method Details

    • tupleAdded

      void tupleAdded(TupleAddedEvent event)
      Event when a new tuple is added to the result.
      Parameters:
      event - add event
    • tupleUpdated

      void tupleUpdated(TupleUpdatedEvent event)
      Event when an existing tuple in the result is updated.
      Parameters:
      event - update event
    • tupleRemoved

      void tupleRemoved(TupleRemovedEvent event)
      Event when an existing tuple is removed from the result.
      Parameters:
      event - remove event
    • snapshotBegin

      void snapshotBegin(BeginSnapshotEvent event)
      Event to indicate the start of the result snapshot. This is the first method called when a query starts returning results, but this method is also called to indicate a reset (a complete restart of the query.)
      Parameters:
      event - snapshot begin
    • snapshotEnd

      void snapshotEnd(EndSnapshotEvent event)
      Event to indicate the query snapshot is complete.
      Parameters:
      event - snapshot end
    • deleteBegin

      void deleteBegin(BeginDeleteEvent event)
      Event to indicate the start of delete query.
      Parameters:
      event - delete begin
      Since:
      1.5.2
    • deleteEnd

      void deleteEnd(EndDeleteEvent event)
      Event to indicate the delete query is complete.
      Parameters:
      event - delete end
      Since:
      1.5.2
    • aggMarkEnd

      default void aggMarkEnd(EndAggMarkEvent event)
      Event to indicate that the set of aggregation results since the last aggMarkBegin event are now consistent and will not change until the next aggMarkBegin.
      Parameters:
      event - the EndAggMarkEvent
      Since:
      7.7.4
    • aggMarkBegin

      default void aggMarkBegin(BeginAggMarkEvent event)
      Event to indicate that the set of aggregation results may be changing so some results may be from an older generation while other may be from a newer one.
      Parameters:
      event - the BeginAggMarkEvent
      Since:
      7.7.4
    • exceptionRaised

      void exceptionRaised(QueryExceptionEvent event)
      Event when an exception occurs during the query. Since 1.3, reaching the row limit is considered an exception.
      Parameters:
      event - exception event
      Since:
      1.3 - this method will be invoked when the query row limit is reached (earlier versions would simply end streaming results)
    • queryClosed

      void queryClosed(QueryClosedEvent event)
      Event when a query being listened to is closed.
      Parameters:
      event - query closed event