Interface MessageDeliveryErrorHandler
- All Known Implementing Classes:
MessageDeliveryErrorHandler.AlwaysRetry,MessageDeliveryErrorHandler.NeverRetry,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.
Strategy for resolving which errors, experienced during Message delivery by the
DurableQueueConsumer,
should be instantly marked as a Poison-Message/Dead-Letter-Message or
if we can attempt message redelivery according to the specified RedeliveryPolicy-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classstatic classstatic class -
Method Summary
Modifier and TypeMethodDescriptionstatic MessageDeliveryErrorHandlerCreate aMessageDeliveryErrorHandlerthat always retries no matter which exception occursbuilder()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 Details
-
isPermanentError
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
Create aMessageDeliveryErrorHandlerthat always retries no matter which exception occurs- Returns:
- a
MessageDeliveryErrorHandlerthat always retries no matter which exception occurs
-
stopRedeliveryOn
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
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
Create a new builder for a flexibleMessageDeliveryErrorHandlerwhich supports both alwaysRetryOnExceptions and stopRedeliveryOnExceptions- Returns:
- the builder instance
-