Interface KafkaListenerErrorHandler

  • All Known Subinterfaces:
    ConsumerAwareListenerErrorHandler, ManualAckListenerErrorHandler
    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 KafkaListenerErrorHandler
    An error handler which is called when a @KafkaListener method throws an exception. This is invoked higher up the stack than the listener container's error handler. For methods annotated with @SendTo, the error handler can return a result.
    Since:
    1.3
    Author:
    Venil Noronha, Gary Russell, Artem Bilan
    • Method Detail

      • handleError

        java.lang.Object handleError​(org.springframework.messaging.Message<?> message,
                                     ListenerExecutionFailedException exception)
        Handle the error.
        Parameters:
        message - the spring-messaging message.
        exception - the exception the listener threw, wrapped in a ListenerExecutionFailedException.
        Returns:
        the return value is ignored unless the annotated method has a @SendTo annotation.
      • handleError

        default java.lang.Object handleError​(org.springframework.messaging.Message<?> message,
                                             ListenerExecutionFailedException exception,
                                             org.apache.kafka.clients.consumer.Consumer<?,​?> consumer)
        Handle the error.
        Parameters:
        message - the spring-messaging message.
        exception - the exception the listener threw, wrapped in a ListenerExecutionFailedException.
        consumer - the consumer.
        Returns:
        the return value is ignored unless the annotated method has a @SendTo annotation.
      • handleError

        default java.lang.Object handleError​(org.springframework.messaging.Message<?> message,
                                             ListenerExecutionFailedException exception,
                                             org.apache.kafka.clients.consumer.Consumer<?,​?> consumer,
                                             @Nullable
                                             Acknowledgment ack)
        Handle the error.
        Parameters:
        message - the spring-messaging message.
        exception - the exception the listener threw, wrapped in a ListenerExecutionFailedException.
        consumer - the consumer.
        ack - the Acknowledgment.
        Returns:
        the return value is ignored unless the annotated method has a @SendTo annotation.