Interface MessageCodec<T>

Type Parameters:
T - value type handled by the codec

public interface MessageCodec<T>
Explicit, safe conversion between a plugin value and its wire representation.
  • Method Summary

    Modifier and Type
    Method
    Description
    default String
    Identifies the encoded representation so subscribers can reject incompatible codecs.
    decode(byte[] payload)
    Decodes a transported payload.
    byte[]
    encode(T value)
    Encodes a value for transport.
  • Method Details

    • encode

      byte[] encode(T value) throws Exception
      Encodes a value for transport.
      Parameters:
      value - value to encode
      Returns:
      encoded bytes
      Throws:
      Exception - if the value cannot be encoded
    • decode

      T decode(byte[] payload) throws Exception
      Decodes a transported payload.
      Parameters:
      payload - encoded bytes
      Returns:
      decoded value
      Throws:
      Exception - if the payload cannot be decoded
    • contentType

      default String contentType()
      Identifies the encoded representation so subscribers can reject incompatible codecs.
      Returns:
      MIME-style content type