Interface AfterRollbackProcessor<K,​V>

  • Type Parameters:
    K - the key type.
    V - the value type.
    All Known Implementing Classes:
    DefaultAfterRollbackProcessor
    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.
    Since:
    1.3.5
    Author:
    Gary Russell
    • Method Detail

      • process

        void process​(java.util.List<org.apache.kafka.clients.consumer.ConsumerRecord<K,​V>> records,
                     org.apache.kafka.clients.consumer.Consumer<K,​V> consumer,
                     MessageListenerContainer container,
                     java.lang.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 group.id 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.
        Parameters:
        records - the records.
        consumer - the consumer.
        container - the container.
        exception - the exception
        recoverable - the recoverable.
        eosMode - the ContainerProperties.EOSMode.
        Since:
        2.6.6
        See Also:
        isProcessInTransaction()
      • clearThreadState

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