private void deserializeMessages(ByteBuffer buffer, ReplicationMessageProcessor processor) throws SQLException, InterruptedException { lastReceivedLSN = stream.getLastReceiveLSN(); messageDecoder.processMessage(buffer, processor, typeRegistry); }
@Override public void readPending(ReplicationMessageProcessor processor) throws SQLException, InterruptedException { ByteBuffer read = stream.readPending(); // the lsn we started from is inclusive, so we need to avoid sending back the same message twice if (read == null || lsnLong >= stream.getLastReceiveLSN().asLong()) { return; } deserializeMessages(read, processor); }
@Override public void read(ReplicationMessageProcessor processor) throws SQLException, InterruptedException { ByteBuffer read = stream.read(); // the lsn we started from is inclusive, so we need to avoid sending back the same message twice if (lsnLong >= stream.getLastReceiveLSN().asLong()) { return; } deserializeMessages(read, processor); }
private void deserializeMessages(ByteBuffer buffer, ReplicationMessageProcessor processor) throws SQLException, InterruptedException { lastReceivedLSN = stream.getLastReceiveLSN(); messageDecoder.processMessage(buffer, processor, typeRegistry); }
@Override public void read(ReplicationMessageProcessor processor) throws SQLException, InterruptedException { ByteBuffer read = stream.read(); // the lsn we started from is inclusive, so we need to avoid sending back the same message twice if (lsnLong >= stream.getLastReceiveLSN().asLong()) { return; } deserializeMessages(read, processor); }
@Override public void readPending(ReplicationMessageProcessor processor) throws SQLException, InterruptedException { ByteBuffer read = stream.readPending(); // the lsn we started from is inclusive, so we need to avoid sending back the same message twice if (read == null || lsnLong >= stream.getLastReceiveLSN().asLong()) { return; } deserializeMessages(read, processor); }
.parse(JSonMapper.fromJson(messageString, PostgresWalMessage.class), stream.getLastReceiveLSN().asLong(), replicationSlotName) .forEach(eventConsumer); stream.setAppliedLSN(stream.getLastReceiveLSN()); stream.setFlushedLSN(stream.getLastReceiveLSN());
private void receiveStream() throws SQLException { assert !stream.isClosed(); assert !connection.isClosed(); //non blocking receive message ByteBuffer msg = stream.readPending(); if (msg == null) { TimeUtils.sleepInMills(10L); return; } int offset = msg.arrayOffset(); byte[] source = msg.array(); int length = source.length - offset; LogSequenceNumber lsn = stream.getLastReceiveLSN(); InvokeContext ctx = new InvokeContext(); ctx.setMessage(new String(source, offset, length)); ctx.setJdbcUrl(this.jdbcConfig.getUrl()); ctx.setJdbcUser(this.jdbcConfig.getUsername()); ctx.setJdbcPass(this.jdbcConfig.getPassword()); ctx.setSlotName(this.slotName); ctx.setServerId(this.serverId); ctx.setLsn(lsn.asLong()); eventParser.parse(ctx); //feedback stream.setAppliedLSN(lsn); stream.setFlushedLSN(lsn); }