public interface Converter
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.Converter
.
Modifier and Type | Method and Description |
---|---|
default org.apache.kafka.common.config.ConfigDef |
config()
Configuration specification for this converter.
|
void |
configure(Map<String,?> configs,
boolean isKey)
Configure this class.
|
default byte[] |
fromConnectData(String topic,
org.apache.kafka.common.header.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.
|
SchemaAndValue |
toConnectData(String topic,
byte[] value)
Convert a native object to a Kafka Connect data object for deserialization.
|
default SchemaAndValue |
toConnectData(String topic,
org.apache.kafka.common.header.Headers headers,
byte[] value)
Convert a native object to a Kafka Connect data object for deserialization,
potentially using the supplied topic and headers in the record as necessary.
|
void configure(Map<String,?> configs, boolean isKey)
configs
- configs in key/value pairsisKey
- whether this converter is for a key or a valuebyte[] fromConnectData(String topic, Schema schema, Object value)
topic
- the topic associated with the dataschema
- the schema for the valuevalue
- the value to convertdefault byte[] fromConnectData(String topic, org.apache.kafka.common.header.Headers headers, Schema schema, Object value)
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.
topic
- the topic associated with the dataheaders
- the headers associated with the data; any changes done to the headers
are applied to the message sent to the brokerschema
- the schema for the valuevalue
- the value to convertSchemaAndValue toConnectData(String topic, byte[] value)
topic
- the topic associated with the datavalue
- the value to convertSchema
and the converted valuedefault SchemaAndValue toConnectData(String topic, org.apache.kafka.common.header.Headers headers, byte[] value)
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.
topic
- the topic associated with the dataheaders
- the headers associated with the datavalue
- the value to convertSchema
and the converted valuedefault org.apache.kafka.common.config.ConfigDef config()