Annotation Type RetryableTopic


  • @Target(METHOD)
    @Retention(RUNTIME)
    @Documented
    public @interface RetryableTopic
    Annotation to create the retry and dlt topics for a KafkaListener annotated listener. See RetryTopicConfigurer for usage examples.
    Since:
    2.7
    Author:
    Tomaz Fernandes, Gary Russell
    See Also:
    RetryTopicConfigurer
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      int attempts
      The number of attempts made before the message is sent to the DLT.
      boolean autoCreateTopics
      Whether or not the topic should be created after registration with the provided configurations.
      org.springframework.retry.annotation.Backoff backoff
      Specify the backoff properties for retrying this operation.
      DltStrategy dltStrategy  
      java.lang.String dltTopicSuffix
      The suffix that will be appended to the main topic in order to generate the dlt topic.
      java.lang.Class<? extends java.lang.Throwable>[] exclude
      The exceptions that should not be retried.
      FixedDelayStrategy fixedDelayTopicStrategy  
      java.lang.Class<? extends java.lang.Throwable>[] include
      The exceptions that should be retried.
      java.lang.String kafkaTemplate
      The bean name of the KafkaTemplate bean that will be used to forward the message to the retry and Dlt topics.
      java.lang.String listenerContainerFactory
      The bean name of the ConcurrentKafkaListenerContainerFactory that will be used to create the consumers for the retry and dlt topics.
      int numPartitions
      The number of partitions for the automatically created topics.
      short replicationFactor
      The replication factor for the automatically created topics.
      java.lang.String retryTopicSuffix
      The suffix that will be appended to the main topic in order to generate the retry topics.
      long timeout
      The amount of time in milliseconds after which message retrying should give up and send the message to the DLT.
      TopicSuffixingStrategy topicSuffixingStrategy
      The suffix that will be appended to the main topic in order to generate the dlt topic.
      boolean traversingCauses
      Whether or not the captured exception should be traversed to look for the exceptions provided above.
    • Element Detail

      • attempts

        int attempts
        The number of attempts made before the message is sent to the DLT.
        Returns:
        the number of attempts.
        Default:
        3
      • backoff

        org.springframework.retry.annotation.Backoff backoff
        Specify the backoff properties for retrying this operation. The default is a simple Backoff specification with no properties - see it's documentation for defaults.
        Returns:
        a backoff specification
        Default:
        @org.springframework.retry.annotation.Backoff
      • timeout

        long timeout
        The amount of time in milliseconds after which message retrying should give up and send the message to the DLT.
        Returns:
        the timeout value.
        Default:
        -1L
      • kafkaTemplate

        java.lang.String kafkaTemplate
        The bean name of the KafkaTemplate bean that will be used to forward the message to the retry and Dlt topics. If not specified, a bean with name retryTopicDefaultKafkaTemplate will be looked up.
        Returns:
        the kafkaTemplate bean name.
        Default:
        ""
      • listenerContainerFactory

        java.lang.String listenerContainerFactory
        The bean name of the ConcurrentKafkaListenerContainerFactory that will be used to create the consumers for the retry and dlt topics. If none is provided, the one from the KafkaListener annotation is used, or else a default one, if any.
        Returns:
        the listenerContainerFactory bean name.
        Default:
        ""
      • autoCreateTopics

        boolean autoCreateTopics
        Whether or not the topic 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 the KafkaConsumer.
        Returns:
        the configuration.
        Default:
        true
      • numPartitions

        int numPartitions
        The number of partitions for the automatically created topics.
        Returns:
        the number of partitions.
        Default:
        1
      • replicationFactor

        short replicationFactor
        The replication factor for the automatically created topics.
        Returns:
        the replication factor.
        Default:
        1
      • include

        java.lang.Class<? extends java.lang.Throwable>[] include
        The exceptions that should be retried.
        Returns:
        the exceptions.
        Default:
        {}
      • exclude

        java.lang.Class<? extends java.lang.Throwable>[] exclude
        The exceptions 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

        boolean traversingCauses
        Whether or not the captured exception should be traversed to look for the exceptions provided above.
        Returns:
        the value.
        Default:
        false
      • retryTopicSuffix

        java.lang.String retryTopicSuffix
        The 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

        java.lang.String dltTopicSuffix
        The suffix that will be appended to the main topic in order to generate the dlt topic.
        Returns:
        the dlt suffix.
        Default:
        "-dlt"
      • topicSuffixingStrategy

        TopicSuffixingStrategy topicSuffixingStrategy
        The suffix that will be appended to the main topic in order to generate the dlt topic.
        Returns:
        the dlt suffix.
        Default:
        org.springframework.kafka.retrytopic.TopicSuffixingStrategy.SUFFIX_WITH_DELAY_VALUE
      • dltStrategy

        DltStrategy dltStrategy
        Default:
        org.springframework.kafka.retrytopic.DltStrategy.ALWAYS_RETRY_ON_ERROR
      • fixedDelayTopicStrategy

        FixedDelayStrategy fixedDelayTopicStrategy
        Default:
        org.springframework.kafka.retrytopic.FixedDelayStrategy.MULTIPLE_TOPICS