Class 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 Detail

      • 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​(java.lang.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​(java.lang.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​(java.lang.String key,
                                         java.lang.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​(java.util.Map<java.lang.String,​java.lang.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:
        deadLetterExchange(String)
      • 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​(int 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:
        2.2
        See Also:
        overflow(Overflow)
      • 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
      • deadLetterExchange

        public QueueBuilder deadLetterExchange​(java.lang.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(String)
      • deadLetterRoutingKey

        public QueueBuilder deadLetterRoutingKey​(java.lang.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:
        deadLetterExchange(String)
      • 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
      • 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:
        quorum()
      • build

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