This module consumes records of type <String, KafkaUser>
from the USER_TOPIC
and handles deserialization exceptions using the circuit breaker pattern.
It demonstrates the following:
- How to use the Kafka Clients consumer API.
- How to work with Apache Avro.
- Unit testing with a mock consumer.
To compile and run this demo, you’ll need:
- Java 21
- Maven
- Docker
To run the application manually:
- Start a Confluent Platform in a Docker environment.
- Produce records of type
<String, KafkaUser>
to theUSER_TOPIC
. You can use the Producer Avro Specific for this. - Intentionally trigger a deserialization exception by either:
- Deleting the Avro schema from the schema registry.
- Producing a non-Avro message (e.g., a plain String) to the
USER_TOPIC
.
- Start the consumer.
To run the application in Docker, use the following command:
docker-compose up -d
This command will start the following services in Docker:
- 1 Kafka Broker (KRaft mode)
- 1 Schema Registry
- 1 Control Center
- 1 Producer Avro Specific
- 1 Circuit Breaker Consumer