Skip to content

roek5803/spring-boot-kafka-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring boot kafka example

This is an example how to use Spring Boot together with Kafka as a event bus and protobuf as protocol.

  • Spring boot
  • Kafka Producer
  • Kafka Consumer
  • Protobuf
  • Eventsourcing

Try it out locally

Build the jars and docker images.

mvn clean install -P docker

Start up the system with docker-compose

docker-compose up -d

Confirm that the services has been started

docker ps -a

Create a message

curl -X POST \
  http://localhost:8080/producer-service/api/v1/message/createMessage \
  -H 'Content-Type: application/json' \
  -d '{
	"message": "HELLO WORLD!"
}'

Take the id from the previous response and change that message

curl -X POST \
  http://localhost:8080/producer-service/api/v1/message/changeMessage \
  -H 'Content-Type: application/json' \
  -d '{
	"id": "<ID_YOU_WANT_TO_CHANGE>",
	"message": "YET ANOTHER HELLO WORLD!"
}'

Fetch all the messages that we have consumed in the consumer service.

curl -X GET http://localhost:8081/consumer-service/api/v1/message