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 ClassesModifier and TypeClassDescription(package private) static class(package private) static classprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final OracleConnectorConfigprivate Stringprivate intprivate Stringprivate final BlockingConsumer<LogMinerEvent>private static final org.slf4j.Loggerprivate final Map<String,TransactionCommitConsumer.RowState> private final OracleDatabaseSchemaprivate int -
Constructor Summary
ConstructorsConstructorDescriptionTransactionCommitConsumer(BlockingConsumer<LogMinerEvent> delegate, OracleConnectorConfig connectorConfig, OracleDatabaseSchema schema) -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(LogMinerEvent event) private voidacceptDmlEvent(DmlEvent event) private voidvoidclose()private voiddispatchChangeEvent(LogMinerEvent event) private voidmergeEvents(DmlEvent into, DmlEvent from) private Object[]private Object[]private voidprepareAndDispatch(DmlEvent event) private StringrowIdFromEvent(Table table, DmlEvent event) private boolean
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
delegate
-
connectorConfig
-
schema
-
rows
-
currentLobRowId
-
currentLobColumnName
-
currentLobColumnPosition
private int currentLobColumnPosition -
transactionIndex
private int transactionIndex
-
-
Constructor Details
-
TransactionCommitConsumer
public TransactionCommitConsumer(BlockingConsumer<LogMinerEvent> delegate, OracleConnectorConfig connectorConfig, OracleDatabaseSchema schema)
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
InterruptedException
-
accept
- Specified by:
acceptin interfaceBlockingConsumer<LogMinerEvent>- Throws:
InterruptedException
-
acceptDmlEvent
- Throws:
InterruptedException
-
acceptLobManipulationEvent
-
prepareAndDispatch
- Throws:
InterruptedException
-
tryMerge
-
mergeEvents
-
dispatchChangeEvent
- Throws:
InterruptedException
-
rowIdFromEvent
-
newValues
-
oldValues
-