Skip to content

Reference / template for a Kafka producer-consumer mechanism

Notifications You must be signed in to change notification settings

squidmin/kafka-api-blueprint

Repository files navigation

kafka-api-blueprint

Reference / template for a Kafka producer-consumer mechanism.

See also:

Build the JAR files

cd ../kafka-producer-blueprint
./gradlew clean build
cd ../kafka-consumer-blueprint
./gradlew clean build
cd ../kafka-api-blueprint
./gradlew clean build

Start the services

docker-compose up --build

Verify Kafka Installation

Create a Kafka topic

docker-compose exec kafka kafka-topics.sh --create --topic another-test-topic --bootstrap-server kafka:9092 --partitions 1 --replication-factor 1

List Kafka topics

docker-compose exec kafka kafka-topics.sh --list --bootstrap-server kafka:9092

Test the Kafka integration

  • Use Postman or a browser to access the API endpoint:

    http://localhost:8083/publish?message=HelloKafka
    
  • The message will be forwarded to the producer application, which will then publish it to Kafka.

Stop and remove all containers

docker-compose down

Remove existing containers, volumes, and images

docker-compose down -v --rmi all

Reference Documentation

Additional Links

These additional references should also help you: