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.

@FunctionalInterface public interface MessageDeliveryErrorHandler
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
  • Method Details

    • isPermanentError

      boolean isPermanentError(QueuedMessage queuedMessage, Exception error)
      This method is called when the DurableQueueConsumer experiences 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 specified RedeliveryPolicy
      Parameters:
      queuedMessage - the message that failed to be delivered
      error - 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 a MessageDeliveryErrorHandler that always retries no matter which exception occurs
      Returns:
      a MessageDeliveryErrorHandler that always retries no matter which exception occurs
    • stopRedeliveryOn

      static MessageDeliveryErrorHandler stopRedeliveryOn(Class<? extends Exception>... exceptions)
      Create a MessageDeliveryErrorHandler that stops message redelivery in case message handling experiences an exception for in the array of exceptions.
      It will first attempt to match directly on Exception class, next it will attempt to match on hierarchy (i.e. a concrete error which is a subtype of an Exception found in the exceptions will 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 MessageDeliveryErrorHandler that stops message redelivery in case message handling experiences an exception for in the list of exceptions
    • stopRedeliveryOn

      static MessageDeliveryErrorHandler stopRedeliveryOn(List<Class<? extends Exception>> exceptions)
      Create a MessageDeliveryErrorHandler that stops message redelivery in case message handling experiences an exception for in the list of exceptions.
      It will first attempt to match directly on Exception class, next it will attempt to match on hierarchy (i.e. a concrete error which is a subtype of an Exception found in the exceptions will 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 MessageDeliveryErrorHandler that stops message redelivery in case message handling experiences an exception for in the list of exceptions
    • builder

      Create a new builder for a flexible MessageDeliveryErrorHandler which supports both alwaysRetryOnExceptions and stopRedeliveryOnExceptions
      Returns:
      the builder instance