Skip to content
Kafka Is Fun

Advanced Patterns · Advanced · Topic 1 of 5

Avro Serialization with Schema Registry

Avro with Confluent Schema Registry registers each schema and checks every new version for compatibility with the previous ones, using the subject's compatibility type (BACKWARD by default). The serializers are Confluent's KafkaAvroSerializer and KafkaAvroDeserializer; they are not part of Spring or Kafka.

application.yml (Avro config)yaml
spring:
  kafka:
    producer:
      value-serializer: io.confluent.kafka.serializers.KafkaAvroSerializer
      properties:
        schema.registry.url: http://schema-registry:8081
        auto.register.schemas: true     # the default: register the schema if it is new
        # use.latest.version only applies when auto.register.schemas is false

    consumer:
      value-deserializer: io.confluent.kafka.serializers.KafkaAvroDeserializer
      properties:
        schema.registry.url: http://schema-registry:8081
        specific.avro.reader: true   # default false (GenericRecord); true returns generated classes
OrderEvent.avsc (Avro schema)json
{
  "type": "record",
  "name": "OrderEvent",
  "namespace": "com.example.events",
  "fields": [
    { "name": "orderId", "type": "string" },
    { "name": "customerId", "type": "string" },
    { "name": "status", "type": "string" },
    { "name": "amount", "type": "double" },
    { "name": "timestamp", "type": { "type": "long", "logicalType": "timestamp-millis" } },
    { "name": "metadata", "type": ["null", "string"], "default": null }
  ]
}

Sources

Checked against Spring for Apache Kafka 4.1.1, Spring Boot 4.1.1 and Kafka 4.2 documentation on 11 October 2026. Draft: not yet reviewed by a Kafka specialist, and releases move on, so confirm against the current documentation before you act on it.