K - the key type.V - the value type.public class DefaultAfterRollbackProcessor<K,V> extends FailedRecordProcessor implements AfterRollbackProcessor<K,V>, org.springframework.beans.factory.InitializingBean
AfterRollbackProcessor. Seeks all
topic/partitions so the records will be re-fetched, including the failed
record. Starting with version 2.2 after a configurable number of failures
for the same topic/partition/offset, that record will be skipped after
calling a BiConsumer recoverer. The default recoverer simply logs
the failed record.logger| Constructor and Description |
|---|
DefaultAfterRollbackProcessor()
Construct an instance with the default recoverer which simply logs the record after
(maxFailures) have occurred for a
topic/partition/offset.
|
DefaultAfterRollbackProcessor(org.springframework.util.backoff.BackOff backOff)
Construct an instance with the default recoverer which simply logs the record after
the backOff returns STOP for a topic/partition/offset.
|
DefaultAfterRollbackProcessor(java.util.function.BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>,java.lang.Exception> recoverer)
Construct an instance with the provided recoverer which will be called after
(maxFailures) have occurred for a
topic/partition/offset.
|
DefaultAfterRollbackProcessor(java.util.function.BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>,java.lang.Exception> recoverer,
org.springframework.util.backoff.BackOff backOff)
Construct an instance with the provided recoverer which will be called after
the backOff returns STOP for a topic/partition/offset.
|
DefaultAfterRollbackProcessor(java.util.function.BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>,java.lang.Exception> recoverer,
org.springframework.util.backoff.BackOff backOff,
KafkaOperations<?,?> kafkaOperations,
boolean commitRecovered)
Construct an instance with the provided recoverer which will be called after the
backOff returns STOP for a topic/partition/offset.
|
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
void |
clearThreadState()
Optional method to clear thread state; will be called just before a consumer
thread terminates.
|
boolean |
isProcessInTransaction()
Return true to invoke
AfterRollbackProcessor.process(List, Consumer, Exception, boolean, ContainerProperties.EOSMode)
in a new transaction. |
void |
process(java.util.List<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>> records,
org.apache.kafka.clients.consumer.Consumer<K,V> consumer,
java.lang.Exception exception,
boolean recoverable)
Deprecated.
|
void |
process(java.util.List<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>> records,
org.apache.kafka.clients.consumer.Consumer<K,V> consumer,
java.lang.Exception exception,
boolean recoverable,
ContainerProperties.EOSMode eosMode)
Process the remaining records.
|
void |
setCommitRecovered(boolean commitRecovered)
Deprecated.
|
void |
setKafkaOperations(KafkaOperations<K,V> kafkaOperations)
Deprecated.
|
void |
setKafkaTemplate(KafkaTemplate<K,V> kafkaTemplate)
Deprecated.
|
addNotRetryableException, deliveryAttempt, getClassifier, getSkipPredicate, isCommitRecovered, removeNotRetryableException, setClassifications, setResetStateOnRecoveryFailuregetLogLevel, setLogLevelpublic DefaultAfterRollbackProcessor()
public DefaultAfterRollbackProcessor(org.springframework.util.backoff.BackOff backOff)
backOff - the BackOff.public DefaultAfterRollbackProcessor(java.util.function.BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>,java.lang.Exception> recoverer)
recoverer - the recoverer.public DefaultAfterRollbackProcessor(@Nullable
java.util.function.BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>,java.lang.Exception> recoverer,
org.springframework.util.backoff.BackOff backOff)
recoverer - the recoverer; if null, the default (logging) recoverer is used.backOff - the BackOff.public DefaultAfterRollbackProcessor(@Nullable
java.util.function.BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>,java.lang.Exception> recoverer,
org.springframework.util.backoff.BackOff backOff,
@Nullable
KafkaOperations<?,?> kafkaOperations,
boolean commitRecovered)
recoverer - the recoverer; if null, the default (logging) recoverer is used.backOff - the BackOff.kafkaOperations - for sending the recovered offset to the transaction.commitRecovered - true to commit the recovered record's offset; requires a
KafkaOperations.public void afterPropertiesSet()
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean@Deprecated public void process(java.util.List<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>> records, org.apache.kafka.clients.consumer.Consumer<K,V> consumer, java.lang.Exception exception, boolean recoverable)
AfterRollbackProcessorprocess in interface AfterRollbackProcessor<K,V>records - the records.consumer - the consumer.exception - the exceptionrecoverable - the recoverable.AfterRollbackProcessor.isProcessInTransaction()public void process(java.util.List<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>> records, org.apache.kafka.clients.consumer.Consumer<K,V> consumer, java.lang.Exception exception, boolean recoverable, @Nullable ContainerProperties.EOSMode eosMode)
AfterRollbackProcessorContainerProperties.EOSMode is
ContainerProperties.EOSMode.BETA). So, generally, only its offset should be
sent to the transaction. For other behavior the process method should manage its
own transaction.process in interface AfterRollbackProcessor<K,V>records - the records.consumer - the consumer.exception - the exceptionrecoverable - the recoverable.eosMode - the ContainerProperties.EOSMode.AfterRollbackProcessor.isProcessInTransaction()public boolean isProcessInTransaction()
AfterRollbackProcessorAfterRollbackProcessor.process(List, Consumer, 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.isProcessInTransaction in interface AfterRollbackProcessor<K,V>AfterRollbackProcessor.process(List, Consumer, Exception, boolean, ContainerProperties.EOSMode)@Deprecated public void setCommitRecovered(boolean commitRecovered)
DefaultAfterRollbackProcessor(BiConsumer, BackOff, KafkaOperations, boolean).process(List, Consumer, Exception, boolean, ContainerProperties.EOSMode)
method in a transaction and, if a record is skipped and recovered, we will send its
offset to the transaction. Requires a KafkaOperations.setCommitRecovered in class FailedRecordProcessorcommitRecovered - true to process in a transaction.isProcessInTransaction(),
process(List, Consumer, Exception, boolean, ContainerProperties.EOSMode)@Deprecated public void setKafkaTemplate(KafkaTemplate<K,V> kafkaTemplate)
DefaultAfterRollbackProcessor(BiConsumer, BackOff, KafkaOperations, boolean).KafkaTemplate to use to send the offset of a recovered record to a
transaction.kafkaTemplate - the template.setCommitRecovered(boolean)@Deprecated public void setKafkaOperations(KafkaOperations<K,V> kafkaOperations)
DefaultAfterRollbackProcessor(BiConsumer, BackOff, KafkaOperations,
boolean).KafkaOperations to use to send the offset of a recovered record to a
transaction.kafkaOperations - the operations.setCommitRecovered(boolean)public void clearThreadState()
AfterRollbackProcessorclearThreadState in interface AfterRollbackProcessor<K,V>clearThreadState in class FailedRecordProcessor