Package org.springframework.amqp.core
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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classQueueBuilder.LeaderLocatorLocate the queue leader.static classQueueBuilder.MasterLocatorDeprecated.in favor ofQueueBuilder.LeaderLocator.static classQueueBuilder.OverflowOverflow argument values.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description QueueBuilderautoDelete()The final queue will auto delete.Queuebuild()Builds a final queue.QueueBuilderdeadLetterExchange(String dlx)Set the dead-letter exchange to which to route expired or rejected messages.QueueBuilderdeadLetterRoutingKey(String dlrk)Set the routing key to use when routing expired or rejected messages to the dead-letter exchange.QueueBuilderdeliveryLimit(int limit)Set the delivery limit; only applies to quorum queues.static QueueBuilderdurable()Creates a builder for a durable queue with a generated unique name -spring.gen-<random>.static QueueBuilderdurable(String name)Creates a builder for a durable queue.QueueBuilderexclusive()The final queue will be exclusive.QueueBuilderexpires(int expires)Set the time that the queue can remain unused before being deleted.QueueBuilderlazy()Set the queue into lazy mode, keeping as many messages as possible on disk to reduce RAM usage on the broker.QueueBuilderleaderLocator(QueueBuilder.LeaderLocator locator)Set the master locator mode which determines which node a queue master will be located on a cluster of nodes.QueueBuildermasterLocator(QueueBuilder.MasterLocator locator)Deprecated.in favor ofleaderLocator(LeaderLocator).QueueBuildermaxLength(int count)Set the number of (ready) messages allowed in the queue before it starts to drop them.QueueBuildermaxLengthBytes(int bytes)Set the total aggregate body size allowed in the queue before it starts to drop them.QueueBuildermaxPriority(int maxPriority)Set the maximum number if priority levels for the queue to support; if not set, the queue will not support message priorities.static QueueBuildernonDurable()Creates a builder for a non-durable (transient) queue.static QueueBuildernonDurable(String name)Creates a builder for a non-durable (transient) queue.QueueBuilderoverflow(QueueBuilder.Overflow overflow)Set the overflow mode when messages are dropped due to max messages or max message size is exceeded.QueueBuilderquorum()Set the queue argument to declare a queue of type 'quorum' instead of 'classic'.QueueBuildersingleActiveConsumer()Set the 'x-single-active-consumer' queue argument.QueueBuilderstream()Set the queue argument to declare a queue of type 'stream' instead of 'classic'.QueueBuilderttl(int ttl)Set the message time-to-live after which it will be discarded, or routed to the dead-letter-exchange, if so configured.QueueBuilderwithArgument(String key, Object value)The final queue will contain argument used to declare a queue.QueueBuilderwithArguments(Map<String,Object> arguments)The final queue will contain arguments used to declare a queue.-
Methods inherited from class org.springframework.amqp.core.AbstractBuilder
getArguments, getOrCreateArguments
-
-
-
-
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(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 namevalue- 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:
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
-
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.dropHeadorQueueBuilder.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(String)
-
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:
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
-
masterLocator
@Deprecated public QueueBuilder masterLocator(QueueBuilder.MasterLocator locator)
Deprecated.in favor ofleaderLocator(LeaderLocator).Set the master locator mode which determines which node a queue master will be located on a cluster of nodes.- Parameters:
locator-QueueBuilder.MasterLocator.minMasters,QueueBuilder.MasterLocator.clientLocalorQueueBuilder.MasterLocator.random.- 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-QueueBuilder.MasterLocator.minMasters,QueueBuilder.MasterLocator.clientLocalorQueueBuilder.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:
quorum()
-
build
public Queue build()
Builds a final queue.- Returns:
- the Queue instance.
-
-