Interface AggregateEventStream

  • All Known Implementing Classes:
    BufferedAggregateEventStream

    public interface AggregateEventStream
    A 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.
      void cancel()
      Close this stream for further reading, notifying the provider of Events to stop streaming them.
      boolean hasNext()
      Indicates whether a new event is available.
      Event next()
      Returns the next available event, possibly blocking until one becomes available for reading.
    • Method Detail

      • 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:
        true if a message is available, or false if 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 a StreamClosedException if 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