Class ConcatenatingDomainEventStream
java.lang.Object
org.axonframework.eventsourcing.eventstore.ConcatenatingDomainEventStream
- All Implemented Interfaces:
Iterator<DomainEventMessage<?>>,DomainEventStream
DomainEventStream implementation that concatenates multiple streams, taking into account that some sequence
numbers may appear in more than one stream.
Streams are consumed in the order provided, skipping events that have sequence numbers equal or lower than the last sequence number consumed from the previous stream.
This implementation is not thread safe. It should not be consumed by more than one thread at a time.
- Since:
- 3.1.1
-
Constructor Summary
ConstructorsConstructorDescriptionInitialize the stream, concatenating the givenstreams.ConcatenatingDomainEventStream(DomainEventStream... streams) Initialize the stream, concatenating the givenstreams. -
Method Summary
Modifier and TypeMethodDescriptionGet the highest known sequence number in the upstream event entry stream.booleanhasNext()Returnstrueif the stream has more events, meaning that a call tonext()will not result in an exception.next()Returns the next events in the stream, if available.peek()Returns the next events in the stream, if available, without moving the pointer forward.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.eventsourcing.eventstore.DomainEventStream
asStream, filter, removeMethods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
ConcatenatingDomainEventStream
Initialize the stream, concatenating the givenstreams.- Parameters:
streams- The streams providing the elements to concatenate
-
ConcatenatingDomainEventStream
Initialize the stream, concatenating the givenstreams. The streams are consumed in the order the collection returns them.- Parameters:
streams- The streams providing the elements to concatenate
-
-
Method Details
-
peek
Description copied from interface:DomainEventStreamReturns the next events in the stream, if available, without moving the pointer forward. Hence, a call toDomainEventStream.next()will return the same event as a call topeek(). UsehasNext()to obtain a guarantee about the availability of any next event. If the pointer has reached the end of the stream, the behavior of this method is undefined. It could either returnnull, or throw an exception, depending on the actual implementation. UseDomainEventStream.hasNext()to confirm the existence of elements after the current pointer.- Specified by:
peekin interfaceDomainEventStream- Returns:
- the next event in the stream.
-
hasNext
public boolean hasNext()Description copied from interface:DomainEventStreamReturnstrueif the stream has more events, meaning that a call tonext()will not result in an exception. If a call to this method returnsfalse, there is no guarantee about the result of a consecutive call tonext()- Specified by:
hasNextin interfaceDomainEventStream- Specified by:
hasNextin interfaceIterator<DomainEventMessage<?>>- Returns:
trueif the stream contains more events.
-
next
Description copied from interface:DomainEventStreamReturns the next events in the stream, if available. UsehasNext()to obtain a guarantee about the availability of any next event. Each call tonext()will forward the pointer to the next event in the stream. If the pointer has reached the end of the stream, the behavior of this method is undefined. It could either returnnull, or throw an exception, depending on the actual implementation. UseDomainEventStream.hasNext()to confirm the existence of elements after the current pointer.- Specified by:
nextin interfaceDomainEventStream- Specified by:
nextin interfaceIterator<DomainEventMessage<?>>- Returns:
- the next event in the stream.
-
getLastSequenceNumber
Description copied from interface:DomainEventStreamGet the highest known sequence number in the upstream event entry stream. Note that, as result of upcasting it is possible that the last event in this stream has a lower sequence number than that returned by this method.To get the highest absolute sequence number of the underlying event entry stream make sure to iterate over all elements in the stream before calling this method.
If the stream is empty this method returns
null.- Specified by:
getLastSequenceNumberin interfaceDomainEventStream- Returns:
- the sequence number of the last known upstream event entry
-