Class TransactionCommitConsumer
- java.lang.Object
-
- io.debezium.connector.oracle.logminer.processor.TransactionCommitConsumer
-
- All Implemented Interfaces:
BlockingConsumer<LogMinerEvent>,AutoCloseable
public class TransactionCommitConsumer extends Object implements AutoCloseable, BlockingConsumer<LogMinerEvent>
A consumer of transaction events at commit time that is capable of inspecting the event stream, merging events that should be merged when LOB support is enabled, and then delegating the final stream of events to a delegate consumer. When a table has a LOB field, Oracle LogMiner often supplies us with synthetic events that deal with sub-tasks that occur in the database as a result of writing LOB data to the database. We would prefer to emit these synthetic events as a part of the overall logical event, whether that is an insert or update. An example of a scenario would be the following logical user action: INSERT INTO my_table (id,lob_field) values (1, 'some clob data'); Oracle LogMiner provides the connector with the following events: INSERT INTO my_table (id,lob_field) values (1, EMPTY_CLOB()); UPDATE my_table SET lob_field = 'some clob data' where id = 1; When LOB support is enabled, this consumer implementation will detect that the update is an event that should be merged with the previous insert event so that the emitted change events consists a single logical change, an insert that have an after section like:"after": { "id": 1, "lob_field": "some clob data" }When LOB support isn't enabled, events are simply passed through to the delegate and no event inspection, merging, or buffering occurs.- Author:
- Chris Cranford
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classTransactionCommitConsumer.LobFragment(package private) static classTransactionCommitConsumer.LobUnderConstructionprivate static classTransactionCommitConsumer.RowState
-
Field Summary
Fields Modifier and Type Field Description private OracleConnectorConfigconnectorConfigprivate StringcurrentLobColumnNameprivate intcurrentLobColumnPositionprivate StringcurrentLobRowIdprivate BlockingConsumer<LogMinerEvent>delegateprivate static org.slf4j.LoggerLOGGERprivate Map<String,TransactionCommitConsumer.RowState>rowsprivate OracleDatabaseSchemaschemaprivate inttransactionIndex
-
Constructor Summary
Constructors Constructor Description TransactionCommitConsumer(BlockingConsumer<LogMinerEvent> delegate, OracleConnectorConfig connectorConfig, OracleDatabaseSchema schema)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(LogMinerEvent event)private voidacceptDmlEvent(DmlEvent event)private voidacceptLobManipulationEvent(LogMinerEvent event)voidclose()private voiddispatchChangeEvent(LogMinerEvent event)private voidmergeEvents(DmlEvent into, DmlEvent from)private Object[]newValues(DmlEvent event)private Object[]oldValues(DmlEvent event)private voidprepareAndDispatch(DmlEvent event)private StringrowIdFromEvent(Table table, DmlEvent event)private booleantryMerge(DmlEvent prev, DmlEvent next)
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
delegate
private final BlockingConsumer<LogMinerEvent> delegate
-
connectorConfig
private final OracleConnectorConfig connectorConfig
-
schema
private final OracleDatabaseSchema schema
-
rows
private final Map<String,TransactionCommitConsumer.RowState> rows
-
currentLobRowId
private String currentLobRowId
-
currentLobColumnName
private String currentLobColumnName
-
currentLobColumnPosition
private int currentLobColumnPosition
-
transactionIndex
private int transactionIndex
-
-
Constructor Detail
-
TransactionCommitConsumer
public TransactionCommitConsumer(BlockingConsumer<LogMinerEvent> delegate, OracleConnectorConfig connectorConfig, OracleDatabaseSchema schema)
-
-
Method Detail
-
close
public void close() throws InterruptedException- Specified by:
closein interfaceAutoCloseable- Throws:
InterruptedException
-
accept
public void accept(LogMinerEvent event) throws InterruptedException
- Specified by:
acceptin interfaceBlockingConsumer<LogMinerEvent>- Throws:
InterruptedException
-
acceptDmlEvent
private void acceptDmlEvent(DmlEvent event) throws InterruptedException
- Throws:
InterruptedException
-
acceptLobManipulationEvent
private void acceptLobManipulationEvent(LogMinerEvent event)
-
prepareAndDispatch
private void prepareAndDispatch(DmlEvent event) throws InterruptedException
- Throws:
InterruptedException
-
dispatchChangeEvent
private void dispatchChangeEvent(LogMinerEvent event) throws InterruptedException
- Throws:
InterruptedException
-
-