Interface ConsumerBuilder


public interface ConsumerBuilder
API to configure and create a Consumer.
  • Method Details

    • stream

      ConsumerBuilder stream(String stream)
      The stream to consume from.
      Parameters:
      stream -
      Returns:
      this builder instance
    • superStream

      ConsumerBuilder superStream(String superStream)
      Set the consumer to consume from a super stream (partitioned stream).

      This is meant to be used with singleActiveConsumer().

      This is an experimental API, subject to change.

      RabbitMQ 3.11 or more is required.

      Parameters:
      superStream -
      Returns:
      this builder instance
      See Also:
    • offset

      ConsumerBuilder offset(OffsetSpecification offsetSpecification)
      The offset to start consuming from.

      The default is OffsetSpecification.next() (the end of the stream).

      Parameters:
      offsetSpecification -
      Returns:
      this builder instance
    • messageHandler

      ConsumerBuilder messageHandler(MessageHandler messageHandler)
      The callback for inbound messages.
      Parameters:
      messageHandler -
      Returns:
      this builder instance
    • name

      ConsumerBuilder name(String name)
      The logical name of the Consumer.

      Set a logical name to enable offset tracking.

      Parameters:
      name -
      Returns:
      this builder instance
    • singleActiveConsumer

      ConsumerBuilder singleActiveConsumer()
      Declare the consumer as a single active consumer.

      A single active consumer must set up a name with name(String).

      Instances of the same application can declare several single active consumer instances with the same name and only one will be active at a time, meaning it will be the only one to get messages from the broker.

      If the active consumer instance stops or crashes, the broker will choose a new active instance among the remaining ones.

      This is an experimental API, subject to change.

      RabbitMQ 3.11 or more is required.

      Returns:
      this builder instance
      Since:
      0.6.0
      See Also:
    • consumerUpdateListener

      ConsumerBuilder consumerUpdateListener(ConsumerUpdateListener consumerUpdateListener)
      Set the listener for single active consumer updates.

      This listener is usually set when manual offset tracking is used, either server-side or with an external datastore.

      This is an experimental API, subject to change.

      RabbitMQ 3.11 or more is required.

      Parameters:
      consumerUpdateListener -
      Returns:
      this builder instance
      Since:
      0.6.0
      See Also:
    • subscriptionListener

      ConsumerBuilder subscriptionListener(SubscriptionListener subscriptionListener)
      Callback on subscription.

      Can be used to set the offset specification before subscribing to the stream.

      This is an experimental API, subject to change.

      Parameters:
      subscriptionListener - the listener
      Returns:
      this builder instance
      Since:
      0.5.0
      See Also:
    • manualTrackingStrategy

      ConsumerBuilder.ManualTrackingStrategy manualTrackingStrategy()
      Returns:
      the manual tracking strategy
    • autoTrackingStrategy

      ConsumerBuilder.AutoTrackingStrategy autoTrackingStrategy()
      Enable ConsumerBuilder.AutoTrackingStrategy.

      This is the default tracking strategy.

      Returns:
      the auto-tracking strategy
    • noTrackingStrategy

      ConsumerBuilder noTrackingStrategy()
      Disable server-side offset tracking.

      Useful when singleActiveConsumer() is enabled and an external store is used for offset tracking. This avoids automatic server-side offset tracking to kick in.

      Returns:
      this builder instance
      Since:
      0.6.0
    • filter

      Configure the filtering.

      RabbitMQ 3.13 or more is required.

      Returns:
      the filtering configuration
    • flow

      Configure flow of messages.
      Returns:
      the flow configuration
      Since:
      0.11.0
      See Also:
    • build

      Consumer build()
      Create the configured Consumer
      Returns:
      the configured consumer