A simple example for an Event Driven Flow by the help of SPRING CLOUD STREAM KAFKA
- java.version:
11
- spring-cloud.version:
Hoxton.SR11
(To get Advantage of Binders@Input
,@Output
) - spring-boot.version:
2.4.5
Please visit Spring Cloud Stream Kafka (Part 1) for Project documentation
The Docker-compose file contains: single kafka and zookeeper. just simply run the following command
docker-compose up -d
Note: docker-compose file is at the root of this project "/scs-kafka-intro"
Run the First Test:
mvn clean package
Then run the generated jar file in target
folder, (so make sure you are in the same directory when you run the jar
file or give the full path)
java -jar scs-099-0.0.1-SNAPSHOT.jar
the application starts to listen on port 8080. make sure that port is not occupied by any other app already, if is try
to pass the following parameter before -jar
by adding -Dserver.port=8081
Basically in this test, Producer adding 10 messages into kafka topic every 5 sec.
java -Dspring.profiles.active=test2 -jar scs-099-0.0.1-SNAPSHOT.jar
java -Dspring.profiles.active=test3 -jar scs-099-0.0.1-SNAPSHOT.jar
Run the following codes in 3 different terminal
on Terminal-1: (this app has one Producer and one consumer)
java -Dspring.profiles.active=test2 -jar scs-099-0.0.1-SNAPSHOT.jar
on Terminal-2: (this app has only one consumer)
java -Dspring.profiles.active=test2 -Dserver.port=8081 -jar scs-099-0.0.1-SNAPSHOT.jar
on Terminal-3: (this app has only one consumer)
java -Dspring.profiles.active=test2 -Dserver.port=8082 -jar scs-099-0.0.1-SNAPSHOT.jar
Please visit Spring Cloud Stream Kafka (Part 1) for Project documentation