Interface QueryUpdateEmitter
- All Superinterfaces:
DescribableComponent
- All Known Implementing Classes:
SimpleQueryUpdateEmitter
subscription queries about
update, errors,
and when there are no more update.
Implementations of the QueryUpdateEmitter are expected to be context-aware, to
ensure operations occur within the correct order of (for example) the lifecycle of an
event handling function.
- Since:
- 3.3.0
- Author:
- Milan Savic, Steven van Beelen
-
Method Summary
Modifier and TypeMethodDescription<Q> voidCompletes subscription queries matching the givenqueryTypeandfilter.voidcomplete(QualifiedName queryName, Predicate<Object> filter) Completes subscription queries matching the givenqueryNameandfilter.default <Q> OptionalIntcompleteAndCount(Class<Q> queryType, Predicate<? super Q> filter) Completes subscription queries matching the givenqueryTypeandfilter, returning the number of subscription queries that were completed.default OptionalIntcompleteAndCount(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.default <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.default OptionalIntcompleteExceptionallyAndCount(QualifiedName queryName, Predicate<Object> filter, Throwable cause) Completes subscription queries with the givencausematching givenqueryNameandfilter, returning the number of subscription queries that were completed exceptionally.default <Q> voidEmits givenupdateto subscription queries matching the givenqueryTypeand givenfilter.<Q> voidEmits the outcome of theupdateSupplierto subscription queries matching the givenqueryTypeand givenfilter.default voidemit(QualifiedName queryName, Predicate<Object> filter, @Nullable Object update) Emits givenupdateto subscription queries matching the givenqueryNameand givenfilter.voidEmits the outcome of theupdateSupplierto subscription queries matching the givenqueryNameand givenfilter.default <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.default OptionalIntemitAndCount(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.static QueryUpdateEmitterforContext(ProcessingContext context) Creates a query update emitter for the givenProcessingContext.Methods inherited from interface org.axonframework.common.infra.DescribableComponent
describeTo
-
Method Details
-
forContext
Creates a query update emitter for the givenProcessingContext.Use this from within a message handler, or any other method that receives a
ProcessingContext, instead of emitting directly through aQueryBus: the emitter returned here is bound to thatcontext, ensuring updates are emitted in the correct order relative to the lifecycle of whatever is currently being handled.Every invocation returns a fresh instance bound to the given
context, sincecontextmay override resources on top of a shared parent (seeProcessingContext.withResource(org.axonframework.messaging.core.Context.ResourceKey<T>, T)) - reusing an instance across such branches would risk it silently operating against the wrong one.- Parameters:
context- theProcessingContextto create the emitter for- Returns:
- a fresh emitter specific for the given
context
-
emit
Emits givenupdateto subscription queries matching the givenqueryTypeand givenfilter.- 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 givenqueryTypeupdate- the incremental update to emit forsubscription queriesmatching the givenfilter- Throws:
MessageTypeNotResolvedException- if the givenqueryTypehas no knownMessageTypeequivalent required to filter theMessage.payload()ConversionException- if theMessage.payload()could not be converted to the givenqueryTypeto perform the givenfilter. Will only occur if aMessageTypecould be found for the givenqueryType
-
emit
Emits the outcome of theupdateSupplierto subscription queries matching the givenqueryTypeand givenfilter.The
updateSupplieris only invoked whenever there are matching queries.- 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- Throws:
MessageTypeNotResolvedException- if the givenqueryTypehas no knownMessageTypeequivalent required to filter theMessage.payload()ConversionException- if theMessage.payload()could not be converted to the givenqueryTypeto perform the givenfilter. Will only occur if aMessageTypecould be found for the givenqueryType
-
emitAndCount
default <Q> OptionalInt emitAndCount(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.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.
- 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 - Throws:
MessageTypeNotResolvedException- if the givenqueryTypehas no knownMessageTypeequivalent required to filter theMessage.payload()ConversionException- if theMessage.payload()could not be converted to the givenqueryTypeto perform the givenfilter. Will only occur if aMessageTypecould be found for the givenqueryType
-
emit
Emits givenupdateto subscription queries matching the givenqueryNameand givenfilter.- Parameters:
queryName- the qualified name of theMessage.type()to filter onfilter- a predicate to filter matching subscription queries based on the rawMessage.payload()update- the incremental update to emit forsubscription queriesmatching the givenfilter
-
emit
Emits the outcome of theupdateSupplierto subscription queries matching the givenqueryNameand givenfilter.The
updateSupplieris only invoked whenever there are matching queries.- 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
default OptionalInt 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.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.
- 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
Completes subscription queries matching the givenqueryTypeandfilter.- 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- Throws:
MessageTypeNotResolvedException- if the givenqueryTypehas no knownMessageTypeequivalent required to filter theMessage.payload()ConversionException- if theMessage.payload()could not be converted to the givenqueryTypeto perform the givenfilter. Will only occur if aMessageTypecould be found for the givenqueryType
-
completeAndCount
Completes 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.
- 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 - Throws:
MessageTypeNotResolvedException- if the givenqueryTypehas no knownMessageTypeequivalent required to filter theMessage.payload()ConversionException- if theMessage.payload()could not be converted to the givenqueryTypeto perform the givenfilter. Will only occur if aMessageTypecould be found for the givenqueryType
-
complete
Completes subscription queries matching the givenqueryNameandfilter.- Parameters:
queryName- the qualified name of theMessage.type()to filter onfilter- a predicate testing the rawMessage.payload()as is
-
completeAndCount
Completes 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.
- 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
Completes subscription queries with the givencausematching givenqueryTypeandfilter.- 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- Throws:
MessageTypeNotResolvedException- if the givenqueryTypehas no knownMessageTypeequivalent required to filter theMessage.payload()ConversionException- if theMessage.payload()could not be converted to the givenqueryTypeto perform the givenfilter. Will only occur if aMessageTypecould be found for the givenqueryType
-
completeExceptionallyAndCount
default <Q> OptionalInt completeExceptionallyAndCount(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.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.
- 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 - Throws:
MessageTypeNotResolvedException- if the givenqueryTypehas no knownMessageTypeequivalent required to filter theMessage.payload()ConversionException- if theMessage.payload()could not be converted to the givenqueryTypeto perform the givenfilter. Will only occur if aMessageTypecould be found for the givenqueryType
-
completeExceptionally
Completes subscription queries with the givencausematching givenqueryNameandfilter.- 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
default OptionalInt 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.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.
- 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
-