public class PostgresStreamingChangeEventSource extends Object implements StreamingChangeEventSource
| Modifier and Type | Class and Description |
|---|---|
static interface |
PostgresStreamingChangeEventSource.PgConnectionSupplier |
ChangeEventSource.ChangeEventSourceContext| Modifier and Type | Field and Description |
|---|---|
private Clock |
clock |
private PostgresConnection |
connection |
private PostgresConnectorConfig |
connectorConfig |
private EventDispatcher<TableId> |
dispatcher |
private ErrorHandler |
errorHandler |
private static int |
GROWING_WAL_WARNING_LOG_INTERVAL
Number of received events without sending anything to Kafka which will
trigger a "WAL backlog growing" warning.
|
private Long |
lastCompletelyProcessedLsn |
private static org.slf4j.Logger |
LOGGER |
private long |
numberOfEventsSinceLastEventSentOrWalGrowingWarning
The minimum of (number of event received since the last event sent to Kafka,
number of event received since last WAL growing warning issued).
|
private PostgresOffsetContext |
offsetContext |
private Metronome |
pauseNoMessage |
private ReplicationConnection |
replicationConnection |
private AtomicReference<ReplicationStream> |
replicationStream |
private PostgresSchema |
schema |
private Snapshotter |
snapshotter |
private PostgresTaskContext |
taskContext |
private static int |
THROTTLE_NO_MESSAGE_BEFORE_PAUSE |
| Constructor and Description |
|---|
PostgresStreamingChangeEventSource(PostgresConnectorConfig connectorConfig,
Snapshotter snapshotter,
PostgresOffsetContext offsetContext,
PostgresConnection connection,
EventDispatcher<TableId> dispatcher,
ErrorHandler errorHandler,
Clock clock,
PostgresSchema schema,
PostgresTaskContext taskContext,
ReplicationConnection replicationConnection) |
| Modifier and Type | Method and Description |
|---|---|
void |
commitOffset(Map<String,?> offset) |
void |
execute(ChangeEventSource.ChangeEventSourceContext context) |
private void |
maybeWarnAboutGrowingWalBacklog(boolean dispatched)
If we receive change events but all of them get filtered out, we cannot
commit any new offset with Apache Kafka.
|
private static final int GROWING_WAL_WARNING_LOG_INTERVAL
private static final org.slf4j.Logger LOGGER
private static final int THROTTLE_NO_MESSAGE_BEFORE_PAUSE
private final PostgresConnection connection
private final EventDispatcher<TableId> dispatcher
private final ErrorHandler errorHandler
private final Clock clock
private final PostgresSchema schema
private final PostgresOffsetContext offsetContext
private final PostgresConnectorConfig connectorConfig
private final PostgresTaskContext taskContext
private final ReplicationConnection replicationConnection
private final AtomicReference<ReplicationStream> replicationStream
private final Snapshotter snapshotter
private final Metronome pauseNoMessage
private long numberOfEventsSinceLastEventSentOrWalGrowingWarning
private Long lastCompletelyProcessedLsn
public PostgresStreamingChangeEventSource(PostgresConnectorConfig connectorConfig, Snapshotter snapshotter, PostgresOffsetContext offsetContext, PostgresConnection connection, EventDispatcher<TableId> dispatcher, ErrorHandler errorHandler, Clock clock, PostgresSchema schema, PostgresTaskContext taskContext, ReplicationConnection replicationConnection)
public void execute(ChangeEventSource.ChangeEventSourceContext context) throws InterruptedException
execute in interface StreamingChangeEventSourceInterruptedExceptionprivate void maybeWarnAboutGrowingWalBacklog(boolean dispatched)
This situation typically occurs if there are changes on the database server, (e.g. in a blacklisted database), but none of them is in a whitelisted table. To prevent this, heartbeats can be used, as they will allow us to commit offsets also when not propagating any "real" change event.
The purpose of this method is to detect this situation and log a warning
every GROWING_WAL_WARNING_LOG_INTERVAL filtered events.
dispatched - Whether an event was sent to the broker or notpublic void commitOffset(Map<String,?> offset)
commitOffset in interface StreamingChangeEventSourceCopyright © 2019 JBoss by Red Hat. All rights reserved.