Class DefaultPulsarConsumerErrorHandler<T>

java.lang.Object
org.springframework.pulsar.listener.DefaultPulsarConsumerErrorHandler<T>
Type Parameters:
T - payload type managed by the Pulsar consumer
All Implemented Interfaces:
PulsarConsumerErrorHandler<T>

public class DefaultPulsarConsumerErrorHandler<T> extends Object implements PulsarConsumerErrorHandler<T>
Default implementation for PulsarConsumerErrorHandler.

This implementation is capable for handling errors based on the interface contract. After handling the errors, if necessary, this implementation is capable of recovering the record(s) using a PulsarMessageRecoverer Note: This implementation uses a ThreadLocal to manage the current message in error and it's associated BackOffExecution.

Author:
Soby Chacko
  • Constructor Details

  • Method Details

    • shouldRetryMessage

      public boolean shouldRetryMessage(Exception exception, org.apache.pulsar.client.api.Message<T> message)
      Description copied from interface: PulsarConsumerErrorHandler
      Decide if the failed message should be retried.
      Specified by:
      shouldRetryMessage in interface PulsarConsumerErrorHandler<T>
      Parameters:
      exception - throws exception
      message - Pulsar message
      Returns:
      if the failed message should be retried or not
    • recoverMessage

      public void recoverMessage(org.apache.pulsar.client.api.Consumer<T> consumer, org.apache.pulsar.client.api.Message<T> message, Exception exception)
      Description copied from interface: PulsarConsumerErrorHandler
      Recover the message based on the implementation provided. Once this method returns, callers can assume that the message is recovered and has not been acknowledged yet.
      Specified by:
      recoverMessage in interface PulsarConsumerErrorHandler<T>
      Parameters:
      consumer - Pulsar consumer
      message - Pulsar message
      exception - thrown exception
    • currentMessage

      public org.apache.pulsar.client.api.Message<T> currentMessage()
      Description copied from interface: PulsarConsumerErrorHandler
      Returns the current message in error.
      Specified by:
      currentMessage in interface PulsarConsumerErrorHandler<T>
      Returns:
      the Pulsar Message currently tracked by the error handler
    • clearMessage

      public void clearMessage()
      Description copied from interface: PulsarConsumerErrorHandler
      Clear the message in error from managing (such as resetting any thread state etc.).
      Specified by:
      clearMessage in interface PulsarConsumerErrorHandler<T>