Interface HeaderConverter
- All Superinterfaces:
AutoCloseable,Closeable,org.apache.kafka.common.Configurable
- All Known Implementing Classes:
SimpleHeaderConverter,StringConverter
The HeaderConverter interface provides support for translating between Kafka Connect's runtime data format and byte[]. This is similar to the
Converter interface, but specifically for Headers. Kafka Connect may discover implementations of this interface using the Java ServiceLoader mechanism. To support this, implementations of this interface should also contain a service provider configuration file in META-INF/services/org.apache.kafka.connect.storage.HeaderConverter.
Implement Monitorable to enable the converter to register metrics. The following tags are automatically added to all metrics registered: connector set to connector name, task set to the task id and converter set to header.
Method Summary
Modifier and TypeMethodDescriptionorg.apache.kafka.common.config.ConfigDefconfig()Configuration specification for this set of header converters.byte[]fromConnectHeader(String topic, String headerKey, Schema schema, Object value) toConnectHeader(String topic, String headerKey, byte[] value) Convert the header name and byte array value into aHeaderobject.Methods inherited from interface org.apache.kafka.common.Configurable
configure
Method Details
toConnectHeader
Convert the header name and byte array value into aHeaderobject.- Parameters:
topic- the name of the topic for the record containing the headerheaderKey- the header's key; may not be nullvalue- the header's raw value; may be null- Returns:
- the
SchemaAndValue; may not be null
fromConnectHeader
- Parameters:
topic- the name of the topic for the record containing the headerheaderKey- the header's key; may not be nullschema- the schema for the header's value; may be nullvalue- 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
config
org.apache.kafka.common.config.ConfigDef config()Configuration specification for this set of header converters.- Returns:
- the configuration specification; may not be null