Class SimpleHeaderConverter

  • All Implemented Interfaces:
    Closeable, AutoCloseable, org.apache.kafka.common.Configurable, HeaderConverter

    public class SimpleHeaderConverter
    extends Object
    implements HeaderConverter
    A HeaderConverter that serializes header values as strings and that deserializes header values to the most appropriate numeric, boolean, array, or map representation. Schemas are not serialized, but are inferred upon deserialization when possible.
    • Constructor Detail

      • SimpleHeaderConverter

        public SimpleHeaderConverter()
    • Method Detail

      • config

        public org.apache.kafka.common.config.ConfigDef config()
        Description copied from interface: HeaderConverter
        Configuration specification for this set of header converters.
        Specified by:
        config in interface HeaderConverter
        Returns:
        the configuration specification; may not be null
      • configure

        public void configure​(Map<String,​?> configs)
        Specified by:
        configure in interface org.apache.kafka.common.Configurable
      • toConnectHeader

        public SchemaAndValue toConnectHeader​(String topic,
                                              String headerKey,
                                              byte[] value)
        Description copied from interface: HeaderConverter
        Convert the header name and byte array value into a Header object.
        Specified by:
        toConnectHeader in interface HeaderConverter
        Parameters:
        topic - the name of the topic for the record containing the header
        headerKey - the header's key; may not be null
        value - the header's raw value; may be null
        Returns:
        the SchemaAndValue; may not be null
      • fromConnectHeader

        public byte[] fromConnectHeader​(String topic,
                                        String headerKey,
                                        Schema schema,
                                        Object value)
        Description copied from interface: HeaderConverter
        Convert the Header's value into its byte array representation.
        Specified by:
        fromConnectHeader in interface HeaderConverter
        Parameters:
        topic - the name of the topic for the record containing the header
        headerKey - the header's key; may not be null
        schema - the schema for the header's value; may be null
        value - the header's value to convert; may be null
        Returns:
        the byte array form of the Header's value; may be null if the value is null