Class ConsumerGroupBuilder<T>

java.lang.Object
org.acemq.amqp.core.ConsumerGroupBuilder<T>
Type Parameters:
T - payload type

public final class ConsumerGroupBuilder<T> extends Object
Says how many consumers to run and how much each may hold, and then starts them.

 ConsumerGroup orders = mq.consumeGroup("orders.new", Order.class, handler)
         .concurrency(4)
         .prefetch(50)
         .start();
 

Nothing consumes until start(). Every other method returns a new builder, so a half-built one can be kept as a field or reused.

  • Method Details

    • concurrency

      public ConsumerGroupBuilder<T> concurrency(int concurrency)
      Parameters:
      concurrency - how many consumers to run. More helps when handlers spend their time waiting on something else; it does nothing for a handler that is already CPU-bound
      Returns:
      a builder with that concurrency
    • prefetch

      public ConsumerGroupBuilder<T> prefetch(int prefetch)
      Parameters:
      prefetch - how many messages each consumer may hold unacknowledged
      Returns:
      a builder with that prefetch
    • options

      public ConsumerGroupBuilder<T> options(ConsumerOptions options)
      Parameters:
      options - everything else about how the consumers behave — retries, idempotency, the codec to read with
      Returns:
      a builder using them
    • start

      public ConsumerGroup start()
      Returns:
      the running group
    • toString

      public String toString()
      Overrides:
      toString in class Object