Annotation Interface ErrorStrategy


@Documented @Retention(RUNTIME) public @interface ErrorStrategy
Setting the error strategy allows you to resume at the next offset or to seek the consumer (stop on error) to the failed offset so that it can retry if an error occurs. The consumer bean is still able to implement a custom exception handler to replace DefaultKafkaListenerExceptionHandler as well as set the error strategy.
Since:
4.1
Author:
Christopher Webb, Vishal Sulibhavi, Denis Stepanov
  • Field Details

    • DEFAULT_DELAY_IN_SECONDS

      static final int DEFAULT_DELAY_IN_SECONDS
      Default retry delay in seconds.
      See Also:
    • DEFAULT_RETRY_COUNT

      static final int DEFAULT_RETRY_COUNT
      Default retry attempts.
      See Also:
    • DEFAULT_HANDLE_ALL_EXCEPTIONS

      static final boolean DEFAULT_HANDLE_ALL_EXCEPTIONS
      Default handle all exceptions.
      See Also:
  • Element Details

    • retryDelay

      String retryDelay
      The delay used with RETRY_ON_ERROR, RETRY_EXPONENTIALLY_ON_ERROR, RETRY_CONDITIONALLY_ON_ERROR and RETRY_CONDITIONALLY_EXPONENTIALLY_ON_ERROR ErrorStrategyValue.
      Returns:
      the delay by which to wait for the next retry
      Default:
      "1s"
    • retryCount

      int retryCount
      The fixed retry count used with RETRY_ON_ERROR and RETRY_EXPONENTIALLY_ON_ERROR, RETRY_CONDITIONALLY_ON_ERROR and RETRY_CONDITIONALLY_EXPONENTIALLY_ON_ERROR ErrorStrategyValue.

      retryCount takes precedence over retryCountValue if they are both set.

      Returns:
      the retry count of how many attempts should be made
      See Also:
      Default:
      1
    • retryCountValue

      @AliasFor(member="retryCount") String retryCountValue
      The dynamic retry count used with RETRY_ON_ERROR and RETRY_EXPONENTIALLY_ON_ERROR ErrorStrategyValue.

      retryCountValue will be overridden by retryCount if they are both set.

      Returns:
      the retry count of how many attempts should be made
      See Also:
      Default:
      ""
    • handleAllExceptions

      boolean handleAllExceptions
      Whether all exceptions should be handled or ignored when using RETRY_ON_ERROR and RETRY_EXPONENTIALLY_ON_ERROR ErrorStrategyValue. By default, only the last failed attempt will be handed over to the exception handler.
      Returns:
      whether all exceptions should be handled or ignored
      Since:
      5.0
      Default:
      false
    • stopOnExhaustedRetry

      boolean stopOnExhaustedRetry
      Whether Micronaut should pause the affected topic partitions after the last retryable failure instead of skipping past the failed record.

      When enabled, the consumer seeks back to the failed offset, handles the exception, and pauses the affected partitions until they are resumed through the ConsumerRegistry or the application is restarted.

      Returns:
      whether to stop consuming from the affected partitions after retries are exhausted
      Since:
      6.0
      Default:
      false
    • value

      The strategy to use when an error occurs, see ErrorStrategyValue.
      Returns:
      the error strategy
      Default:
      NONE
    • dlq

      String dlq
      The dead letter topic to publish failed records to when using ErrorStrategyValue.LOG_AND_RESUME_AT_NEXT_RECORD or ErrorStrategyValue.RETRY_TOPIC_ON_ERROR after retry topics are exhausted.
      Returns:
      The dead letter topic name
      Since:
      5.8
      Default:
      ""
    • retryTopicSuffixes

      String[] retryTopicSuffixes
      The suffixes used to derive retry topics from the original topic name when using ErrorStrategyValue.RETRY_TOPIC_ON_ERROR.

      For example, with an original topic orders and suffixes -retry-5s and -retry-30s, Micronaut will use the retry topics orders-retry-5s and orders-retry-30s.

      Returns:
      The retry topic suffixes
      Since:
      6.0.0
      Default:
      {}
    • retryTopicDelays

      String[] retryTopicDelays
      The delays to apply before consuming records from the retry topics declared in retryTopicSuffixes() when using ErrorStrategyValue.RETRY_TOPIC_ON_ERROR.

      The number of configured delays must match the number of configured retry topic suffixes.

      Returns:
      The retry topic delays
      Since:
      6.0.0
      Default:
      {}
    • exceptionTypes

      Class<? extends Throwable>[] exceptionTypes
      The types of exceptions to retry, used with RETRY_ON_ERROR and RETRY_EXPONENTIALLY_ON_ERROR, see ErrorStrategyValue. When used with RETRY_CONDITIONALLY_ON_ERROR and RETRY_CONDITIONALLY_EXPONENTIALLY_ON_ERROR, the skip behaviour will be overridden if the thrown exception is one of these types.
      Returns:
      the list of exceptions types
      Since:
      4.5.0
      Default:
      {}