Demo project to implement Apache Kafka using Spring Boot
- JDK
- Maven
- Apache Kafka
- IDE (Eclipse/Intellij IDEA/STS)
-
Clone the Repository
git clone https://github.com/AdityaCH1997/SpringBootKafkaIntegrationDemo.git cd SpringBootKafkaIntegrationDemo -
Build the Application
mvn clean install -
Start Zookeeper Service
Open a new Terminal/CLI and navigate to the locally installed kafka directory.
For Mac/Linux:
bin/zookeeper-server-start.sh config/zookeeper.propertiesFor Windows:
.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.propertiesThe service under default settings will start at port 2081
-
Start Kafka Broker Service
Open a new Terminal/CLI and navigate to the locally installed kafka directory.
For Mac/Linux:
bin/kafka-server-start.sh config/server.propertiesFor Windows:
.\bin\windows\kafka-server-start.bat .\config\server.propertiesThe service under default settings will start at port 9092
-
Bootstrap the Spring Boot Application
Opening the Project 'SpringBootKafkaIntegrationDemo' directory in any IDE and starting(build and run) the application will work. To do the same from Terminal/CLI execute the below commands:
Open a new Terminal/CLI and navigate to the local Project directory.
Build the Project:
mvnw packageRun the Application:
java -jar target/SpringBootKafkaIntegrationDemo.jarThe Application under default settings will start at port 8080
- Spring Boot:
- Modify
application.propertiesorapplication.ymlin the Spring Boot application for server, consumer and producer configurations.
- The Application interacts with Kafka when the exposed APIs are called and publish messages to specific Kafka topics in the Kafka broker which is then consumed by the Kafka Consumers from the Consumer Group.
- After usage kill all the running services and the application using
Ctrl + C.