Class QueueBuilder

java.lang.Object
org.springframework.amqp.core.AbstractBuilder
org.springframework.amqp.core.QueueBuilder

public final class QueueBuilder extends AbstractBuilder
Builds a Spring AMQP Queue using a fluent API.
Since:
1.6
Author:
Maciej Walkowiak, Gary Russell
  • Method Details

    • durable

      public static QueueBuilder durable()
      Creates a builder for a durable queue with a generated unique name - spring.gen-<random>.
      Returns:
      the QueueBuilder instance.
    • nonDurable

      public static QueueBuilder nonDurable()
      Creates a builder for a non-durable (transient) queue.
      Returns:
      the QueueBuilder instance.
    • durable

      public static QueueBuilder durable(String name)
      Creates a builder for a durable queue.
      Parameters:
      name - the name of the queue.
      Returns:
      the QueueBuilder instance.
    • nonDurable

      public static QueueBuilder nonDurable(String name)
      Creates a builder for a non-durable (transient) queue.
      Parameters:
      name - the name of the queue.
      Returns:
      the QueueBuilder instance.
    • exclusive

      public QueueBuilder exclusive()
      The final queue will be exclusive.
      Returns:
      the QueueBuilder instance.
    • autoDelete

      public QueueBuilder autoDelete()
      The final queue will auto delete.
      Returns:
      the QueueBuilder instance.
    • withArgument

      public QueueBuilder withArgument(String key, Object value)
      The final queue will contain argument used to declare a queue.
      Parameters:
      key - argument name
      value - argument value
      Returns:
      the QueueBuilder instance.
    • withArguments

      public QueueBuilder withArguments(Map<String,Object> arguments)
      The final queue will contain arguments used to declare a queue.
      Parameters:
      arguments - the arguments map
      Returns:
      the QueueBuilder instance.
    • ttl

      public QueueBuilder ttl(int ttl)
      Set the message time-to-live after which it will be discarded, or routed to the dead-letter-exchange, if so configured.
      Parameters:
      ttl - the time to live (milliseconds).
      Returns:
      the builder.
      Since:
      2.2
      See Also:
    • expires

      public QueueBuilder expires(int expires)
      Set the time that the queue can remain unused before being deleted.
      Parameters:
      expires - the expiration (milliseconds).
      Returns:
      the builder.
      Since:
      2.2
    • maxLength

      public QueueBuilder maxLength(long count)
      Set the number of (ready) messages allowed in the queue before it starts to drop them.
      Parameters:
      count - the number of (ready) messages allowed.
      Returns:
      the builder.
      Since:
      3.1
      See Also:
    • maxLengthBytes

      public QueueBuilder maxLengthBytes(int bytes)
      Set the total aggregate body size allowed in the queue before it starts to drop them.
      Parameters:
      bytes - the total aggregate body size.
      Returns:
      the builder.
      Since:
      2.2
    • overflow

      public QueueBuilder overflow(QueueBuilder.Overflow overflow)
      Set the overflow mode when messages are dropped due to max messages or max message size is exceeded.
      Parameters:
      overflow - QueueBuilder.Overflow.dropHead or QueueBuilder.Overflow.rejectPublish.
      Returns:
      the builder.
      Since:
      2.2
    • deadLetterExchange

      public QueueBuilder deadLetterExchange(String dlx)
      Set the dead-letter exchange to which to route expired or rejected messages.
      Parameters:
      dlx - the dead-letter exchange.
      Returns:
      the builder.
      Since:
      2.2
      See Also:
    • deadLetterRoutingKey

      public QueueBuilder deadLetterRoutingKey(String dlrk)
      Set the routing key to use when routing expired or rejected messages to the dead-letter exchange.
      Parameters:
      dlrk - the dead-letter routing key.
      Returns:
      the builder.
      Since:
      2.2
      See Also:
    • maxPriority

      public QueueBuilder maxPriority(int maxPriority)
      Set the maximum number if priority levels for the queue to support; if not set, the queue will not support message priorities.
      Parameters:
      maxPriority - the maximum priority.
      Returns:
      the builder.
      Since:
      2.2
    • lazy

      public QueueBuilder lazy()
      Set the queue into lazy mode, keeping as many messages as possible on disk to reduce RAM usage on the broker. if not set, the queue will keep an in-memory cache to deliver messages as fast as possible.
      Returns:
      the builder.
      Since:
      2.2
    • leaderLocator

      public QueueBuilder leaderLocator(QueueBuilder.LeaderLocator locator)
      Set the master locator mode which determines which node a queue master will be located on a cluster of nodes.
      Parameters:
      locator - MasterLocator#minMasters, MasterLocator#clientLocal or MasterLocator#random.
      Returns:
      the builder.
      Since:
      2.2
    • singleActiveConsumer

      public QueueBuilder singleActiveConsumer()
      Set the 'x-single-active-consumer' queue argument.
      Returns:
      the builder.
      Since:
      2.2.2
    • quorum

      public QueueBuilder quorum()
      Set the queue argument to declare a queue of type 'quorum' instead of 'classic'.
      Returns:
      the builder.
      Since:
      2.2.2
    • stream

      public QueueBuilder stream()
      Set the queue argument to declare a queue of type 'stream' instead of 'classic'.
      Returns:
      the builder.
      Since:
      2.4
    • deliveryLimit

      public QueueBuilder deliveryLimit(int limit)
      Set the delivery limit; only applies to quorum queues.
      Parameters:
      limit - the limit.
      Returns:
      the builder.
      Since:
      2.2.2
      See Also:
    • build

      public Queue build()
      Builds a final queue.
      Returns:
      the Queue instance.