Skip to content

Spring Boot + Kafka example using Avro schema (with Schema Registry integration), and just a standalone Avro encode/decode example in Java

Notifications You must be signed in to change notification settings

codingkiddo/avro-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Avro Examples (Standalone + Spring Boot + Kafka + Schema Registry)

1) Standalone (pure Java)

cd standalone
mvn -q clean package
# Run (make sure it compiles the generated sources)
mvn -q -DskipTests exec:java -Dexec.mainClass=com.codingkiddo.avro.AvroDemo
# or: java -cp target/classes:$(dependency:list -DincludeScope=runtime) com.codingkiddo.avro.AvroDemo

This writes user.avro and reads it back.

2) Spring Boot + Kafka + Schema Registry

Start infra (Kafka in KRaft mode + Schema Registry):

cd spring-boot-kafka-avro
docker compose up -d

Then run the app:

mvn -q spring-boot:run

Produce a message:

curl -X POST http://localhost:8080/api/users   -H "Content-Type: application/json"   -d '{"id":1,"name":"Vinod Kumar","email":"vinod@codingkiddo.com"}'

Watch the logs for the consumer output.

Topic: users-avro

If you prefer Confluent CLI or kcat, you can inspect topics and schema at http://localhost:8081.

About

Spring Boot + Kafka example using Avro schema (with Schema Registry integration), and just a standalone Avro encode/decode example in Java

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages