Class SimpleQueryUpdateEmitter

java.lang.Object
org.axonframework.messaging.queryhandling.SimpleQueryUpdateEmitter
All Implemented Interfaces:
DescribableComponent, QueryUpdateEmitter

public class SimpleQueryUpdateEmitter extends Object implements QueryUpdateEmitter
Simple implementation of the QueryUpdateEmitter, delegating operations to a QueryBus for emitting update, completing subscription queries, and completing subscription queries exceptionally.

Uses the ProcessingContext given during construction of the SimpleQueryUpdateEmitter to perform all operations in the expected lifecycle order.

Since:
4.0.0
Author:
Milan Savic, Stefan Dragisic, Steven van Beelen
  • Constructor Details

  • Method Details

    • emit

      public <Q> void emit(@Nonnull Class<Q> queryType, @Nonnull Predicate<? super Q> filter, @Nonnull Supplier<Object> updateSupplier)
      Description copied from interface: QueryUpdateEmitter
      Emits the outcome of the updateSupplier to subscription queries matching the given queryType and given filter.

      The updateSupplier is only invoked whenever there are matching queries.

      Specified by:
      emit in interface QueryUpdateEmitter
      Type Parameters:
      Q - The type of the
      invalid reference
      SubscriptionQueryMessage
      to filter on.
      Parameters:
      queryType - The type of the
      invalid reference
      SubscriptionQueryMessage
      to filter on.
      filter - A predicate testing the
      invalid reference
      SubscriptionQueryMessage#payload()
      , converted to the given queryType to filter on.
      updateSupplier - The update supplier to emit for subscription queries matching the given queryType and filter.
    • emit

      public void emit(@Nonnull QualifiedName queryName, @Nonnull Predicate<Object> filter, @Nonnull Supplier<Object> updateSupplier)
      Description copied from interface: QueryUpdateEmitter
      Emits the outcome of the updateSupplier to subscription queries matching the given queryName and given filter.

      The updateSupplier is only invoked whenever there are matching queries.

      Specified by:
      emit in interface QueryUpdateEmitter
      Parameters:
      queryName - The qualified name of the
      invalid reference
      SubscriptionQueryMessage#type()
      to filter on.
      filter - A predicate testing the
      invalid reference
      SubscriptionQueryMessage#payload()
      as is to the given queryType to filter on.
      updateSupplier - The update supplier to emit for subscription queries matching the given queryName and filter.
    • complete

      public <Q> void complete(@Nonnull Class<Q> queryType, @Nonnull Predicate<? super Q> filter)
      Description copied from interface: QueryUpdateEmitter
      Completes subscription queries matching the given queryType and filter.
      Specified by:
      complete in interface QueryUpdateEmitter
      Type Parameters:
      Q - The type of the
      invalid reference
      SubscriptionQueryMessage
      to filter on.
      Parameters:
      queryType - The type of the
      invalid reference
      SubscriptionQueryMessage
      to filter on.
      filter - A predicate testing the
      invalid reference
      SubscriptionQueryMessage#payload()
      , converted to the given queryType to filter on.
    • complete

      public void complete(@Nonnull QualifiedName queryName, @Nonnull Predicate<Object> filter)
      Description copied from interface: QueryUpdateEmitter
      Completes subscription queries matching the given queryName and filter.
      Specified by:
      complete in interface QueryUpdateEmitter
      Parameters:
      queryName - The qualified name of the
      invalid reference
      SubscriptionQueryMessage#type()
      to filter on.
      filter - A predicate testing the
      invalid reference
      SubscriptionQueryMessage#payload()
      as is to the given queryType to filter on.
    • completeExceptionally

      public <Q> void completeExceptionally(@Nonnull Class<Q> queryType, @Nonnull Predicate<? super Q> filter, @Nonnull Throwable cause)
      Description copied from interface: QueryUpdateEmitter
      Completes subscription queries with the given cause matching given queryType and filter.
      Specified by:
      completeExceptionally in interface QueryUpdateEmitter
      Type Parameters:
      Q - The type of the
      invalid reference
      SubscriptionQueryMessage
      to filter on.
      Parameters:
      queryType - The type of the
      invalid reference
      SubscriptionQueryMessage
      to filter on.
      filter - A predicate testing the
      invalid reference
      SubscriptionQueryMessage#payload()
      , converted to the given queryType to filter on.
      cause - The cause of an error leading to exceptionally complete subscription queries.
    • completeExceptionally

      public void completeExceptionally(@Nonnull QualifiedName queryName, @Nonnull Predicate<Object> filter, @Nonnull Throwable cause)
      Description copied from interface: QueryUpdateEmitter
      Completes subscription queries with the given cause matching given queryName and filter.
      Specified by:
      completeExceptionally in interface QueryUpdateEmitter
      Parameters:
      queryName - The qualified name of the
      invalid reference
      SubscriptionQueryMessage#type()
      to filter on.
      filter - A predicate testing the
      invalid reference
      SubscriptionQueryMessage#payload()
      as is to the given queryType to filter on.
      cause - The cause of an error leading to exceptionally complete subscription queries.
    • describeTo

      public void describeTo(@Nonnull ComponentDescriptor descriptor)
      Description copied from interface: DescribableComponent
      Describe the properties of this DescribableComponent with the given descriptor.

      Components should call the appropriate describeProperty methods on the descriptor to register their properties. The descriptor is responsible for determining how these properties are formatted and structured in the final output.

      Best Practices: As a general rule, all relevant fields of a DescribableComponent implementation should be described in this method. However, developers have discretion to include only the fields that make sense in the context. Not every field may be meaningful for description purposes, especially internal implementation details. Furthermore, components might want to expose different information based on their current state. The final decision on what properties to include lies with the person implementing the describeTo method, who should focus on providing information that is useful for understanding the component's configuration and state.

      Example implementation:

       public void describeTo(ComponentDescriptor descriptor) {
           descriptor.describeProperty("name", this.name);
           descriptor.describeProperty("enabled", this.enabled);
           descriptor.describeProperty("configuration", this.configuration); // A nested component
           descriptor.describeProperty("handlers", this.eventHandlers);      // A collection
       }
       
      Specified by:
      describeTo in interface DescribableComponent
      Parameters:
      descriptor - The component descriptor to describe this DescribableComponentn its properties in.