Search in sources :

Example 1 with ChainedLogicalStreamBuilder

use of org.postgresql.replication.fluent.logical.ChainedLogicalStreamBuilder in project debezium by debezium.

the class PostgresReplicationConnection method startPgReplicationStream.

private PGReplicationStream startPgReplicationStream(final LogSequenceNumber lsn, Function<ChainedLogicalStreamBuilder, ChainedLogicalStreamBuilder> configurator) throws SQLException {
    assert lsn != null;
    ChainedLogicalStreamBuilder streamBuilder = pgConnection().getReplicationAPI().replicationStream().logical().withSlotName(slotName).withStartPosition(lsn);
    streamBuilder = configurator.apply(streamBuilder);
    if (statusUpdateIntervalMillis != null && statusUpdateIntervalMillis > 0) {
        streamBuilder.withStatusInterval(statusUpdateIntervalMillis, TimeUnit.MILLISECONDS);
    }
    PGReplicationStream stream = streamBuilder.start();
    // Needed by tests when connections are opened and closed in a fast sequence
    try {
        Thread.sleep(10);
    } catch (Exception e) {
    }
    stream.forceUpdateStatus();
    return stream;
}
Also used : PGReplicationStream(org.postgresql.replication.PGReplicationStream) ChainedLogicalStreamBuilder(org.postgresql.replication.fluent.logical.ChainedLogicalStreamBuilder) PSQLException(org.postgresql.util.PSQLException) JdbcConnectionException(io.debezium.jdbc.JdbcConnectionException) SQLException(java.sql.SQLException) ConnectException(org.apache.kafka.connect.errors.ConnectException)

Aggregations

JdbcConnectionException (io.debezium.jdbc.JdbcConnectionException)1 SQLException (java.sql.SQLException)1 ConnectException (org.apache.kafka.connect.errors.ConnectException)1 PGReplicationStream (org.postgresql.replication.PGReplicationStream)1 ChainedLogicalStreamBuilder (org.postgresql.replication.fluent.logical.ChainedLogicalStreamBuilder)1 PSQLException (org.postgresql.util.PSQLException)1