public class ConditionalRejectingErrorHandler extends Object implements org.springframework.util.ErrorHandler
ErrorHandler
that conditionally wraps the Exception in an
AmqpRejectAndDontRequeueException
if the configured rejection
strategy determines that the message is fatal and should not be requeued.
Such messages will be discarded or sent to a Dead Letter Exchange, depending
on broker configuration.
The default strategy will do this if the exception is a
ListenerExecutionFailedException
with a cause of MessageConversionException
,
MessageConversionException
,
MethodArgumentNotValidException
, MethodArgumentTypeMismatchException
,
NoSuchMethodException
or ClassCastException
.
The exception will not be wrapped if the cause
chain already contains an
AmqpRejectAndDontRequeueException
.
Modifier and Type | Class and Description |
---|---|
static class |
ConditionalRejectingErrorHandler.DefaultExceptionStrategy
Default implementation of
FatalExceptionStrategy . |
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.logging.Log |
logger |
Constructor and Description |
---|
ConditionalRejectingErrorHandler()
Create a handler with the
ConditionalRejectingErrorHandler.DefaultExceptionStrategy . |
ConditionalRejectingErrorHandler(FatalExceptionStrategy exceptionStrategy)
Create a handler with the supplied
FatalExceptionStrategy implementation. |
public ConditionalRejectingErrorHandler()
ConditionalRejectingErrorHandler.DefaultExceptionStrategy
.public ConditionalRejectingErrorHandler(FatalExceptionStrategy exceptionStrategy)
FatalExceptionStrategy
implementation.exceptionStrategy
- The strategy implementation.public void handleError(Throwable t)
handleError
in interface org.springframework.util.ErrorHandler