Package io.debezium.pipeline.txmetadata
Class TransactionMonitor
- java.lang.Object
-
- io.debezium.pipeline.txmetadata.TransactionMonitor
-
@NotThreadSafe public class TransactionMonitor extends Object
The class has externalized its state inTransactionContext
context class so it can be stored in and recovered from offsets. The class receives all processed events and keeps the transaction tracking depending on transaction id. Upon transaction change the metadata events are delivered to a dedicated topic informing aboutSTART/END
of the transaction, including transaction id and in case ofEND
event the amount of events generated by the transaction.Every event seen has its
source
block enriched to contain- transaction id
- the total event order in the transaction
- the order of event per table/collection source in the transaction
- Author:
- Jiri Pechanec
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description TransactionMonitor(CommonConnectorConfig connectorConfig, EventMetadataProvider eventMetadataProvider, BlockingConsumer<org.apache.kafka.connect.source.SourceRecord> sender)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
beginTransaction(Partition partition, OffsetContext offsetContext)
void
dataEvent(Partition partition, DataCollectionId source, OffsetContext offset, Object key, org.apache.kafka.connect.data.Struct value)
private void
endTransaction(Partition partition, OffsetContext offsetContext)
void
transactionComittedEvent(Partition partition, OffsetContext offset)
private void
transactionEvent(OffsetContext offsetContext, DataCollectionId source, org.apache.kafka.connect.data.Struct value)
void
transactionStartedEvent(Partition partition, String transactionId, OffsetContext offset)
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
schemaNameAdjuster
private static final SchemaNameAdjuster schemaNameAdjuster
-
TOPIC_SUFFIX
private static final String TOPIC_SUFFIX
- See Also:
- Constant Field Values
-
DEBEZIUM_TRANSACTION_KEY
public static final String DEBEZIUM_TRANSACTION_KEY
- See Also:
- Constant Field Values
-
DEBEZIUM_TRANSACTION_ID_KEY
public static final String DEBEZIUM_TRANSACTION_ID_KEY
- See Also:
- Constant Field Values
-
DEBEZIUM_TRANSACTION_TOTAL_ORDER_KEY
public static final String DEBEZIUM_TRANSACTION_TOTAL_ORDER_KEY
- See Also:
- Constant Field Values
-
DEBEZIUM_TRANSACTION_DATA_COLLECTION_ORDER_KEY
public static final String DEBEZIUM_TRANSACTION_DATA_COLLECTION_ORDER_KEY
- See Also:
- Constant Field Values
-
DEBEZIUM_TRANSACTION_STATUS_KEY
public static final String DEBEZIUM_TRANSACTION_STATUS_KEY
- See Also:
- Constant Field Values
-
DEBEZIUM_TRANSACTION_EVENT_COUNT_KEY
public static final String DEBEZIUM_TRANSACTION_EVENT_COUNT_KEY
- See Also:
- Constant Field Values
-
DEBEZIUM_TRANSACTION_COLLECTION_KEY
public static final String DEBEZIUM_TRANSACTION_COLLECTION_KEY
- See Also:
- Constant Field Values
-
DEBEZIUM_TRANSACTION_DATA_COLLECTIONS_KEY
public static final String DEBEZIUM_TRANSACTION_DATA_COLLECTIONS_KEY
- See Also:
- Constant Field Values
-
TRANSACTION_BLOCK_SCHEMA
public static final org.apache.kafka.connect.data.Schema TRANSACTION_BLOCK_SCHEMA
-
TRANSACTION_KEY_SCHEMA
private static final org.apache.kafka.connect.data.Schema TRANSACTION_KEY_SCHEMA
-
EVENT_COUNT_PER_DATA_COLLECTION_SCHEMA
private static final org.apache.kafka.connect.data.Schema EVENT_COUNT_PER_DATA_COLLECTION_SCHEMA
-
TRANSACTION_VALUE_SCHEMA
private static final org.apache.kafka.connect.data.Schema TRANSACTION_VALUE_SCHEMA
-
eventMetadataProvider
private final EventMetadataProvider eventMetadataProvider
-
topicName
private final String topicName
-
sender
private final BlockingConsumer<org.apache.kafka.connect.source.SourceRecord> sender
-
connectorConfig
private final CommonConnectorConfig connectorConfig
-
-
Constructor Detail
-
TransactionMonitor
public TransactionMonitor(CommonConnectorConfig connectorConfig, EventMetadataProvider eventMetadataProvider, BlockingConsumer<org.apache.kafka.connect.source.SourceRecord> sender)
-
-
Method Detail
-
dataEvent
public void dataEvent(Partition partition, DataCollectionId source, OffsetContext offset, Object key, org.apache.kafka.connect.data.Struct value) throws InterruptedException
- Throws:
InterruptedException
-
transactionComittedEvent
public void transactionComittedEvent(Partition partition, OffsetContext offset) throws InterruptedException
- Throws:
InterruptedException
-
transactionStartedEvent
public void transactionStartedEvent(Partition partition, String transactionId, OffsetContext offset) throws InterruptedException
- Throws:
InterruptedException
-
transactionEvent
private void transactionEvent(OffsetContext offsetContext, DataCollectionId source, org.apache.kafka.connect.data.Struct value)
-
beginTransaction
private void beginTransaction(Partition partition, OffsetContext offsetContext) throws InterruptedException
- Throws:
InterruptedException
-
endTransaction
private void endTransaction(Partition partition, OffsetContext offsetContext) throws InterruptedException
- Throws:
InterruptedException
-
-