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
-
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> OptionalIntcompleteAndCount(Class<Q> queryType, Predicate<? super Q> filter) Completes subscription queries matching the givenqueryTypeandfilter, returning the number of subscription queries that were completed.completeAndCount(QualifiedName queryName, Predicate<Object> filter) Completes subscription queries matching the givenqueryNameandfilter, returning the number of subscription queries that were completed.<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.<Q> OptionalIntcompleteExceptionallyAndCount(Class<Q> queryType, Predicate<? super Q> filter, Throwable cause) Completes subscription queries with the givencausematching givenqueryTypeandfilter, returning the number of subscription queries that were completed exceptionally.completeExceptionallyAndCount(QualifiedName queryName, Predicate<Object> filter, Throwable cause) Completes subscription queries with the givencausematching givenqueryNameandfilter, returning the number of subscription queries that were completed exceptionally.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.<Q> OptionalIntemitAndCount(Class<Q> queryType, Predicate<? super Q> filter, Supplier<Object> updateSupplier) Emits the outcome of theupdateSupplierto subscription queries matching the givenqueryTypeand givenfilter, returning the number of subscription queries the update was emitted to.emitAndCount(QualifiedName queryName, Predicate<Object> filter, Supplier<Object> updateSupplier) Emits the outcome of theupdateSupplierto subscription queries matching the givenqueryNameand givenfilter, returning the number of subscription queries the update was emitted to.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(QueryBus queryBus, MessageTypeResolver messageTypeResolver, MessageConverter converter, 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), while their match-count-returning counterparts,emitAndCount(Class, Predicate, Supplier)andemitAndCount(QualifiedName, Predicate, Supplier), are delegated toQueryBus.emitUpdateAndCount(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), with their match-count-returning counterparts delegated toQueryBus.completeSubscriptionsAndCount(Predicate, ProcessingContext)andQueryBus.completeSubscriptionsExceptionallyAndCount(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(Class<Q> queryType, Predicate<? super Q> filter, 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 theQueryMessageto filter on- Parameters:
queryType- the type of theQueryMessageto filter onfilter- a predicate to filter matching subscription queries based on theMessage.payload()converted to the givenqueryTypeupdateSupplier- the update supplier to emit forsubscription queriesmatching the givenqueryTypeandfilter
-
emitAndCount
public <Q> OptionalInt emitAndCount(Class<Q> queryType, Predicate<? super Q> filter, Supplier<Object> updateSupplier) Description copied from interface:QueryUpdateEmitterEmits the outcome of theupdateSupplierto subscription queries matching the givenqueryTypeand givenfilter, returning the number of subscription queries the update was emitted to.Implementations that cannot determine this number return
OptionalInt.empty()instead.A subscription query to which delivery of the update fails (for example due to a full update buffer) is excluded from this count, even though that failure still terminates the subscription.
- Specified by:
emitAndCountin interfaceQueryUpdateEmitter- Type Parameters:
Q- the type of theQueryMessageto filter on- Parameters:
queryType- the type of theQueryMessageto filter onfilter- a predicate to filter matching subscription queries based on theMessage.payload()converted to the givenqueryTypeupdateSupplier- the update supplier to emit forsubscription queriesmatching the givenqueryTypeandfilter- Returns:
- the number of subscription queries the update was emitted to as an
OptionalInt, which is empty when we couldn't match
-
emit
public void emit(QualifiedName queryName, Predicate<Object> filter, 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 theMessage.type()to filter onfilter- a predicate to filter matching subscription queries based on the rawMessage.payload()updateSupplier- the update supplier to emit forsubscription queriesmatching the givenqueryNameandfilter
-
emitAndCount
public OptionalInt emitAndCount(QualifiedName queryName, Predicate<Object> filter, Supplier<Object> updateSupplier) Description copied from interface:QueryUpdateEmitterEmits the outcome of theupdateSupplierto subscription queries matching the givenqueryNameand givenfilter, returning the number of subscription queries the update was emitted to.Implementations that cannot determine this number return
OptionalInt.empty()instead.A subscription query to which delivery of the update fails (for example due to a full update buffer) is excluded from this count, even though that failure still terminates the subscription.
- Specified by:
emitAndCountin interfaceQueryUpdateEmitter- Parameters:
queryName- the qualified name of theMessage.type()to filter onfilter- a predicate to filter matching subscription queries based on the rawMessage.payload()updateSupplier- the update supplier to emit forsubscription queriesmatching the givenqueryNameandfilter- Returns:
- the number of subscription queries the update was emitted to as an
OptionalInt, which is empty when we couldn't match
-
complete
Description copied from interface:QueryUpdateEmitterCompletes subscription queries matching the givenqueryTypeandfilter.- Specified by:
completein interfaceQueryUpdateEmitter- Type Parameters:
Q- the type of theQueryMessageto filter on- Parameters:
queryType- the type of theQueryMessageto filter onfilter- a predicate to filter matching subscription queries based on theMessage.payload()converted to the givenqueryType
-
completeAndCount
Description copied from interface:QueryUpdateEmitterCompletes subscription queries matching the givenqueryTypeandfilter, returning the number of subscription queries that were completed.Implementations that cannot determine this number return
OptionalInt.empty()instead.A subscription query for which completion fails is excluded from this count.
- Specified by:
completeAndCountin interfaceQueryUpdateEmitter- Type Parameters:
Q- the type of theQueryMessageto filter on.- Parameters:
queryType- the type of theQueryMessageto filter on.filter- a predicate to filter matching subscription queries based on theMessage.payload()converted to the givenqueryType- Returns:
- the number of subscription queries that were completed as an
OptionalInt, which is empty when we couldn't match
-
complete
Description copied from interface:QueryUpdateEmitterCompletes subscription queries matching the givenqueryNameandfilter.- Specified by:
completein interfaceQueryUpdateEmitter- Parameters:
queryName- the qualified name of theMessage.type()to filter onfilter- a predicate testing the rawMessage.payload()as is
-
completeAndCount
Description copied from interface:QueryUpdateEmitterCompletes subscription queries matching the givenqueryNameandfilter, returning the number of subscription queries that were completed.Implementations that cannot determine this number return
OptionalInt.empty()instead.A subscription query for which completion fails is excluded from this count.
- Specified by:
completeAndCountin interfaceQueryUpdateEmitter- Parameters:
queryName- the qualified name of theMessage.type()to filter onfilter- a predicate testing the rawMessage.payload()as is- Returns:
- the number of subscription queries that were completed as an
OptionalInt, which is empty when we couldn't match
-
completeExceptionally
public <Q> void completeExceptionally(Class<Q> queryType, Predicate<? super Q> filter, Throwable cause) Description copied from interface:QueryUpdateEmitterCompletes subscription queries with the givencausematching givenqueryTypeandfilter.- Specified by:
completeExceptionallyin interfaceQueryUpdateEmitter- Type Parameters:
Q- the type of theQueryMessageto filter on- Parameters:
queryType- the type of theQueryMessageto filter onfilter- a predicate to filter matching subscription queries based on theMessage.payload()converted to the givenqueryTypecause- the cause of an error leading to exceptionally complete subscription queries
-
completeExceptionallyAndCount
public <Q> OptionalInt completeExceptionallyAndCount(Class<Q> queryType, Predicate<? super Q> filter, Throwable cause) Description copied from interface:QueryUpdateEmitterCompletes subscription queries with the givencausematching givenqueryTypeandfilter, returning the number of subscription queries that were completed exceptionally.Implementations that cannot determine this number return
OptionalInt.empty()instead.A subscription query for which the exceptional completion fails to be delivered is excluded from this count.
- Specified by:
completeExceptionallyAndCountin interfaceQueryUpdateEmitter- Type Parameters:
Q- the type of theQueryMessageto filter on- Parameters:
queryType- the type of theQueryMessageto filter onfilter- a predicate to filter matching subscription queries based on theMessage.payload()converted to the givenqueryTypecause- the cause of an error leading to exceptionally complete subscription queries- Returns:
- the number of subscription queries that were completed exceptionally as an
OptionalInt, which is empty when we couldn't match
-
completeExceptionally
public void completeExceptionally(QualifiedName queryName, Predicate<Object> filter, Throwable cause) Description copied from interface:QueryUpdateEmitterCompletes subscription queries with the givencausematching givenqueryNameandfilter.- Specified by:
completeExceptionallyin interfaceQueryUpdateEmitter- Parameters:
queryName- the qualified name of theMessage.type()to filter onfilter- a predicate to filter matching subscription queries based on the rawMessage.payload()cause- the cause of an error leading to exceptionally complete subscription queries
-
completeExceptionallyAndCount
public OptionalInt completeExceptionallyAndCount(QualifiedName queryName, Predicate<Object> filter, Throwable cause) Description copied from interface:QueryUpdateEmitterCompletes subscription queries with the givencausematching givenqueryNameandfilter, returning the number of subscription queries that were completed exceptionally.Implementations that cannot determine this number return
OptionalInt.empty()instead.A subscription query for which the exceptional completion fails to be delivered is excluded from this count.
- Specified by:
completeExceptionallyAndCountin interfaceQueryUpdateEmitter- Parameters:
queryName- the qualified name of theMessage.type()to filter onfilter- a predicate to filter matching subscription queries based on the rawMessage.payload()cause- the cause of an error leading to exceptionally complete subscription queries- Returns:
- the number of subscription queries that were completed exceptionally as an
OptionalInt, which is empty when we couldn't match
-
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.
-