Interface SbeMessage<E extends org.agrona.sbe.MessageEncoderFlyweight,D extends org.agrona.sbe.MessageDecoderFlyweight>

All Superinterfaces:
KeyHeader, KeyMessage<D>, MutableKeyHeader<SbeMessage<E,D>>, MutableKeyMessage<D,SbeMessage<E,D>>

public interface SbeMessage<E extends org.agrona.sbe.MessageEncoderFlyweight,D extends org.agrona.sbe.MessageDecoderFlyweight> extends MutableKeyMessage<D,SbeMessage<E,D>>
SBE message for publication.

Instances can be reused by replacing topic fields and payload before each publish.

  • Method Details

    • payloadEncoder

      SbeMessage<E,D> payloadEncoder(E encoder)
      Sets the SBE payload encoder for this message. The encoder must have been initialised via encoder.wrapAndApplyHeader(buffer, offset, headerEncoder) before being passed here. At publish time, the encoder's buffer(), offset(), and encodedLength() are used to locate the payload bytes.
    • payloadDecoder

      D payloadDecoder()
      Returns the decoder wrapped over the current encoder payload.
    • payloadEncoder

      E payloadEncoder()
      Returns the encoder assigned by payloadEncoder(MessageEncoderFlyweight).
    • payloadHeaderEncodedLength

      SbeMessage<E,D> payloadHeaderEncodedLength(int headerEncodedLength)
      Sets the message header encoded length for this message. Use this when the payload uses a non-standard message header. When the message is created with a concrete encoder class, this is resolved automatically from the schema.
    • payloadHeaderEncodedLength

      int payloadHeaderEncodedLength()
      Returns the SBE message header encoded length used to locate payload bytes.
    • prepareVariableLengthEncoder

      void prepareVariableLengthEncoder()
      Resets the encoder position before encoding messages with repeating groups or variable length data fields. This is effectively the same as:
      
       encoder.wrap(encoder.buffer(), headerEncodedLength);
       
      Envelope fields (topics, flags, etc.) are not affected.
    • copyFrom

      void copyFrom(KeyMessage<? extends org.agrona.sbe.MessageFlyweight> source)
      Copies the message fields and SBE payload from the given source message into this message. The source payload bytes are copied into an independent, heap-backed, expandable buffer. If the encoder already has a buffer with sufficient capacity, it is reused to avoid allocation. The encoder is wrapped on the copied buffer and is usable for further modifications after the copy.

      The source payload must be a MessageDecoderFlyweight or MessageEncoderFlyweight.

      For widened messages created with MessageEncoderFlyweight.class, assign a concrete encoder with payloadEncoder(MessageEncoderFlyweight) before calling this method.