Interface MessageDecoder
- All Known Implementing Classes:
AbstractMessageDecoder,PgOutputMessageDecoder,PgProtoMessageDecoder
public interface MessageDecoder
A class that is able to deserialize/decode binary representation of a batch of replication messages generated by
logical decoding plugin. Clients provide a callback code for processing.
- Author:
- Jiri Pechanec
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this decoder, freeing and/or closing all resources it may potentially hold.org.postgresql.replication.fluent.logical.ChainedLogicalStreamBuilderdefaultOptions(org.postgresql.replication.fluent.logical.ChainedLogicalStreamBuilder builder, Function<Integer, Boolean> hasMinimumServerVersion) Allows MessageDecoder to configure options with which the replication stream is started.voidprocessMessage(ByteBuffer buffer, ReplicationStream.ReplicationMessageProcessor processor, TypeRegistry typeRegistry) Process a message upon arrival from logical decoderbooleanshouldMessageBeSkipped(ByteBuffer buffer, Lsn lastReceivedLsn, Lsn startLsn, WalPositionLocator walPosition) A callback into the decoder allowing it to decide whether the supplied message should be processed by the decoder or whether it can be skipped.
-
Method Details
-
processMessage
void processMessage(ByteBuffer buffer, ReplicationStream.ReplicationMessageProcessor processor, TypeRegistry typeRegistry) throws SQLException, InterruptedException Process a message upon arrival from logical decoder- Parameters:
buffer- - binary representation of replication messageprocessor- - message processing on arrivaltypeRegistry- - registry with known types- Throws:
SQLExceptionInterruptedException
-
defaultOptions
org.postgresql.replication.fluent.logical.ChainedLogicalStreamBuilder defaultOptions(org.postgresql.replication.fluent.logical.ChainedLogicalStreamBuilder builder, Function<Integer, Boolean> hasMinimumServerVersion) Allows MessageDecoder to configure options with which the replication stream is started. See PostgreSQL command START_REPLICATION SLOT for more details.- Parameters:
builder-- Returns:
- the builder instance
-
shouldMessageBeSkipped
boolean shouldMessageBeSkipped(ByteBuffer buffer, Lsn lastReceivedLsn, Lsn startLsn, WalPositionLocator walPosition) A callback into the decoder allowing it to decide whether the supplied message should be processed by the decoder or whether it can be skipped.- Parameters:
buffer- the replication stream bufferlastReceivedLsn- the last LSN reported by the replication streamstartLsn- the starting LSN reported by the streaming producerwalPosition- wal position from which the streaming should resume- Returns:
trueif the incoming message should be skipped,falseotherwise
-
close
void close()Closes this decoder, freeing and/or closing all resources it may potentially hold.
-