Interface AfterRollbackProcessor<K,V>

Type Parameters:
K - the key type.
V - the value type.
All Known Implementing Classes:
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 AfterRollbackProcessor<K,V>
Invoked by a listener container with remaining, unprocessed, records (including the failed record). Implementations should seek the desired topics/partitions so that records will be re-fetched on the next poll. When used with a batch listener, the entire batch of records is provided.
Gary Russell
  • Method Details

    • process

      void process(List<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>> records, org.apache.kafka.clients.consumer.Consumer<K,V> consumer, MessageListenerContainer container, Exception exception, boolean recoverable, ContainerProperties.EOSMode eosMode)
      Process the remaining records. Recoverable will be true if the container is processing individual records; this allows the processor to recover (skip) the failed record rather than re-seeking it. This is not possible with a batch listener since only the listener itself knows which record in the batch keeps failing. IMPORTANT: If invoked in a transaction when the listener was invoked with a single record, the transaction id will be based on the container and the topic/partition of the failed record, to avoid issues with zombie fencing. So, generally, only its offset should be sent to the transaction. For other behavior the process method should manage its own transaction.
      records - the records.
      consumer - the consumer.
      container - the container.
      exception - the exception
      recoverable - the recoverable.
      eosMode - the ContainerProperties.EOSMode.
      See Also:
    • clearThreadState

      default void clearThreadState()
      Optional method to clear thread state; will be called just before a consumer thread terminates.
    • isProcessInTransaction

      default boolean isProcessInTransaction()
      Return true to invoke process(List, Consumer, MessageListenerContainer, Exception, boolean, ContainerProperties.EOSMode) in a new transaction. Because the container cannot infer the desired behavior, the processor is responsible for sending the offset to the transaction if it decides to skip the failing record.
      true to run in a transaction; default false.
      See Also: