Interface AggregateEventStream
-
- All Known Implementing Classes:
BufferedAggregateEventStream
public interface AggregateEventStreamA stream of Events for a single Aggregate. The operations on this stream are blocking and intended for Event Sourcing purposes, where an Aggregate's state needs to be reconstructed based on historic events.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Stream<Event>asStream()Returns a Stream that consumes the Events from this instance.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.
-
-
-
Method Detail
-
next
Event next() throws InterruptedException
Returns the next available event, possibly blocking until one becomes available for reading.- Returns:
- the next event
- Throws:
InterruptedException- if the current thread was interrupted while waiting for an event to become availableStreamClosedException- when the stream has reached the end or was closed for another reason- See Also:
to verify availability of events
-
hasNext
boolean hasNext()
Indicates whether a new event is available. This method may block while waiting for a confirmation if an event is available for reading.- Returns:
trueif a message is available, orfalseif the stream has reached the end- Throws:
StreamClosedException- if the stream has been closed prematurely because of an error or on client request
-
cancel
void cancel()
Close 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,hasNext()may throw aStreamClosedExceptionif the cancellation caused the stream to close before the last message was received.
-
asStream
default Stream<Event> asStream()
Returns a Stream that consumes the Events from this instance. Note that this instance should not be read from in parallel to the returned stream, as this may provide undefined results on the availability of events in either stream instance.- Returns:
- a Stream containing the Events contained in this stream
-
-