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.LobStateDescribes the current LOB event buffering state, whether we're working on a series ofLOB_WRITEevents,LOB_ERASEevents, or any other type of event that does not require special handling.
-
Field Summary
Fields Modifier and Type Field Description private OracleConnectorConfigconnectorConfigprivate BlockingConsumer<LogMinerEvent>delegateprivate LogMinerEventlastEventprivate SelectLobLocatorEventlastSelectLobLocatorEventprivate TransactionCommitConsumer.LobStatelobStateprivate List<String>lobWriteDataprivate static org.slf4j.LoggerLOGGERprivate OracleDatabaseSchemaschema
-
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)voidclose()private voiddispatchChangeEvent(LogMinerEvent event)private intgetSelectLobLocatorColumnIndex()private booleanisForSameTableOrScn(LogMinerEvent event, LogMinerEvent prevEvent)private booleanisMerged(LogMinerEvent event, LogMinerEvent prevEvent)private booleanisSameTableRow(LogMinerEvent event, LogMinerEvent prevEvent)private voidmergeLobWriteData(LogMinerEvent event)private voidmergeNewColumns(DmlEvent event, DmlEvent prevEvent)private TransactionCommitConsumer.LobStateresolveLobStateByCurrentEvent(LogMinerEvent event)
-
-
-
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
-
lastEvent
private LogMinerEvent lastEvent
-
lastSelectLobLocatorEvent
private SelectLobLocatorEvent lastSelectLobLocatorEvent
-
lobState
private TransactionCommitConsumer.LobState lobState
-
-
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
-
dispatchChangeEvent
private void dispatchChangeEvent(LogMinerEvent event) throws InterruptedException
- Throws:
InterruptedException
-
resolveLobStateByCurrentEvent
private TransactionCommitConsumer.LobState resolveLobStateByCurrentEvent(LogMinerEvent event)
-
isMerged
private boolean isMerged(LogMinerEvent event, LogMinerEvent prevEvent)
-
mergeLobWriteData
private void mergeLobWriteData(LogMinerEvent event)
-
getSelectLobLocatorColumnIndex
private int getSelectLobLocatorColumnIndex()
-
isForSameTableOrScn
private boolean isForSameTableOrScn(LogMinerEvent event, LogMinerEvent prevEvent)
-
isSameTableRow
private boolean isSameTableRow(LogMinerEvent event, LogMinerEvent prevEvent)
-
-