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(); // TODO DBZ-508 get rid of this // Needed by tests when connections are opened and closed in a fast sequence try { Thread.sleep(10); } catch (Exception e) { } stream.forceUpdateStatus(); return stream; }
.createReplicationSlot() .logical() .withSlotName(slotName)
private void createRplStream() throws SQLException { this.stream = this.rplConnection.getReplicationAPI() .replicationStream() .logical() .withSlotName(this.jdbcConfig.getSlotName()) .withSlotOption("include-xids", true) .withSlotOption("skip-empty-xacts", true) .withStatusInterval(5, TimeUnit.SECONDS) .start(); log.info("GetRplStream success,slot:{}", this.slotName); }
private void createRplSlot() throws SQLException { try { this.rplConnection.getReplicationAPI() .createReplicationSlot() .logical() .withSlotName(this.jdbcConfig.getSlotName()) .withOutputPlugin("test_decoding") .make(); } catch (SQLException e) { String msg = "ERROR: replication slot \"" + this.jdbcConfig.getSlotName() + "\" already exists"; if (msg.equals(e.getMessage())) { return; } throw e; } log.info("GetRplSlot success,slot:{}", this.slotName); }
.replicationStream() .logical() .withSlotName(replicationSlotName)
.createReplicationSlot() .logical() .withSlotName(slotName)
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(); // TODO DBZ-508 get rid of this // Needed by tests when connections are opened and closed in a fast sequence try { Thread.sleep(10); } catch (Exception e) { } stream.forceUpdateStatus(); return stream; }