Interface MessageDecoder
-
- All Known Implementing Classes:
AbstractMessageDecoder,NonStreamingWal2JsonMessageDecoder,PgOutputMessageDecoder,PgProtoMessageDecoder,StreamingWal2JsonMessageDecoder
public interface MessageDecoderA 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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidclose()Closes this decoder, freeing and/or closing all resources it may potentially hold.org.postgresql.replication.fluent.logical.ChainedLogicalStreamBuilderoptionsWithMetadata(org.postgresql.replication.fluent.logical.ChainedLogicalStreamBuilder builder)Allows MessageDecoder to configure options with which the replication stream is started.org.postgresql.replication.fluent.logical.ChainedLogicalStreamBuilderoptionsWithoutMetadata(org.postgresql.replication.fluent.logical.ChainedLogicalStreamBuilder builder)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 decoderdefault voidsetContainsMetadata(boolean flag)Signals to this decoder whether messages contain type metadata or not.booleanshouldMessageBeSkipped(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 Detail
-
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
-
optionsWithMetadata
org.postgresql.replication.fluent.logical.ChainedLogicalStreamBuilder optionsWithMetadata(org.postgresql.replication.fluent.logical.ChainedLogicalStreamBuilder builder)
Allows MessageDecoder to configure options with which the replication stream is started. The messages CAN contain type metadata. See PostgreSQL command START_REPLICATION SLOT for more details.- Parameters:
builder-- Returns:
- the builder instance
-
optionsWithoutMetadata
org.postgresql.replication.fluent.logical.ChainedLogicalStreamBuilder optionsWithoutMetadata(org.postgresql.replication.fluent.logical.ChainedLogicalStreamBuilder builder)
Allows MessageDecoder to configure options with which the replication stream is started. The messages MUST NOT contain type metadata. See PostgreSQL command START_REPLICATION SLOT for more details.- Parameters:
builder-- Returns:
- the builder instance
-
setContainsMetadata
default void setContainsMetadata(boolean flag)
Signals to this decoder whether messages contain type metadata or not.
-
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.
-
-