Interface MessageDecoder

All Known Implementing Classes:
AbstractMessageDecoder, NonStreamingWal2JsonMessageDecoder, PgOutputMessageDecoder, PgProtoMessageDecoder, StreamingWal2JsonMessageDecoder

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
    optionsWithMetadata(org.postgresql.replication.fluent.logical.ChainedLogicalStreamBuilder builder, Function<Integer,Boolean> hasMinimumServerVersion)
    Allows MessageDecoder to configure options with which the replication stream is started.
    org.postgresql.replication.fluent.logical.ChainedLogicalStreamBuilder
    optionsWithoutMetadata(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
    default void
    setContainsMetadata(boolean flag)
    Signals to this decoder whether messages contain type metadata or not.
    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
    • optionsWithMetadata

      org.postgresql.replication.fluent.logical.ChainedLogicalStreamBuilder optionsWithMetadata(org.postgresql.replication.fluent.logical.ChainedLogicalStreamBuilder builder, Function<Integer,Boolean> hasMinimumServerVersion)
      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, Function<Integer,Boolean> hasMinimumServerVersion)
      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 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.