Annotation 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
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionThe types of exceptions to retry, used with RETRY_ON_ERROR and RETRY_EXPONENTIALLY_ON_ERROR, seeErrorStrategyValue
.boolean
Whether all exceptions should be handled or ignored when using RETRY_ON_ERROR and RETRY_EXPONENTIALLY_ON_ERRORErrorStrategyValue
.int
The fixed retry count used with RETRY_ON_ERROR and RETRY_EXPONENTIALLY_ON_ERROR, RETRY_CONDITIONALLY_ON_ERROR and RETRY_CONDITIONALLY_EXPONENTIALLY_ON_ERRORErrorStrategyValue
.The dynamic retry count used with RETRY_ON_ERROR and RETRY_EXPONENTIALLY_ON_ERRORErrorStrategyValue
.The delay used with RETRY_ON_ERROR, RETRY_EXPONENTIALLY_ON_ERROR, RETRY_CONDITIONALLY_ON_ERROR and RETRY_CONDITIONALLY_EXPONENTIALLY_ON_ERRORErrorStrategyValue
.The strategy to use when an error occurs, seeErrorStrategyValue
. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Default retry delay in seconds.static final boolean
Default handle all exceptions.static final int
Default retry attempts.
-
Field Details
-
DEFAULT_DELAY_IN_SECONDS
static final int DEFAULT_DELAY_IN_SECONDSDefault retry delay in seconds.- See Also:
-
DEFAULT_RETRY_COUNT
static final int DEFAULT_RETRY_COUNTDefault retry attempts.- See Also:
-
DEFAULT_HANDLE_ALL_EXCEPTIONS
static final boolean DEFAULT_HANDLE_ALL_EXCEPTIONSDefault handle all exceptions.- See Also:
-
-
Element Details
-
retryDelay
String retryDelayThe delay used with RETRY_ON_ERROR, RETRY_EXPONENTIALLY_ON_ERROR, RETRY_CONDITIONALLY_ON_ERROR and RETRY_CONDITIONALLY_EXPONENTIALLY_ON_ERRORErrorStrategyValue
.- Returns:
- the delay by which to wait for the next retry
- Default:
- "1s"
-
retryCount
int retryCountThe fixed retry count used with RETRY_ON_ERROR and RETRY_EXPONENTIALLY_ON_ERROR, RETRY_CONDITIONALLY_ON_ERROR and RETRY_CONDITIONALLY_EXPONENTIALLY_ON_ERRORErrorStrategyValue
.retryCount
takes precedence overretryCountValue
if they are both set.- Returns:
- the retry count of how many attempts should be made
- See Also:
- Default:
- 1
-
retryCountValue
The dynamic retry count used with RETRY_ON_ERROR and RETRY_EXPONENTIALLY_ON_ERRORErrorStrategyValue
.retryCountValue
will be overridden byretryCount
if they are both set.- Returns:
- the retry count of how many attempts should be made
- See Also:
- Default:
- ""
-
handleAllExceptions
boolean handleAllExceptionsWhether all exceptions should be handled or ignored when using RETRY_ON_ERROR and RETRY_EXPONENTIALLY_ON_ERRORErrorStrategyValue
. 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
-
value
ErrorStrategyValue valueThe strategy to use when an error occurs, seeErrorStrategyValue
.- Returns:
- the error strategy
- Default:
- NONE
-
exceptionTypes
The types of exceptions to retry, used with RETRY_ON_ERROR and RETRY_EXPONENTIALLY_ON_ERROR, seeErrorStrategyValue
. 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:
- {}
-