/kafka-springboot

:loop: Kafka / Spring boot

Primary LanguageJava

kafka-for-developers-using-spring-boot

This repository has the complete code related to kafka producers/consumers using spring boot.

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

list message commands

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

KafkaProducer

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"})

KafkaConsumer

Securing your Kafka Cluster using SSL

H2 Database