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 Type
    Method
    Description
    void
    Closes this decoder, freeing and/or closing all resources it may potentially hold.
    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.
    void
    Process a message upon arrival from logical decoder
    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.
  • 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 message
      processor - - message processing on arrival
      typeRegistry - - registry with known types
      Throws:
      SQLException
      InterruptedException
    • 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 buffer
      lastReceivedLsn - the last LSN reported by the replication stream
      startLsn - the starting LSN reported by the streaming producer
      walPosition - wal position from which the streaming should resume
      Returns:
      true if the incoming message should be skipped, false otherwise
    • close

      void close()
      Closes this decoder, freeing and/or closing all resources it may potentially hold.