Interface QueryUpdateEmitter

All Superinterfaces:
MessageDispatchInterceptorSupport<SubscriptionQueryUpdateMessage<?>>
All Known Implementing Classes:
SimpleQueryUpdateEmitter

public interface QueryUpdateEmitter extends MessageDispatchInterceptorSupport<SubscriptionQueryUpdateMessage<?>>
Component which informs subscription queries about updates, errors and when there are no more updates.

If any of the emitter functions in this interface are called from a message handling function (e.g. an EventHandler annotated function), then that call will automatically be tied into the lifecycle of the current UnitOfWork to ensure correct order of execution.

Added, implementations of this class should thus respect any current UnitOfWork in the UnitOfWork.Phase.STARTED phase for any of the emitting functions. If this is the case then the emitter call action should be performed during the UnitOfWork.Phase.AFTER_COMMIT. Otherwise the operation can be executed immediately.

Since:
3.3
Author:
Milan Savic
  • Method Details

    • emit

      <U> void emit(@Nonnull Predicate<SubscriptionQueryMessage<?,?,U>> filter, @Nonnull SubscriptionQueryUpdateMessage<U> update)
      Emits incremental update (as return value of provided update function) to subscription queries matching given filter.
      Type Parameters:
      U - the type of the update
      Parameters:
      filter - predicate on subscription query message used to filter subscription queries
      update - incremental update message
    • emit

      default <U> void emit(@Nonnull Predicate<SubscriptionQueryMessage<?,?,U>> filter, @Nullable U update)
      Emits given incremental update to subscription queries matching given filter. If an update is null, emit will be skipped. In order to send nullable updates, use emit(Class, Predicate, SubscriptionQueryUpdateMessage) or emit(Predicate, SubscriptionQueryUpdateMessage) methods.
      Type Parameters:
      U - the type of the update
      Parameters:
      filter - predicate on subscription query message used to filter subscription queries
      update - incremental update
    • emit

      default <Q, U> void emit(@Nonnull Class<Q> queryType, @Nonnull Predicate<? super Q> filter, @Nonnull SubscriptionQueryUpdateMessage<U> update)
      Emits given incremental update to subscription queries matching given query type and filter.
      Type Parameters:
      Q - the type of the query
      U - the type of the update
      Parameters:
      queryType - the type of the query
      filter - predicate on query payload used to filter subscription queries
      update - incremental update message
    • emit

      default <Q, U> void emit(@Nonnull Class<Q> queryType, @Nonnull Predicate<? super Q> filter, @Nullable U update)
      Emits given incremental update to subscription queries matching given query type and filter. If an update is null, emit will be skipped. In order to send nullable updates, use emit(Class, Predicate, SubscriptionQueryUpdateMessage) or emit(Predicate, SubscriptionQueryUpdateMessage) methods.
      Type Parameters:
      Q - the type of the query
      U - the type of the update
      Parameters:
      queryType - the type of the query
      filter - predicate on query payload used to filter subscription queries
      update - incremental update
    • complete

      void complete(@Nonnull Predicate<SubscriptionQueryMessage<?,?,?>> filter)
      Completes subscription queries matching given filter.
      Parameters:
      filter - predicate on subscription query message used to filter subscription queries
    • complete

      default <Q> void complete(@Nonnull Class<Q> queryType, @Nonnull Predicate<? super Q> filter)
      Completes subscription queries matching given query type and filter.
      Type Parameters:
      Q - the type of the query
      Parameters:
      queryType - the type of the query
      filter - predicate on query payload used to filter subscription queries
    • completeExceptionally

      void completeExceptionally(@Nonnull Predicate<SubscriptionQueryMessage<?,?,?>> filter, @Nonnull Throwable cause)
      Completes with an error subscription queries matching given filter.
      Parameters:
      filter - predicate on subscription query message used to filter subscription queries
      cause - the cause of an error
    • completeExceptionally

      default <Q> void completeExceptionally(@Nonnull Class<Q> queryType, @Nonnull Predicate<? super Q> filter, @Nonnull Throwable cause)
      Completes with an error subscription queries matching given query type and filter
      Type Parameters:
      Q - the type of the query
      Parameters:
      queryType - the type of the query
      filter - predicate on query payload used to filter subscription queries
      cause - the cause of an error
    • queryUpdateHandlerRegistered

      boolean queryUpdateHandlerRegistered(@Nonnull SubscriptionQueryMessage<?,?,?> query)
      Checks whether there is a query update handler for a given query.
      Parameters:
      query - the subscription query for which we have registered the update handler
      Returns:
      true if there is an update handler registered for given query, false otherwise
    • registerUpdateHandler

      @Deprecated <U> UpdateHandlerRegistration<U> registerUpdateHandler(SubscriptionQueryMessage<?,?,?> query, SubscriptionQueryBackpressure backpressure, int updateBufferSize)
      Registers an Update Handler for given query with given backpressure and updateBufferSize.
      Type Parameters:
      U - the incremental response types of the query
      Parameters:
      query - the subscription query for which we register an Update Handler
      backpressure - the backpressure mechanism to be used for emitting updates
      updateBufferSize - the size of buffer which accumulates updates before subscription to the flux is made
      Returns:
      the object which contains updates and a registration which can be used to cancel them
    • registerUpdateHandler

      <U> UpdateHandlerRegistration<U> registerUpdateHandler(@Nonnull SubscriptionQueryMessage<?,?,?> query, int updateBufferSize)
      Registers an Update Handler for given query with given updateBufferSize.
      Type Parameters:
      U - the incremental response types of the query
      Parameters:
      query - the subscription query for which we register an Update Handler
      updateBufferSize - the size of buffer which accumulates updates before subscription to the flux is made
      Returns:
      the object which contains updates and a registration which can be used to cancel them
    • activeSubscriptions

      default Set<SubscriptionQueryMessage<?,?,?>> activeSubscriptions()
      Provides the set of running subscription queries. If there are changes to subscriptions they will be reflected in the returned set of this method. Implementations should provide an unmodifiable set of the active subscriptions.
      Returns:
      the set of running subscription queries