Class 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.ReplicationConnection
    Copied from Debezium 1.9.8.Final

    The ReplicationConnection created from createReplicationStream will 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 createReplicationStream will stop when endingPos reached.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected static class  PostgresReplicationConnection.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
      • Nested classes/interfaces inherited from interface io.debezium.connector.postgresql.connection.ReplicationConnection

        io.debezium.connector.postgresql.connection.ReplicationConnection.Builder
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      void close​(boolean dropSlot)  
      Optional<io.debezium.connector.postgresql.spi.SlotCreationResult> createReplicationSlot()  
      void initConnection()  
      protected void initPublication()  
      protected void initReplicationSlot()  
      protected org.postgresql.core.BaseConnection pgConnection()  
      void reconnect()  
      void setEndingPos​(Lsn endingPos)  
      io.debezium.connector.postgresql.connection.ReplicationStream startStreaming​(Lsn offset, io.debezium.connector.postgresql.connection.WalPositionLocator walPosition)  
      io.debezium.connector.postgresql.connection.ReplicationStream startStreaming​(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
      • Methods inherited from interface io.debezium.connector.postgresql.connection.ReplicationConnection

        isConnected
    • Method Detail

      • initPublication

        protected void initPublication()
      • startStreaming

        public io.debezium.connector.postgresql.connection.ReplicationStream startStreaming​(io.debezium.connector.postgresql.connection.WalPositionLocator walPosition)
                                                                                     throws SQLException,
                                                                                            InterruptedException
        creating 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 streamer

        This 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:
        startStreaming in interface io.debezium.connector.postgresql.connection.ReplicationConnection
        Returns:
        Throws:
        SQLException
        InterruptedException
      • startStreaming

        public io.debezium.connector.postgresql.connection.ReplicationStream startStreaming​(Lsn offset,
                                                                                            io.debezium.connector.postgresql.connection.WalPositionLocator walPosition)
                                                                                     throws SQLException,
                                                                                            InterruptedException
        Specified by:
        startStreaming in interface io.debezium.connector.postgresql.connection.ReplicationConnection
        Throws:
        SQLException
        InterruptedException
      • createReplicationSlot

        public Optional<io.debezium.connector.postgresql.spi.SlotCreationResult> createReplicationSlot()
                                                                                                throws SQLException
        Specified by:
        createReplicationSlot in interface io.debezium.connector.postgresql.connection.ReplicationConnection
        Throws:
        SQLException
      • setEndingPos

        public void setEndingPos​(Lsn endingPos)
      • close

        public void close()
        Specified by:
        close in interface AutoCloseable
        Overrides:
        close in class io.debezium.jdbc.JdbcConnection
      • close

        public void close​(boolean dropSlot)
      • reconnect

        public void reconnect()
                       throws SQLException
        Specified by:
        reconnect in interface io.debezium.connector.postgresql.connection.ReplicationConnection
        Throws:
        SQLException