Package io.debezium.pipeline
Class EventDispatcher<T extends DataCollectionId>
- java.lang.Object
-
- io.debezium.pipeline.EventDispatcher<T>
-
public class EventDispatcher<T extends DataCollectionId> extends Object
Central dispatcher for data change and schema change events. The former will be routed to the change event queue, the latter will be routed to theDatabaseSchema
. But based on the applying include/exclude list configuration, events may be not be dispatched at all.This router is also in charge of emitting heartbeat messages, exposing of metrics via JMX etc.
- Author:
- Gunnar Morling
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
EventDispatcher.BufferingSnapshotChangeRecordReceiver
static interface
EventDispatcher.InconsistentSchemaHandler<T extends DataCollectionId>
Reaction to an incoming change event for which schema is not foundprivate class
EventDispatcher.IncrementalSnapshotChangeRecordReceiver
private class
EventDispatcher.SchemaChangeEventReceiver
static interface
EventDispatcher.SnapshotReceiver
Change record receiver used during snapshotting.private class
EventDispatcher.StreamingChangeRecordReceiver
-
Field Summary
-
Constructor Summary
-
Method Summary
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
topicSelector
private final TopicSelector<T extends DataCollectionId> topicSelector
-
schema
private final DatabaseSchema<T extends DataCollectionId> schema
-
historizedSchema
private final HistorizedDatabaseSchema<T extends DataCollectionId> historizedSchema
-
queue
private final ChangeEventQueue<DataChangeEvent> queue
-
filter
private final DataCollectionFilters.DataCollectionFilter<T extends DataCollectionId> filter
-
changeEventCreator
private final ChangeEventCreator changeEventCreator
-
heartbeat
private final Heartbeat heartbeat
-
eventListener
private DataChangeEventListener eventListener
-
emitTombstonesOnDelete
private final boolean emitTombstonesOnDelete
-
inconsistentSchemaHandler
private final EventDispatcher.InconsistentSchemaHandler<T extends DataCollectionId> inconsistentSchemaHandler
-
transactionMonitor
private final TransactionMonitor transactionMonitor
-
connectorConfig
private final CommonConnectorConfig connectorConfig
-
skippedOperations
private final EnumSet<Envelope.Operation> skippedOperations
-
neverSkip
private final boolean neverSkip
-
schemaChangeKeySchema
private final org.apache.kafka.connect.data.Schema schemaChangeKeySchema
-
schemaChangeValueSchema
private final org.apache.kafka.connect.data.Schema schemaChangeValueSchema
-
tableChangesSerializer
private final TableChanges.TableChangesSerializer<List<org.apache.kafka.connect.data.Struct>> tableChangesSerializer
-
signal
private final Signal signal
-
incrementalSnapshotChangeEventSource
private IncrementalSnapshotChangeEventSource<T extends DataCollectionId> incrementalSnapshotChangeEventSource
-
streamingReceiver
private final EventDispatcher.StreamingChangeRecordReceiver streamingReceiver
Change event receiver for events dispatched from a streaming change event source.
-
-
Constructor Detail
-
EventDispatcher
public EventDispatcher(CommonConnectorConfig connectorConfig, TopicSelector<T> topicSelector, DatabaseSchema<T> schema, ChangeEventQueue<DataChangeEvent> queue, DataCollectionFilters.DataCollectionFilter<T> filter, ChangeEventCreator changeEventCreator, EventMetadataProvider metadataProvider, SchemaNameAdjuster schemaNameAdjuster)
-
EventDispatcher
public EventDispatcher(CommonConnectorConfig connectorConfig, TopicSelector<T> topicSelector, DatabaseSchema<T> schema, ChangeEventQueue<DataChangeEvent> queue, DataCollectionFilters.DataCollectionFilter<T> filter, ChangeEventCreator changeEventCreator, EventMetadataProvider metadataProvider, Heartbeat heartbeat, SchemaNameAdjuster schemaNameAdjuster)
-
EventDispatcher
public EventDispatcher(CommonConnectorConfig connectorConfig, TopicSelector<T> topicSelector, DatabaseSchema<T> schema, ChangeEventQueue<DataChangeEvent> queue, DataCollectionFilters.DataCollectionFilter<T> filter, ChangeEventCreator changeEventCreator, EventDispatcher.InconsistentSchemaHandler<T> inconsistentSchemaHandler, EventMetadataProvider metadataProvider, Heartbeat customHeartbeat, SchemaNameAdjuster schemaNameAdjuster, JdbcConnection jdbcConnection)
-
-
Method Detail
-
dispatchSnapshotEvent
public void dispatchSnapshotEvent(T dataCollectionId, ChangeRecordEmitter changeRecordEmitter, EventDispatcher.SnapshotReceiver receiver) throws InterruptedException
- Throws:
InterruptedException
-
getSnapshotChangeEventReceiver
public EventDispatcher.SnapshotReceiver getSnapshotChangeEventReceiver()
-
getIncrementalSnapshotChangeEventReceiver
public EventDispatcher.SnapshotReceiver getIncrementalSnapshotChangeEventReceiver(DataChangeEventListener dataListener)
-
dispatchDataChangeEvent
public boolean dispatchDataChangeEvent(T dataCollectionId, ChangeRecordEmitter changeRecordEmitter) throws InterruptedException
Dispatches one or moreDataChangeEvent
s. If the given data collection is included in the currently captured set of collections, the given emitter will be invoked, so it can emit one or more events (in the common case, one event will be emitted, but e.g. in case of PK updates, it may be a deletion and a creation event). The receiving coordinator createsSourceRecord
s for all emitted events and passes them to this dispatcher'sChangeEventCreator
for converting them into data change events.- Returns:
true
if an event was dispatched (i.e. sent to the message broker),false
otherwise.- Throws:
InterruptedException
-
dispatchFilteredEvent
public void dispatchFilteredEvent(Partition partition, OffsetContext offset) throws InterruptedException
- Throws:
InterruptedException
-
dispatchTransactionCommittedEvent
public void dispatchTransactionCommittedEvent(Partition partition, OffsetContext offset) throws InterruptedException
- Throws:
InterruptedException
-
dispatchTransactionStartedEvent
public void dispatchTransactionStartedEvent(Partition partition, String transactionId, OffsetContext offset) throws InterruptedException
- Throws:
InterruptedException
-
dispatchConnectorEvent
public void dispatchConnectorEvent(ConnectorEvent event)
-
errorOnMissingSchema
public Optional<DataCollectionSchema> errorOnMissingSchema(T dataCollectionId, ChangeRecordEmitter changeRecordEmitter)
-
ignoreMissingSchema
public Optional<DataCollectionSchema> ignoreMissingSchema(T dataCollectionId, ChangeRecordEmitter changeRecordEmitter)
-
dispatchSchemaChangeEvent
public void dispatchSchemaChangeEvent(T dataCollectionId, SchemaChangeEventEmitter schemaChangeEventEmitter) throws InterruptedException
- Throws:
InterruptedException
-
dispatchSchemaChangeEvent
public void dispatchSchemaChangeEvent(Collection<T> dataCollectionIds, SchemaChangeEventEmitter schemaChangeEventEmitter) throws InterruptedException
- Throws:
InterruptedException
-
alwaysDispatchHeartbeatEvent
public void alwaysDispatchHeartbeatEvent(Partition partition, OffsetContext offset) throws InterruptedException
- Throws:
InterruptedException
-
dispatchHeartbeatEvent
public void dispatchHeartbeatEvent(Partition partition, OffsetContext offset) throws InterruptedException
- Throws:
InterruptedException
-
heartbeatsEnabled
public boolean heartbeatsEnabled()
-
enqueueHeartbeat
private void enqueueHeartbeat(org.apache.kafka.connect.source.SourceRecord record) throws InterruptedException
- Throws:
InterruptedException
-
enqueueTransactionMessage
private void enqueueTransactionMessage(org.apache.kafka.connect.source.SourceRecord record) throws InterruptedException
- Throws:
InterruptedException
-
enqueueSchemaChangeMessage
private void enqueueSchemaChangeMessage(org.apache.kafka.connect.source.SourceRecord record) throws InterruptedException
- Throws:
InterruptedException
-
dispatchServerHeartbeatEvent
public void dispatchServerHeartbeatEvent(Partition partition, OffsetContext offset) throws InterruptedException
- Throws:
InterruptedException
-
setEventListener
public void setEventListener(DataChangeEventListener eventListener)
Provide a listener that is invoked for every incoming event to be processed.- Parameters:
eventListener
-
-
setIncrementalSnapshotChangeEventSource
public void setIncrementalSnapshotChangeEventSource(Optional<IncrementalSnapshotChangeEventSource<? extends DataCollectionId>> incrementalSnapshotChangeEventSource)
Enable support for incremental snapshotting.
-
getSchema
public DatabaseSchema<T> getSchema()
-
getHistorizedSchema
public HistorizedDatabaseSchema<T> getHistorizedSchema()
-
getIncrementalSnapshotChangeEventSource
public IncrementalSnapshotChangeEventSource<T> getIncrementalSnapshotChangeEventSource()
-
-