Package org.springframework.amqp.core
Class QueueBuilder
java.lang.Object
org.springframework.amqp.core.AbstractBuilder
org.springframework.amqp.core.QueueBuilder
Builds a Spring AMQP Queue using a fluent API.
- Since:
- 1.6
- Author:
- Maciej Walkowiak, Gary Russell
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Locate the queue leader.static enum
Overflow argument values. -
Method Summary
Modifier and TypeMethodDescriptionThe final queue will auto delete.build()
Builds a final queue.deadLetterExchange
(String dlx) Set the dead-letter exchange to which to route expired or rejected messages.deadLetterRoutingKey
(String dlrk) Set the routing key to use when routing expired or rejected messages to the dead-letter exchange.deliveryLimit
(int limit) Set the delivery limit; only applies to quorum queues.static QueueBuilder
durable()
Creates a builder for a durable queue with a generated unique name -spring.gen-<random>
.static QueueBuilder
Creates a builder for a durable queue.The final queue will be exclusive.expires
(int expires) Set the time that the queue can remain unused before being deleted.lazy()
Set the queue into lazy mode, keeping as many messages as possible on disk to reduce RAM usage on the broker.leaderLocator
(QueueBuilder.LeaderLocator locator) Set the master locator mode which determines which node a queue master will be located on a cluster of nodes.maxLength
(long count) Set the number of (ready) messages allowed in the queue before it starts to drop them.maxLengthBytes
(int bytes) Set the total aggregate body size allowed in the queue before it starts to drop them.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.static QueueBuilder
Creates a builder for a non-durable (transient) queue.static QueueBuilder
nonDurable
(String name) Creates a builder for a non-durable (transient) queue.overflow
(QueueBuilder.Overflow overflow) Set the overflow mode when messages are dropped due to max messages or max message size is exceeded.quorum()
Set the queue argument to declare a queue of type 'quorum' instead of 'classic'.Set the 'x-single-active-consumer' queue argument.stream()
Set the queue argument to declare a queue of type 'stream' instead of 'classic'.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.withArgument
(String key, Object value) The final queue will contain argument used to declare a queue.withArguments
(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 Details
-
durable
Creates a builder for a durable queue with a generated unique name -spring.gen-<random>
.- Returns:
- the QueueBuilder instance.
-
nonDurable
Creates a builder for a non-durable (transient) queue.- Returns:
- the QueueBuilder instance.
-
durable
Creates a builder for a durable queue.- Parameters:
name
- the name of the queue.- Returns:
- the QueueBuilder instance.
-
nonDurable
Creates a builder for a non-durable (transient) queue.- Parameters:
name
- the name of the queue.- Returns:
- the QueueBuilder instance.
-
exclusive
The final queue will be exclusive.- Returns:
- the QueueBuilder instance.
-
autoDelete
The final queue will auto delete.- Returns:
- the QueueBuilder instance.
-
withArgument
The final queue will contain argument used to declare a queue.- Parameters:
key
- argument namevalue
- argument value- Returns:
- the QueueBuilder instance.
-
withArguments
The final queue will contain arguments used to declare a queue.- Parameters:
arguments
- the arguments map- Returns:
- the QueueBuilder instance.
-
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
Set the time that the queue can remain unused before being deleted.- Parameters:
expires
- the expiration (milliseconds).- Returns:
- the builder.
- Since:
- 2.2
-
maxLength
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
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
Set the overflow mode when messages are dropped due to max messages or max message size is exceeded.- Parameters:
overflow
-QueueBuilder.Overflow.dropHead
orQueueBuilder.Overflow.rejectPublish
.- Returns:
- the builder.
- Since:
- 2.2
-
deadLetterExchange
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
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
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
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
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
orMasterLocator#random
.- Returns:
- the builder.
- Since:
- 2.2
-
singleActiveConsumer
Set the 'x-single-active-consumer' queue argument.- Returns:
- the builder.
- Since:
- 2.2.2
-
quorum
Set the queue argument to declare a queue of type 'quorum' instead of 'classic'.- Returns:
- the builder.
- Since:
- 2.2.2
-
stream
Set the queue argument to declare a queue of type 'stream' instead of 'classic'.- Returns:
- the builder.
- Since:
- 2.4
-
deliveryLimit
Set the delivery limit; only applies to quorum queues.- Parameters:
limit
- the limit.- Returns:
- the builder.
- Since:
- 2.2.2
- See Also:
-
build
Builds a final queue.- Returns:
- the Queue instance.
-