Interface PulsarConsumerErrorHandler<T>

Type Parameters:
T - payload type managed by the consumer
All Known Implementing Classes:
DefaultPulsarConsumerErrorHandler

public interface PulsarConsumerErrorHandler<T>
Contract for consumer error handling through the message listener container. Both record and batch message listener errors are handled through this interface. When an error handler implementation is provided to the message listener container, the container will funnel all errors through it for handling.
Author:
Soby Chacko
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clear the message in error from managing (such as resetting any thread state etc.).
    org.apache.pulsar.client.api.Message<T>
    Returns the current message in error.
    void
    recoverMessage(org.apache.pulsar.client.api.Consumer<T> consumer, org.apache.pulsar.client.api.Message<T> message, Exception thrownException)
    Recover the message based on the implementation provided.
    boolean
    shouldRetryMessage(Exception exception, org.apache.pulsar.client.api.Message<T> message)
    Decide if the failed message should be retried.
  • Method Details

    • shouldRetryMessage

      boolean shouldRetryMessage(Exception exception, org.apache.pulsar.client.api.Message<T> message)
      Decide if the failed message should be retried.
      Parameters:
      exception - throws exception
      message - Pulsar message
      Returns:
      if the failed message should be retried or not
    • recoverMessage

      void recoverMessage(org.apache.pulsar.client.api.Consumer<T> consumer, org.apache.pulsar.client.api.Message<T> message, Exception thrownException)
      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.
      Parameters:
      consumer - Pulsar consumer
      message - Pulsar message
      thrownException - thrown exception
    • currentMessage

      org.apache.pulsar.client.api.Message<T> currentMessage()
      Returns the current message in error.
      Returns:
      the Pulsar Message currently tracked by the error handler
    • clearMessage

      void clearMessage()
      Clear the message in error from managing (such as resetting any thread state etc.).