Files
scs-100/scs-099
2021-05-17 10:39:22 -07:00
..
2021-05-17 09:36:46 -07:00
2021-05-16 19:02:05 -07:00
2021-05-16 19:02:05 -07:00
2021-05-16 19:02:05 -07:00
2021-05-17 10:39:22 -07:00

SCS-099

Producer Consumer

A simple Example of an Event Driven Flow by the help of SPRING CLOUD STREAM KAFKA

properties
  • java.version: 11
  • spring-cloud.version: Hoxton.SR11 (To get Advantage of Binders @Input,@Output)
  • spring-boot.version: 2.4.5

The Docker-compose file contains: single kafka and zookeeper. just simply run the following command

General Flow Diagram

docker-compose up -d

Note: docker-compose file is at the root of this project "/scs-kafka-intro"

Build the project

Run the First Test:

mvn clean package

Run the Application

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

Run the Test2

java -Dspring.profiles.active=test2 -jar scs-099-0.0.1-SNAPSHOT.jar

Run the Test3

java -Dspring.profiles.active=test3 -jar scs-099-0.0.1-SNAPSHOT.jar

Run the Test4

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