Skip to content

Spring Boot Kafka Consumer example built using Gradle. Showcases error handling, payload consumption, listener creation, junit testing, health endpoint, and more.

License

Notifications You must be signed in to change notification settings

DLaMott/spring-boot-kafka-consumer

Repository files navigation

Spring Boot KafkaConsumer

Features

  • Spring-Boot kafka consumer showcase
  • JUnit
  • Localstack configuration
  • Gradle implementation

Don't want the code?

Use my kafka consumer generator! Requires Node/ NPM to be set up

> npm install -g yo
> npm install -g generator-spring-boot-kafka-consumer
> yo generator-spring-boot-kafka-consumer

Local Development Setup:

Steps To test Consumer against a Producer

  1. Ensure Kafka is installed on your local machine:

  2. Start Kafka!

  • .\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties to start zookeeper
  • .\bin\windows\kafka-server-start.bat .\config\server.properties to start kafka server
  1. Create Topic:
  • .\bin\windows\kafka-topics.bat --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test-topic

  • View Topics:

    • .bin\windows\kafka-topics.bat --list --bootstrap-server localhost:9092
  1. Produce Topic:
  • .\bin\windows\kafka-console-producer -broker-list localhost:9092 -topic test-topic

  • Sample Payload:

    • {"data":{"operation":"update","eventKey":"JohnSmith"},"metadata":{"dataClassification":"public","eventDateTime":"2023-12-21T05:05:15.65445Z","eventId":"23434-343-3434-33","topicName":"test-topic", "eventName":"fire-topic", "version":"v1"}}

About

Spring Boot Kafka Consumer example built using Gradle. Showcases error handling, payload consumption, listener creation, junit testing, health endpoint, and more.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages