@InterfaceStability.Unstable public class GenericAvroSerde extends Object implements org.apache.kafka.common.serialization.Serde<org.apache.avro.generic.GenericRecord>
SpecificAvroSerde.
This serde reads and writes data according to the wire format defined at
http://docs.confluent.io/current/schema-registry/docs/serializer-formatter.html#wire-format.
It requires access to a Confluent Schema Registry endpoint, which you must
GenericAvroDeserializer.configure(Map, boolean) via the parameter
"schema.registry.url".
Usage
Example for configuring this serde as a Kafka Streams application's default serde for both record keys and record values:
Properties streamsConfiguration = new Properties();
streamsConfiguration.put(StreamsConfig.KEY_SERDE_CLASS_CONFIG, GenericAvroSerde.class);
streamsConfiguration.put(StreamsConfig.VALUE_SERDE_CLASS_CONFIG, GenericAvroSerde.class);
streamsConfiguration.put(
AbstractKafkaAvroSerDeConfig.SCHEMA_REGISTRY_URL_CONFIG,
"http://confluent-schema-registry-server:8081/");
Example for explicitly overriding the application's default serdes (whatever they were
configured to) so that only specific operations such as KStream#to() use this serde:
Serde<GenericRecord> genericAvroSerde = new GenericAvroSerde();
boolean isKeySerde = false;
genericAvroSerde.configure(
Collections.singletonMap(
AbstractKafkaAvroSerDeConfig.SCHEMA_REGISTRY_URL_CONFIG,
"http://confluent-schema-registry-server:8081/"),
isKeySerde);
KStream<String, GenericRecord> stream = ...;
stream.to(Serdes.String(), genericAvroSerde, "my-output-topic");
| Constructor and Description |
|---|
GenericAvroSerde() |
GenericAvroSerde(SchemaRegistryClient client)
For testing purposes only.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
configure(Map<String,?> serdeConfig,
boolean isSerdeForRecordKeys) |
org.apache.kafka.common.serialization.Deserializer<org.apache.avro.generic.GenericRecord> |
deserializer() |
org.apache.kafka.common.serialization.Serializer<org.apache.avro.generic.GenericRecord> |
serializer() |
public GenericAvroSerde()
public GenericAvroSerde(SchemaRegistryClient client)
public org.apache.kafka.common.serialization.Serializer<org.apache.avro.generic.GenericRecord> serializer()
serializer in interface org.apache.kafka.common.serialization.Serde<org.apache.avro.generic.GenericRecord>public org.apache.kafka.common.serialization.Deserializer<org.apache.avro.generic.GenericRecord> deserializer()
deserializer in interface org.apache.kafka.common.serialization.Serde<org.apache.avro.generic.GenericRecord>public void configure(Map<String,?> serdeConfig, boolean isSerdeForRecordKeys)
configure in interface org.apache.kafka.common.serialization.Serde<org.apache.avro.generic.GenericRecord>public void close()
close in interface Closeableclose in interface AutoCloseableclose in interface org.apache.kafka.common.serialization.Serde<org.apache.avro.generic.GenericRecord>Copyright © 2026 Confluent, Inc.. All rights reserved.