Class BufferedAggregateEventStream
- java.lang.Object
-
- io.axoniq.axonserver.connector.impl.FlowControlledStream<T,R>
-
- io.axoniq.axonserver.connector.impl.FlowControlledBuffer<Event,GetAggregateEventsRequest>
-
- io.axoniq.axonserver.connector.event.impl.BufferedAggregateEventStream
-
- All Implemented Interfaces:
AggregateEventStream,io.grpc.stub.ClientResponseObserver<GetAggregateEventsRequest,Event>,io.grpc.stub.StreamObserver<Event>
public class BufferedAggregateEventStream extends FlowControlledBuffer<Event,GetAggregateEventsRequest> implements AggregateEventStream
Buffering implementation of theAggregateEventStreamused for Event Sourced Aggregates.
-
-
Constructor Summary
Constructors Constructor Description BufferedAggregateEventStream()BufferedAggregateEventStream(int bufferSize, int refillBatch)Constructs aBufferedAggregateEventStreamwith the givenbufferSize.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected GetAggregateEventsRequestbuildFlowControlMessage(FlowControl flowControl)Build a flow control message of typeOUTbased on the givenflowControl.voidcancel()Close this stream for further reading, notifying the provider of Events to stop streaming them.booleanhasNext()Indicates whether a new event is available.Eventnext()Returns the next available event, possibly blocking until one becomes available for reading.protected EventterminalMessage()Builds a terminal message of typeTspecifying when the this stream is closed.-
Methods inherited from class io.axoniq.axonserver.connector.impl.FlowControlledBuffer
beforeStart, close, getErrorResult, isClosed, onCompleted, onError, onNext, peek, take, tryTake, tryTake, tryTake, tryTakeNow
-
Methods inherited from class io.axoniq.axonserver.connector.impl.FlowControlledStream
buildInitialFlowControlMessage, enableFlowControl, markConsumed, outboundStream
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.axoniq.axonserver.connector.event.AggregateEventStream
asStream
-
-
-
-
Constructor Detail
-
BufferedAggregateEventStream
public BufferedAggregateEventStream()
-
BufferedAggregateEventStream
public BufferedAggregateEventStream(int bufferSize, int refillBatch)Constructs aBufferedAggregateEventStreamwith the givenbufferSize.- Parameters:
bufferSize- the buffer size of the aggregate event stream
-
-
Method Detail
-
next
public Event next() throws InterruptedException
Description copied from interface:AggregateEventStreamReturns the next available event, possibly blocking until one becomes available for reading.- Specified by:
nextin interfaceAggregateEventStream- Returns:
- the next event
- Throws:
InterruptedException- if the current thread was interrupted while waiting for an event to become available- See Also:
to verify availability of events
-
hasNext
public boolean hasNext()
Description copied from interface:AggregateEventStreamIndicates whether a new event is available. This method may block while waiting for a confirmation if an event is available for reading.- Specified by:
hasNextin interfaceAggregateEventStream- Returns:
trueif a message is available, orfalseif the stream has reached the end
-
cancel
public void cancel()
Description copied from interface:AggregateEventStreamClose this stream for further reading, notifying the provider of Events to stop streaming them. Any event already emitted by the sender may still be consumed.Note that after calling
cancel,AggregateEventStream.hasNext()may throw aStreamClosedExceptionif the cancellation caused the stream to close before the last message was received.- Specified by:
cancelin interfaceAggregateEventStream
-
buildFlowControlMessage
protected GetAggregateEventsRequest buildFlowControlMessage(FlowControl flowControl)
Description copied from class:FlowControlledStreamBuild a flow control message of typeOUTbased on the givenflowControl.- Specified by:
buildFlowControlMessagein classFlowControlledStream<Event,GetAggregateEventsRequest>- Parameters:
flowControl- theFlowControlmessage used to base this implementation's flow control message on- Returns:
- the message used by this implementation to request new entries of type
IN
-
terminalMessage
protected Event terminalMessage()
Description copied from class:FlowControlledBufferBuilds a terminal message of typeTspecifying when the this stream is closed.- Specified by:
terminalMessagein classFlowControlledBuffer<Event,GetAggregateEventsRequest>- Returns:
- a terminal message of type
Tspecifying when the this stream is closed
-
-