Add Retry Config: Template and Listener
Also add requeue rejected to listener config and timeouts to RabbitTemplate config. Closes gh-5340
This commit is contained in:
committed by
Stephane Nicoll
parent
f4bb9e3ba7
commit
08732fe4c8
@@ -768,8 +768,15 @@ content into your application; rather pick only the properties that you need.
|
||||
spring.rabbitmq.listener.acknowledge-mode= # Acknowledge mode of container.
|
||||
spring.rabbitmq.listener.auto-startup=true # Start the container automatically on startup.
|
||||
spring.rabbitmq.listener.concurrency= # Minimum number of consumers.
|
||||
spring.rabbitmq.listener.default-requeue-rejected= # Whether or not to requeue delivery failures; default `true`.
|
||||
spring.rabbitmq.listener.max-concurrency= # Maximum number of consumers.
|
||||
spring.rabbitmq.listener.prefetch= # Number of messages to be handled in a single request. It should be greater than or equal to the transaction size (if used).
|
||||
spring.rabbitmq.listener.retry.enable= # Set to true to enable stateless retries for listener containers.
|
||||
spring.rabbitmq.listener.retry.initial-interval=1000 # The interval between the first and second attempt to deliver a message.
|
||||
spring.rabbitmq.listener.retry.max-attempts=3 # The maximum number of attempts to deliver a message.
|
||||
spring.rabbitmq.listener.retry.max-interval=10000 # The maximum number of attempts to deliver a message.
|
||||
spring.rabbitmq.listener.retry.multiplier=1.0 # A multiplier to apply to the previous delivery retry interval.
|
||||
spring.rabbitmq.listener.retry.stateless=true # Whether or not retry is stateless or stateful.
|
||||
spring.rabbitmq.listener.transaction-size= # Number of messages to be processed in a transaction. For best results it should be less than or equal to the prefetch count.
|
||||
spring.rabbitmq.password= # Login to authenticate against the broker.
|
||||
spring.rabbitmq.port=5672 # RabbitMQ port.
|
||||
@@ -779,6 +786,13 @@ content into your application; rather pick only the properties that you need.
|
||||
spring.rabbitmq.ssl.key-store-password= # Password used to access the key store.
|
||||
spring.rabbitmq.ssl.trust-store= # Trust store that holds SSL certificates.
|
||||
spring.rabbitmq.ssl.trust-store-password= # Password used to access the trust store.
|
||||
spring.rabbitmq.template.receiveTimeout=0 # Timeout for `receive()` methods.
|
||||
spring.rabbitmq.template.replyTimeout=5000 # Timeout for `sendAndReceive()` methods.
|
||||
spring.rabbitmq.template.retry.enable= # Set to true to enable retries in the `RabbitTemplate`.
|
||||
spring.rabbitmq.template.retry.initial-interval=1000 # The interval between the first and second attempt to publish a message.
|
||||
spring.rabbitmq.template.retry.max-attempts=3 # The maximum number of attempts to publish a message.
|
||||
spring.rabbitmq.template.retry.max-interval=10000 # The maximum number of attempts to publish a message.
|
||||
spring.rabbitmq.template.retry.multiplier=1.0 # A multiplier to apply to the previous publishing retry interval.
|
||||
spring.rabbitmq.username= # Login user to authenticate to the broker.
|
||||
spring.rabbitmq.virtual-host= # Virtual host to use when connecting to the broker.
|
||||
|
||||
|
||||
@@ -3801,7 +3801,9 @@ automatically to the auto-configured `AmqpTemplate`.
|
||||
Any `org.springframework.amqp.core.Queue` that is defined as a bean will be automatically
|
||||
used to declare a corresponding queue on the RabbitMQ instance if necessary.
|
||||
|
||||
|
||||
You can enable retries on the `AmqpTemplate` to retry operations, for example in the event the broker connection is
|
||||
lost.
|
||||
Retries are disabled by default.
|
||||
|
||||
[[boot-features-using-amqp-receiving]]
|
||||
==== Receiving a message
|
||||
@@ -3868,6 +3870,16 @@ That you can use in any `@RabbitListener`-annotated method as follows:
|
||||
}
|
||||
----
|
||||
|
||||
You can enable retries to handle situations where your listener throws an exception.
|
||||
When retries are exhausted, the message will be rejected and either dropped or routed to a dead-letter exchange
|
||||
if the broker is so configured.
|
||||
Retries are disabled by default.
|
||||
|
||||
IMPORTANT: If retries are not enabled and the listener throws an exception, by default the delivery will be retried
|
||||
indefinitely.
|
||||
You can modify this behavior in two ways; set the `defaultRequeueRejected` property to `false` and zero redeliveries
|
||||
will be attempted; or, throw an `AmqpRejectAndDontRequeueException` to signal the message should be rejected.
|
||||
This is the mechanism used when retries are enabled and the maximum delivery attempts is reached.
|
||||
|
||||
[[boot-features-email]]
|
||||
== Sending email
|
||||
|
||||
Reference in New Issue
Block a user