Class SimpleQueryUpdateEmitter
- All Implemented Interfaces:
DescribableComponent,QueryUpdateEmitter
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
-
Field Summary
Fields inherited from interface org.axonframework.messaging.queryhandling.QueryUpdateEmitter
RESOURCE_KEY -
Constructor Summary
ConstructorsConstructorDescriptionSimpleQueryUpdateEmitter(QueryBus queryBus, MessageTypeResolver messageTypeResolver, MessageConverter converter, ProcessingContext context) Construct aSimpleQueryUpdateEmitterwith the givenmessageTypeResolver,queryBus, andcontext. -
Method Summary
Modifier and TypeMethodDescription<Q> voidCompletes subscription queries matching the givenqueryTypeandfilter.voidcomplete(QualifiedName queryName, Predicate<Object> filter) Completes subscription queries matching the givenqueryNameandfilter.<Q> voidcompleteExceptionally(Class<Q> queryType, Predicate<? super Q> filter, Throwable cause) Completes subscription queries with the givencausematching givenqueryTypeandfilter.voidcompleteExceptionally(QualifiedName queryName, Predicate<Object> filter, Throwable cause) Completes subscription queries with the givencausematching givenqueryNameandfilter.voiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.<Q> voidEmits the outcome of theupdateSupplierto subscription queries matching the givenqueryTypeand givenfilter.voidEmits the outcome of theupdateSupplierto subscription queries matching the givenqueryNameand givenfilter.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.messaging.queryhandling.QueryUpdateEmitter
emit, emit
-
Constructor Details
-
SimpleQueryUpdateEmitter
public SimpleQueryUpdateEmitter(@Nonnull QueryBus queryBus, @Nonnull MessageTypeResolver messageTypeResolver, @Nonnull MessageConverter converter, @Nonnull ProcessingContext context) Construct aSimpleQueryUpdateEmitterwith the givenmessageTypeResolver,queryBus, andcontext.The
messageTypeResolveris used to constructupdate messagesforQueryUpdateEmitter.emit(Class, Predicate, Object)invocations. AnyQueryUpdateEmitter.emit(Class, Predicate, Object)orQueryUpdateEmitter.emit(QualifiedName, Predicate, Object)is delegated toQueryBus.emitUpdate(Predicate, Supplier, ProcessingContext). Similarly,complete(Class, Predicate)/complete(QualifiedName, Predicate)andcompleteExceptionally(Class, Predicate, Throwable)/completeExceptionally(QualifiedName, Predicate, Throwable)are respectively delegated toQueryBus.completeSubscriptions(Predicate, ProcessingContext)andQueryBus.completeSubscriptionsExceptionally(Predicate, Throwable, ProcessingContext).- Parameters:
queryBus- TheQueryBusto delegate theQueryUpdateEmitter.emit(Class, Predicate, Object),complete(Class, Predicate), andcompleteExceptionally(Class, Predicate, Throwable)invocations to.messageTypeResolver- TheMessageTyperesolver used to constructupdate messagesforQueryUpdateEmitter.emit(Class, Predicate, Object)invocationsconverter- TheMessageConverterused to convert thepayloadwhenever a filter is used based on a concrete type. For example, throughQueryUpdateEmitter.emit(Class, Predicate, Object).context- TheProcessingContextwithin which update are emitted, subscription query are completed, and subscription queries are completed exceptionally in.
-
-
Method Details
-
emit
public <Q> void emit(@Nonnull Class<Q> queryType, @Nonnull Predicate<? super Q> filter, @Nonnull Supplier<Object> updateSupplier) Description copied from interface:QueryUpdateEmitterEmits the outcome of theupdateSupplierto subscription queries matching the givenqueryTypeand givenfilter.The
updateSupplieris only invoked whenever there are matching queries.- Specified by:
emitin interfaceQueryUpdateEmitter- Type Parameters:
Q- The type of theto filter on.invalid reference
SubscriptionQueryMessage- Parameters:
queryType- The type of theto filter on.invalid reference
SubscriptionQueryMessagefilter- A predicate testing the, converted to the giveninvalid reference
SubscriptionQueryMessage#payload()queryTypeto filter on.updateSupplier- The update supplier to emit forsubscription queriesmatching the givenqueryTypeandfilter.
-
emit
public void emit(@Nonnull QualifiedName queryName, @Nonnull Predicate<Object> filter, @Nonnull Supplier<Object> updateSupplier) Description copied from interface:QueryUpdateEmitterEmits the outcome of theupdateSupplierto subscription queries matching the givenqueryNameand givenfilter.The
updateSupplieris only invoked whenever there are matching queries.- Specified by:
emitin interfaceQueryUpdateEmitter- Parameters:
queryName- The qualified name of theto filter on.invalid reference
SubscriptionQueryMessage#type()filter- A predicate testing theas is to the giveninvalid reference
SubscriptionQueryMessage#payload()queryTypeto filter on.updateSupplier- The update supplier to emit forsubscription queriesmatching the givenqueryNameandfilter.
-
complete
Description copied from interface:QueryUpdateEmitterCompletes subscription queries matching the givenqueryTypeandfilter.- Specified by:
completein interfaceQueryUpdateEmitter- Type Parameters:
Q- The type of theto filter on.invalid reference
SubscriptionQueryMessage- Parameters:
queryType- The type of theto filter on.invalid reference
SubscriptionQueryMessagefilter- A predicate testing the, converted to the giveninvalid reference
SubscriptionQueryMessage#payload()queryTypeto filter on.
-
complete
Description copied from interface:QueryUpdateEmitterCompletes subscription queries matching the givenqueryNameandfilter.- Specified by:
completein interfaceQueryUpdateEmitter- Parameters:
queryName- The qualified name of theto filter on.invalid reference
SubscriptionQueryMessage#type()filter- A predicate testing theas is to the giveninvalid reference
SubscriptionQueryMessage#payload()queryTypeto filter on.
-
completeExceptionally
public <Q> void completeExceptionally(@Nonnull Class<Q> queryType, @Nonnull Predicate<? super Q> filter, @Nonnull Throwable cause) Description copied from interface:QueryUpdateEmitterCompletes subscription queries with the givencausematching givenqueryTypeandfilter.- Specified by:
completeExceptionallyin interfaceQueryUpdateEmitter- Type Parameters:
Q- The type of theto filter on.invalid reference
SubscriptionQueryMessage- Parameters:
queryType- The type of theto filter on.invalid reference
SubscriptionQueryMessagefilter- A predicate testing the, converted to the giveninvalid reference
SubscriptionQueryMessage#payload()queryTypeto 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:QueryUpdateEmitterCompletes subscription queries with the givencausematching givenqueryNameandfilter.- Specified by:
completeExceptionallyin interfaceQueryUpdateEmitter- Parameters:
queryName- The qualified name of theto filter on.invalid reference
SubscriptionQueryMessage#type()filter- A predicate testing theas is to the giveninvalid reference
SubscriptionQueryMessage#payload()queryTypeto filter on.cause- The cause of an error leading to exceptionally complete subscription queries.
-
describeTo
Description copied from interface:DescribableComponentDescribe the properties ofthis DescribableComponentwith the givendescriptor.Components should call the appropriate
describePropertymethods 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
DescribableComponentimplementation 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 thedescribeTomethod, 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:
describeToin interfaceDescribableComponent- Parameters:
descriptor- The component descriptor to describethis DescribableComponentn its properties in.
-