Class StreamOptions

java.lang.Object
org.acemq.amqp.core.StreamOptions

public final class StreamOptions extends Object
How a stream should be read.

Built by the DSL rather than by hand:


 mq.stream("orders.log", OrderPlaced.class)
         .fromFirst()
         .prefetch(200)
         .skipFailures()
         .consume(message -> project(message.payload()));
 
  • Method Details

    • defaults

      public static StreamOptions defaults()
      Returns:
      read only messages written from now on, with a prefetch of 100
    • fromFirst

      public StreamOptions fromFirst()
      Returns:
      everything the stream still holds, oldest first
    • fromLast

      public StreamOptions fromLast()
      Returns:
      the last chunk the stream holds and everything after it
    • fromNext

      public StreamOptions fromNext()
      Returns:
      only messages written after this consumer attaches
    • fromOffset

      public StreamOptions fromOffset(long offset)
      Parameters:
      offset - exact position, normally one past the last offset recorded as handled
      Returns:
      options starting there
    • from

      public StreamOptions from(Instant timestamp)
      Parameters:
      timestamp - point in time to start from
      Returns:
      options starting at the first message written at or after it
    • fromLast

      public StreamOptions fromLast(Duration age)
      Parameters:
      age - how far back to begin
      Returns:
      options replaying that period and then continuing
    • withOffset

      public StreamOptions withOffset(StreamOffset offset)
      Parameters:
      offset - where to start
      Returns:
      options starting there
    • prefetch

      public StreamOptions prefetch(int prefetch)
      Parameters:
      prefetch - how many unacknowledged messages the broker may have in flight
      Returns:
      options with that prefetch
    • skipFailures

      public StreamOptions skipFailures()
      Carries on past a message whose handler failed.
      Returns:
      options that skip failures rather than stopping
    • as

      public StreamOptions as(Codec codec)
      Parameters:
      codec - the format to read with, for formats whose bytes describe nothing
      Returns:
      options reading that format
    • offset

      public StreamOffset offset()
      Returns:
      where reading starts
    • prefetchCount

      public int prefetchCount()
      Returns:
      how many unacknowledged messages may be in flight
    • onFailure

      public StreamOptions.OnFailure onFailure()
      Returns:
      what happens when a handler throws
    • codec

      public Optional<Codec> codec()
      Returns:
      the format this consumer was told to read, if it was told one
    • toString

      public String toString()
      Overrides:
      toString in class Object