Annotation Interface RetryableTopic
Annotation to create the retry and dlt topics for a
KafkaListener
annotated
listener. See RetryTopicConfigurer
for
usage examples. All String properties can be resolved from property placeholders
${...}
or SpEL expressions #{...}
.- Since:
- 2.7
- Author:
- Tomaz Fernandes, Gary Russell, Fabio da Silva Jr., João Lima
- See Also:
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionThe number of attempts made before the message is sent to the DLT.Whether or not the topics should be created after registration with the provided configurations.Override the container factory'sautoStartup
property for just the DLT container.org.springframework.retry.annotation.Backoff
Specify the backoff properties for retrying this operation.Concurrency for the retry and DLT containers; if not specified, the main container concurrency is used.Whether or not create a DLT, and redeliver to the DLT if delivery fails or just give up.The suffix that will be appended to the main topic in order to generate the dlt topic.The exception types that should not be retried.String[]
The exception class names that should not be retried.The exception types that should be retried.String[]
The exception class names that should be retried.The bean name of theKafkaTemplate
bean that will be used to forward the message to the retry and Dlt topics.The bean name of theConcurrentKafkaListenerContainerFactory
that will be used to create the consumers for the retry and dlt topics.The number of partitions for the automatically created topics.The replication factor for the automatically created topics.The suffix that will be appended to the main topic in order to generate the retry topics.Topic reuse strategy for sequential attempts made with a same backoff interval.The amount of time in milliseconds after which message retrying should give up and send the message to the DLT.Whether the retry topics will be suffixed with the delay value for that topic or a simple index.Whether or not the captured exception should be traversed to look for the exceptions provided above.
-
Element Details
-
attempts
String attemptsThe number of attempts made before the message is sent to the DLT. Expressions must resolve to an integer or a string that can be parsed as such. Default 3.- Returns:
- the number of attempts.
- Default:
- "3"
-
backoff
org.springframework.retry.annotation.Backoff backoffSpecify the backoff properties for retrying this operation. The default is a simpleBackoff
specification with no properties - see it's documentation for defaults.- Returns:
- a backoff specification
- Default:
- @org.springframework.retry.annotation.Backoff
-
timeout
String timeoutThe amount of time in milliseconds after which message retrying should give up and send the message to the DLT. Expressions must resolve to a long or a String that can be parsed as such.- Returns:
- the timeout value.
- Default:
- ""
-
kafkaTemplate
String kafkaTemplateThe bean name of theKafkaTemplate
bean that will be used to forward the message to the retry and Dlt topics. If not specified, a bean with nameretryTopicDefaultKafkaTemplate
orkafkaTemplate
will be looked up.- Returns:
- the kafkaTemplate bean name.
- Default:
- ""
-
listenerContainerFactory
String listenerContainerFactoryThe bean name of theConcurrentKafkaListenerContainerFactory
that will be used to create the consumers for the retry and dlt topics. If none is provided, the one from theKafkaListener
annotation is used, or else a default one, if any.- Returns:
- the listenerContainerFactory bean name.
- Default:
- ""
-
autoCreateTopics
String autoCreateTopicsWhether or not the topics should be created after registration with the provided configurations. Not to be confused with the ConsumerConfig.ALLOW_AUTO_CREATE_TOPICS_CONFIG from Kafka configuration, which is handled by theKafkaConsumer
. Expressions must resolve to a boolean or a String that can be parsed as such.- Returns:
- the configuration.
- Default:
- "true"
-
numPartitions
String numPartitionsThe number of partitions for the automatically created topics. Expressions must resolve to an integer or a String that can be parsed as such. Default 1.- Returns:
- the number of partitions.
- Default:
- "1"
-
replicationFactor
String replicationFactorThe replication factor for the automatically created topics. Expressions must resolve to a short or a String that can be parsed as such. Default is -1 to use the broker default if the broker is earlier than version 2.4, an explicit value is required.- Returns:
- the replication factor.
- Default:
- "-1"
-
include
The exception types that should be retried.- Returns:
- the exceptions.
- Default:
- {}
-
exclude
The exception types that should not be retried. When the message processing throws these exceptions the message goes straight to the DLT.- Returns:
- the exceptions not to be retried.
- Default:
- {}
-
includeNames
String[] includeNamesThe exception class names that should be retried.- Returns:
- the exceptions.
- Default:
- {}
-
excludeNames
String[] excludeNamesThe exception class names that should not be retried. When the message processing throws these exceptions the message goes straight to the DLT.- Returns:
- the exceptions not to be retried.
- Default:
- {}
-
traversingCauses
String traversingCausesWhether or not the captured exception should be traversed to look for the exceptions provided above. Expressions must resolve to a boolean or a String that can be parsed as such. Default true wheninclude()
orexclude()
provided; false otherwise.- Returns:
- the value.
- Default:
- ""
-
retryTopicSuffix
String retryTopicSuffixThe suffix that will be appended to the main topic in order to generate the retry topics. The corresponding delay value is also appended.- Returns:
- the retry topics' suffix.
- Default:
- "-retry"
-
dltTopicSuffix
String dltTopicSuffixThe suffix that will be appended to the main topic in order to generate the dlt topic.- Returns:
- the dlt suffix.
- Default:
- "-dlt"
-
topicSuffixingStrategy
TopicSuffixingStrategy topicSuffixingStrategyWhether the retry topics will be suffixed with the delay value for that topic or a simple index.- Returns:
- the strategy.
- Default:
- SUFFIX_WITH_DELAY_VALUE
-
sameIntervalTopicReuseStrategy
SameIntervalTopicReuseStrategy sameIntervalTopicReuseStrategyTopic reuse strategy for sequential attempts made with a same backoff interval.- Returns:
- the strategy.
- Since:
- 3.0.4
- Default:
- MULTIPLE_TOPICS
-
dltStrategy
DltStrategy dltStrategyWhether or not create a DLT, and redeliver to the DLT if delivery fails or just give up.- Returns:
- the dlt strategy.
- Default:
- ALWAYS_RETRY_ON_ERROR
-
autoStartDltHandler
String autoStartDltHandlerOverride the container factory'sautoStartup
property for just the DLT container. Usually used to not start the DLT container whenautoStartup
is true.- Returns:
- whether or not to override the factory.
- Since:
- 2.8
- Default:
- ""
-
concurrency
String concurrencyConcurrency for the retry and DLT containers; if not specified, the main container concurrency is used.- Returns:
- the concurrency.
- Since:
- 3.0
- Default:
- ""
-