Interface MessageDeliveryErrorHandler
-
- All Known Implementing Classes:
MessageDeliveryErrorHandler.AlwaysRetry,MessageDeliveryErrorHandler.StopRedeliveryOn
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface MessageDeliveryErrorHandler
Strategy for resolving which errors, experienced during Message delivery by theDurableQueueConsumer, should be instantly marked as a Poison-Message/Dead-Letter-Message or if we can attempt message redelivery according to the specifiedRedeliveryPolicy
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classMessageDeliveryErrorHandler.AlwaysRetrystatic classMessageDeliveryErrorHandler.StopRedeliveryOn
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static MessageDeliveryErrorHandleralwaysRetry()Create aMessageDeliveryErrorHandlerthat always retries no matter which exception occursstatic MessageDeliveryErrorHandlerBuilderbuilder()Create a new builder for a flexibleMessageDeliveryErrorHandlerwhich supports both alwaysRetryOnExceptions and stopRedeliveryOnExceptionsbooleanisPermanentError(QueuedMessage queuedMessage, Exception error)This method is called when theDurableQueueConsumerexperiences an exception during Message delivery.
The result of this method determines if the Message is instantly marked as a Poison-Message/Dead-Letter-Message or if we can attempt message redelivery according to the specifiedRedeliveryPolicystatic MessageDeliveryErrorHandlerstopRedeliveryOn(Class<? extends Exception>... exceptions)Create aMessageDeliveryErrorHandlerthat stops message redelivery in case message handling experiences an exception for in the array ofexceptions.
It will first attempt to match directly onExceptionclass, next it will attempt to match on hierarchy (i.e.static MessageDeliveryErrorHandlerstopRedeliveryOn(List<Class<? extends Exception>> exceptions)Create aMessageDeliveryErrorHandlerthat stops message redelivery in case message handling experiences an exception for in the list ofexceptions.
It will first attempt to match directly onExceptionclass, next it will attempt to match on hierarchy (i.e.
-
-
-
Method Detail
-
isPermanentError
boolean isPermanentError(QueuedMessage queuedMessage, Exception error)
This method is called when theDurableQueueConsumerexperiences an exception during Message delivery.
The result of this method determines if the Message is instantly marked as a Poison-Message/Dead-Letter-Message or if we can attempt message redelivery according to the specifiedRedeliveryPolicy- Parameters:
queuedMessage- the message that failed to be deliverederror- the error experienced- Returns:
- true if the error is a permanent error - in which case the message is instantly marked as an Poison-Message/Dead-Letter-Message,
otherwise false - in which case the message will be redelivered according to the specified
RedeliveryPolicy
-
alwaysRetry
static MessageDeliveryErrorHandler alwaysRetry()
Create aMessageDeliveryErrorHandlerthat always retries no matter which exception occurs- Returns:
- a
MessageDeliveryErrorHandlerthat always retries no matter which exception occurs
-
stopRedeliveryOn
static MessageDeliveryErrorHandler stopRedeliveryOn(Class<? extends Exception>... exceptions)
Create aMessageDeliveryErrorHandlerthat stops message redelivery in case message handling experiences an exception for in the array ofexceptions.
It will first attempt to match directly onExceptionclass, next it will attempt to match on hierarchy (i.e. a concrete error which is a subtype of anExceptionfound in theexceptionswill also match)- Parameters:
exceptions- the array of exceptions where message redelivery will be stopped and the Message will be instantly marked as an Poison-Message/Dead-Letter-Message or- Returns:
- a
MessageDeliveryErrorHandlerthat stops message redelivery in case message handling experiences an exception for in the list ofexceptions
-
stopRedeliveryOn
static MessageDeliveryErrorHandler stopRedeliveryOn(List<Class<? extends Exception>> exceptions)
Create aMessageDeliveryErrorHandlerthat stops message redelivery in case message handling experiences an exception for in the list ofexceptions.
It will first attempt to match directly onExceptionclass, next it will attempt to match on hierarchy (i.e. a concrete error which is a subtype of anExceptionfound in theexceptionswill also match)- Parameters:
exceptions- the list of exceptions where message redelivery will be stopped and the Message will be instantly marked as a Poison-Message/Dead-Letter-Message- Returns:
- a
MessageDeliveryErrorHandlerthat stops message redelivery in case message handling experiences an exception for in the list ofexceptions
-
builder
static MessageDeliveryErrorHandlerBuilder builder()
Create a new builder for a flexibleMessageDeliveryErrorHandlerwhich supports both alwaysRetryOnExceptions and stopRedeliveryOnExceptions- Returns:
- the builder instance
-
-