Class StreamParameters

java.lang.Object
org.zalando.fahrschein.StreamParameters

public class StreamParameters extends Object
  • Constructor Details

    • StreamParameters

      public StreamParameters()
  • Method Details

    • withBatchLimit

      public StreamParameters withBatchLimit(int batchLimit) throws IllegalArgumentException
      Maximum number of events in each chunk (and therefore per partition) of the stream.
      Parameters:
      batchLimit - Nakadi's default value (at the time of writing): 1. batchLimit must be lower or equal to streamLimit. A value of 0 (or less than 1) is rejected by Nakadi.
      Throws:
      IllegalArgumentException
    • withStreamLimit

      public StreamParameters withStreamLimit(int streamLimit) throws IllegalArgumentException
      Maximum number of events in this stream (over all partitions being streamed in this connection).
      Parameters:
      streamLimit - If 0 or undefined, will stream batches indefinitely. Stream initialization will fail if streamLimit is lower than batchLimit.
      Throws:
      IllegalArgumentException
    • withBatchFlushTimeout

      public StreamParameters withBatchFlushTimeout(int batchFlushTimeout) throws IllegalArgumentException

      Maximum time in seconds to wait for the flushing of each chunk (per partition).

      If the amount of buffered Events reaches batchLimit before this batchFlushTimeout is reached, the messages are immediately flushed to the client and batch flush timer is reset.

      If 0 or undefined, will assume 30 seconds.

      Value is treated as a recommendation. Nakadi may flush chunks with a smaller timeout.

      Parameters:
      batchFlushTimeout - Maximum time in seconds to wait for the flushing of each chunk (per partition). Nakadi's default value (at the time of writing): 30
      Throws:
      IllegalArgumentException
    • withStreamTimeout

      public StreamParameters withStreamTimeout(int streamTimeout) throws IllegalArgumentException

      Maximum time in seconds a stream will live before connection is closed by the server. If 0 or unspecified will stream for 1h ±10min.

      If this timeout is reached, any pending messages (in the sense of stream_limit) will be flushed to the client.

      Stream initialization will fail if streamTimeout is lower than batchFlushTimeout. If the streamTimeout is greater than max value (4200 seconds) - Nakadi will treat this as not specifying streamTimeout (this is done due to backwards compatibility).

      Parameters:
      streamTimeout - Maximum time in seconds a stream will live before connection is closed by the server. Nakadi's default value (at the time of writing): 0 Stream initialization will fail if streamTimeout is lower than batchFlushTimeout
      Throws:
      IllegalArgumentException
    • withCommitTimeout

      public StreamParameters withCommitTimeout(int commitTimeout)
      Maximum amount of seconds that Nakadi will be waiting for commit after sending a batch to a client. In case if commit does not come within this timeout, Nakadi will initialize stream termination, no new data will be sent. Partitions from this stream will be assigned to other streams. Setting commitTimeout to 0 is equal to setting it to the maximum allowed value: 60 seconds.
      Parameters:
      commitTimeout - Maximum amount of seconds that Nakadi will be waiting for commit after sending a batch to a client.
    • withStreamKeepAliveLimit

      public StreamParameters withStreamKeepAliveLimit(int streamKeepAliveLimit)
      Maximum number of empty keep alive batches to get in a row before closing the connection.
      Parameters:
      streamKeepAliveLimit - If 0 or undefined will send keep alive messages indefinitely. Nakadi's default value (at the time of writing): 0
    • withMaxUncommittedEvents

      public StreamParameters withMaxUncommittedEvents(int maxUncommittedEvents)
      The maximum number of uncommitted events that Nakadi will stream before pausing the stream. When in paused state and commit comes - the stream will resume.
      Parameters:
      maxUncommittedEvents - Nakadi's default value (at the time of writing): 10
    • withBatchTimespan

      public StreamParameters withBatchTimespan(int batchTimespan)
      Useful for batching events based on their received_at timestamp. Nakadi would flush a batch as soon as the difference in time between the first and the last event in the batch exceeds the batchTimespan.
      Parameters:
      batchTimespan - Nakadi's default (at the time of writing): 0, meaning "do not inspect timestamps".
    • getBatchLimit

      public Optional<Integer> getBatchLimit()
      Returns:
      Maximum number of events in each chunk (and therefore per partition) of the stream.
    • getStreamLimit

      public Optional<Integer> getStreamLimit()
      Returns:
      Maximum number of events in this stream (over all partitions being streamed in this connection).
    • getBatchFlushTimeout

      public Optional<Integer> getBatchFlushTimeout()
      Returns:
      Maximum time in seconds to wait for the flushing of each chunk (per partition).
    • getStreamTimeout

      public Optional<Integer> getStreamTimeout()
      Returns:
      Maximum time in seconds a stream will live before connection is closed by the server.
    • getStreamKeepAliveLimit

      public Optional<Integer> getStreamKeepAliveLimit()
      Returns:
      Maximum number of empty keep alive batches to get in a row before closing the connection.
    • getMaxUncommittedEvents

      public Optional<Integer> getMaxUncommittedEvents()
      Returns:
      The maximum number of uncommitted events that Nakadi will stream before pausing the stream.
    • getCommitTimeout

      public Optional<Integer> getCommitTimeout()
      Returns:
      Maximum amount of seconds that Nakadi will be waiting for commit after sending a batch to a client
    • getBatchTimespan

      public Optional<Integer> getBatchTimespan()
      Returns:
      Nakadi would flush a batch as soon as the difference in time between the first and the last event in the batch exceeds the batchTimespan.