Class PostgresReplicationConnection
- java.lang.Object
-
- io.debezium.jdbc.JdbcConnection
-
- io.debezium.connector.postgresql.connection.PostgresReplicationConnection
-
- All Implemented Interfaces:
io.debezium.connector.postgresql.connection.ReplicationConnection,AutoCloseable
public class PostgresReplicationConnection extends io.debezium.jdbc.JdbcConnection implements io.debezium.connector.postgresql.connection.ReplicationConnectionCopied from Debezium 1.9.8.FinalThe
ReplicationConnectioncreated fromcreateReplicationStreamwill hang when the wal logs only contain the keepAliveMessage. Support to set an ending Lsn to stop hanging.Line 83, 711~713 : add endingPos and its setter.
Line 571~576, 595~600: ReplicationStream from
createReplicationStreamwill stop when endingPos reached.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classPostgresReplicationConnection.ReplicationConnectionBuilder-
Nested classes/interfaces inherited from class io.debezium.jdbc.JdbcConnection
io.debezium.jdbc.JdbcConnection.BlockingMultiResultSetConsumer, io.debezium.jdbc.JdbcConnection.BlockingResultSetConsumer, io.debezium.jdbc.JdbcConnection.CallPreparer, io.debezium.jdbc.JdbcConnection.ConnectionFactory, io.debezium.jdbc.JdbcConnection.MultiResultSetConsumer, io.debezium.jdbc.JdbcConnection.Operations, io.debezium.jdbc.JdbcConnection.ParameterResultSetConsumer, io.debezium.jdbc.JdbcConnection.ResultSetConsumer, io.debezium.jdbc.JdbcConnection.ResultSetExtractor<T extends Object>, io.debezium.jdbc.JdbcConnection.ResultSetMapper<T extends Object>, io.debezium.jdbc.JdbcConnection.StatementFactory, io.debezium.jdbc.JdbcConnection.StatementPreparer
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidclose(boolean dropSlot)Optional<io.debezium.connector.postgresql.spi.SlotCreationResult>createReplicationSlot()voidinitConnection()protected voidinitPublication()protected voidinitReplicationSlot()protected org.postgresql.core.BaseConnectionpgConnection()voidreconnect()voidsetEndingPos(Lsn endingPos)io.debezium.connector.postgresql.connection.ReplicationStreamstartStreaming(Lsn offset, io.debezium.connector.postgresql.connection.WalPositionLocator walPosition)io.debezium.connector.postgresql.connection.ReplicationStreamstartStreaming(io.debezium.connector.postgresql.connection.WalPositionLocator walPosition)creating a replication connection and starting to stream involves a few steps: 1.-
Methods inherited from class io.debezium.jdbc.JdbcConnection
buildSelectWithRowLimits, call, commit, config, connect, connection, connection, connectionString, database, execute, execute, executeWithoutCommitting, getColumnsDetails, getColumnValue, getCurrentTimestamp, isConnected, isNullable, isTableType, isTableUniqueIndexIncluded, isValid, loadKeyStore, overrideColumn, parseSqlStatementString, patternBasedFactory, patternBasedFactory, prepareQuery, prepareQuery, prepareQuery, prepareQuery, prepareQuery, prepareQueryAndMap, prepareQueryWithBlockingConsumer, prepareUpdate, print, print, query, query, queryAndMap, queryAndMap, querySingleValue, queryWithBlockingConsumer, quotedColumnIdString, quotedTableIdString, readAllCatalogNames, readAllSchemaNames, readAllTableNames, readPrimaryKeyNames, readPrimaryKeyOrUniqueIndexNames, readSchema, readTableColumn, readTableNames, readTablePreparedStatement, readTableStatement, readTableUniqueIndices, resolveCatalogName, resolveJdbcType, resolveNativeType, rollback, rowToArray, setAutoCommit, singleResultMapper, supportedTableTypes, tableTypes, username
-
-
-
-
Method Detail
-
initPublication
protected void initPublication()
-
initReplicationSlot
protected void initReplicationSlot() throws SQLException, InterruptedException- Throws:
SQLExceptionInterruptedException
-
startStreaming
public io.debezium.connector.postgresql.connection.ReplicationStream startStreaming(io.debezium.connector.postgresql.connection.WalPositionLocator walPosition) throws SQLException, InterruptedExceptioncreating a replication connection and starting to stream involves a few steps: 1. we create the connection and ensure that a. the slot exists b. the slot isn't currently being used 2. we query to get our potential start position in the slot (lsn) 3. we try and start streaming, depending on our options (such as in wal2json) this may fail, which can result in the connection being killed and we need to start the process over if we are using a temporary slot 4. actually start the streamerThis method takes care of all of these and this method queries for a default starting position If you know where you are starting from you should call
startStreaming(Lsn, WalPositionLocator), this method delegates to that method- Specified by:
startStreamingin interfaceio.debezium.connector.postgresql.connection.ReplicationConnection- Returns:
- Throws:
SQLExceptionInterruptedException
-
startStreaming
public io.debezium.connector.postgresql.connection.ReplicationStream startStreaming(Lsn offset, io.debezium.connector.postgresql.connection.WalPositionLocator walPosition) throws SQLException, InterruptedException
- Specified by:
startStreamingin interfaceio.debezium.connector.postgresql.connection.ReplicationConnection- Throws:
SQLExceptionInterruptedException
-
initConnection
public void initConnection() throws SQLException, InterruptedException- Specified by:
initConnectionin interfaceio.debezium.connector.postgresql.connection.ReplicationConnection- Throws:
SQLExceptionInterruptedException
-
createReplicationSlot
public Optional<io.debezium.connector.postgresql.spi.SlotCreationResult> createReplicationSlot() throws SQLException
- Specified by:
createReplicationSlotin interfaceio.debezium.connector.postgresql.connection.ReplicationConnection- Throws:
SQLException
-
pgConnection
protected org.postgresql.core.BaseConnection pgConnection() throws SQLException- Throws:
SQLException
-
setEndingPos
public void setEndingPos(Lsn endingPos)
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Overrides:
closein classio.debezium.jdbc.JdbcConnection
-
close
public void close(boolean dropSlot)
-
reconnect
public void reconnect() throws SQLException- Specified by:
reconnectin interfaceio.debezium.connector.postgresql.connection.ReplicationConnection- Throws:
SQLException
-
-