Interface Converter

All Known Implementing Classes:
StringConverter

public interface Converter
The Converter interface provides support for translating between Kafka Connect's runtime data format and byte[]. Internally, this likely includes an intermediate step to the format used by the serialization layer (e.g. JsonNode, GenericRecord, Message).
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    configure(Map<String,?> configs, boolean isKey)
    Configure this class.
    default byte[]
    fromConnectData(String topic, Headers headers, Schema schema, Object value)
    Convert a Kafka Connect data object to a native object for serialization, potentially using the supplied topic and headers in the record as necessary.
    byte[]
    fromConnectData(String topic, Schema schema, Object value)
    Convert a Kafka Connect data object to a native object for serialization.
    toConnectData(String topic, byte[] value)
    Convert a native object to a Kafka Connect data object.
    toConnectData(String topic, Headers headers, byte[] value)
    Convert a native object to a Kafka Connect data object, potentially using the supplied topic and headers in the record as necessary.
  • Method Details

    • configure

      void configure(Map<String,?> configs, boolean isKey)
      Configure this class.
      Parameters:
      configs - configs in key/value pairs
      isKey - whether is for key or value
    • fromConnectData

      byte[] fromConnectData(String topic, Schema schema, Object value)
      Convert a Kafka Connect data object to a native object for serialization.
      Parameters:
      topic - the topic associated with the data
      schema - the schema for the value
      value - the value to convert
      Returns:
      the serialized value
    • fromConnectData

      default byte[] fromConnectData(String topic, Headers headers, Schema schema, Object value)
      Convert a Kafka Connect data object to a native object for serialization, potentially using the supplied topic and headers in the record as necessary.

      Connect uses this method directly, and for backward compatibility reasons this method by default will call the fromConnectData(String, Schema, Object) method. Override this method to make use of the supplied headers.

      Parameters:
      topic - the topic associated with the data
      headers - the headers associated with the data; any changes done to the headers are applied to the message sent to the broker
      schema - the schema for the value
      value - the value to convert
      Returns:
      the serialized value
    • toConnectData

      SchemaAndValue toConnectData(String topic, byte[] value)
      Convert a native object to a Kafka Connect data object.
      Parameters:
      topic - the topic associated with the data
      value - the value to convert
      Returns:
      an object containing the Schema and the converted value
    • toConnectData

      default SchemaAndValue toConnectData(String topic, Headers headers, byte[] value)
      Convert a native object to a Kafka Connect data object, potentially using the supplied topic and headers in the record as necessary.

      Connect uses this method directly, and for backward compatibility reasons this method by default will call the toConnectData(String, byte[]) method. Override this method to make use of the supplied headers.

      Parameters:
      topic - the topic associated with the data
      headers - the headers associated with the data
      value - the value to convert
      Returns:
      an object containing the Schema and the converted value