Package org.apache.kafka.connect.source
Interface TransactionContext
public interface TransactionContext
Provided to source tasks to allow them to define their own producer transaction boundaries when
exactly-once support is enabled.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Requests a transaction abort after the next batch of records fromSourceTask.poll()
.void
abortTransaction
(SourceRecord record) Requests a transaction abort after a source record is processed.void
Request a transaction commit after the next batch of records fromSourceTask.poll()
is processed.void
commitTransaction
(SourceRecord record) Request a transaction commit after a source record is processed.
-
Method Details
-
commitTransaction
void commitTransaction()Request a transaction commit after the next batch of records fromSourceTask.poll()
is processed. -
commitTransaction
Request a transaction commit after a source record is processed. The source record will be the last record in the committed transaction.If a task requests that the last record in a batch that it returns from
SourceTask.poll()
be committed by invoking this method, and also requests that that same batch be aborted by invokingabortTransaction()
, the record-based operation (in this case, committing the transaction) will take precedence.- Parameters:
record
- the record to commit the transaction after; may not be null.
-
abortTransaction
void abortTransaction()Requests a transaction abort after the next batch of records fromSourceTask.poll()
. All of the records in that transaction will be discarded and will not appear in a committed transaction. However, offsets for that transaction will still be committed so than the records in that transaction are not reprocessed. If the data should instead be reprocessed, the task should not invoke this method and should instead throw an exception. -
abortTransaction
Requests a transaction abort after a source record is processed. The source record will be the last record in the aborted transaction. All of the records in that transaction will be discarded and will not appear in a committed transaction. However, offsets for that transaction will still be committed so that the records in that transaction are not reprocessed. If the data should be reprocessed, the task should not invoke this method and should instead throw an exception.If a task requests that the last record in a batch that it returns from
SourceTask.poll()
be aborted by invoking this method, and also requests that that same batch be committed by invokingcommitTransaction()
, the record-based operation (in this case, aborting the transaction) will take precedence.- Parameters:
record
- the record to abort the transaction after; may not be null.
-