kafka-for-developers-using-spring-boot
This repository has the complete code related to kafka producers/consumers using spring boot.
- Setup-Kafka
- or run kafka in docker using the docker-compose command:
docker-compose up -d
Run producer application
./library-events-producer/gradlew -p ./library-events-producer/ bootRun
Run consumer application
./library-events-consumer/gradlew -p ./library-events-consumer/ bootRun
Send message
curl -i \
-d '{"libraryEventId":null,"book":{"bookId":456,"bookName":"Kafka Using Spring Boot","bookAuthor":"Dilip"}}' \
-H "Content-Type: application/json" \
-X POST http://localhost:8080/v1/libraryevent
Check message in consumer
Consumer record ConsumerRecord(topic = library-events, partition = 0, leaderEpoch = 0, offset = 1, CreateTime = 1657787450677, serialized key size = -1, serialized value size = 128, headers = RecordHeaders(headers = [RecordHeader(key = header, value = [118, 97, 108, 117, 101])], isReadOnly = false), key = null, value = {"libraryEventId":null,"book":{"bookId":456,"bookName":"Kafka Using Spring Boot","bookAuthor":"Dilip"},"libraryEventType":"NEW"})
Securing your Kafka Cluster using SSL
H2 Database
- Access the h2 database in the following link - http://localhost:8081/h2-console