Class AbstractQueryResponseMessageStream<T>
- Type Parameters:
T- The type of the objects in the underlyingResultStreamto be transformed intoQueryResponseMessages.
- All Implemented Interfaces:
MessageStream<QueryResponseMessage>
- Direct Known Subclasses:
QueryResponseMessageStream,QueryUpdateMessageStream
MessageStream interface that wraps a ResultStream. This class
provides functionality for transforming the data in the ResultStream into QueryResponseMessages,
handling any encountered errors, and managing stream lifecycle events.- Since:
- 5.0.0
- Author:
- Allard Buijze, Jan Gallinkski, John Hendrikx
-
Nested Class Summary
Nested classes/interfaces inherited from class org.axonframework.messaging.core.AbstractMessageStream
AbstractMessageStream.FetchResult<T extends @Nullable MessageStream.Entry<?>>Nested classes/interfaces inherited from interface org.axonframework.messaging.core.MessageStream
MessageStream.Empty<M extends Message>, MessageStream.Entry<M extends Message>, MessageStream.Single<M extends Message> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractQueryResponseMessageStream(io.axoniq.axonserver.connector.ResultStream<T> stream) Constructs an instance of the AbstractQueryResponseMessageStream class with the provided result stream. -
Method Summary
Modifier and TypeMethodDescriptionAttempts to fetch the next availableMessageStream.Entryfrom the underlying source.protected abstract booleanprotected voidCallback invoked when the stream is about to transition to a completed state, either successfully or exceptionally.Methods inherited from class org.axonframework.messaging.core.AbstractMessageStream
close, describeDelegates, describeFlags, error, hasNextAvailable, initialize, isCompleted, next, peek, setCallback, signalProgress, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.axonframework.messaging.core.MessageStream
cast, concatWith, filter, first, ignoreEntries, map, mapMessage, onClose, onComplete, onErrorContinue, onNext, reduce
-
Constructor Details
-
AbstractQueryResponseMessageStream
Constructs an instance of the AbstractQueryResponseMessageStream class with the provided result stream.- Parameters:
stream- TheResultStreaminstance from which query response data will be fetched. Must not be null.
-
-
Method Details
-
fetchNext
Description copied from class:AbstractMessageStreamAttempts to fetch the next availableMessageStream.Entryfrom the underlying source.This method is invoked by
AbstractMessageStream.next()when no previously peeked entry is available. Implementations must return aAbstractMessageStream.FetchResultdescribing the current state of the stream:AbstractMessageStream.FetchResult.Valueif an entry is immediately available,AbstractMessageStream.FetchResult.NotReadyif no entry is currently available but more may arrive later,AbstractMessageStream.FetchResult.Completedif the stream is exhausted and will produce no further entries,AbstractMessageStream.FetchResult.Errorif the stream has failed with an error.
Returning
AbstractMessageStream.FetchResult.NotReadywill transition the stream into an awaiting data state. Implementations must subsequently invokeAbstractMessageStream.signalProgress()when progress may be possible again (e.g., when new data arrives or the stream completes).Implementations must ensure that any state changes observable via this method are fully applied before invoking
AbstractMessageStream.signalProgress(). A signal that arrives before the consumer has entered the awaiting state is not replayed; correctness relies on this method returning the updated state when the consumer calls it next. SeeAbstractMessageStream.signalProgress()for the full ordering contract.This method must be non-blocking. It should return immediately with the best available information about the stream's current state.
Implementations must not attempt to complete or close the stream directly. Instead, they must return
AbstractMessageStream.FetchResult.CompletedorAbstractMessageStream.FetchResult.Errorto signal termination.If an implementation throws an exception, the stream completes exceptionally with that exception.
- Specified by:
fetchNextin classAbstractMessageStream<QueryResponseMessage>- Returns:
- a
AbstractMessageStream.FetchResultrepresenting the outcome of the fetch attempt
-
onCompleted
protected void onCompleted()Description copied from class:AbstractMessageStreamCallback invoked when the stream is about to transition to a completed state, either successfully or exceptionally. Subclasses may override this method to perform custom actions on completion.If the implementation throws an exception, the stream still completes, but it will complete with the thrown exception. If the stream was about to complete with an error, and the callback fails as well, the exception is added as a suppressed exception.
- Overrides:
onCompletedin classAbstractMessageStream<QueryResponseMessage>
-
isError
-