This project demonstrates how to integrate Apache Kafka with the DeliveryBoy and EndUser microservices, enabling efficient messaging and data flow between them. Built with Spring Boot, this project features both Kafka producer and consumer implementations.
- Kafka Producer & Consumer setup for two microservices:
DeliveryBoyandEndUser. - Kafka Configuration for both microservices via
application.ymlfiles. - Kafka Service implementations to manage message flow between services.
- Integration of Kafka topics for communication.
KafkaConfig.java: Configures Kafka producer and consumer.LocationController.java: Handles incoming location-related requests.KafkaService.java: Contains Kafka producer and consumer logic.application.yml: Kafka configuration (topic names, bootstrap servers, etc.).
KafkaConfig.java: Configures Kafka producer and consumer.AppConstants.java: Contains constants used throughout the application.application.yml: Kafka configuration (topic names, bootstrap servers, etc.).
Before you begin, ensure that you have the following installed:
- Java 17 or above
- Apache Kafka and Zookeeper running locally or remotely
- Maven for building and running the project
First, make sure that Zookeeper and Kafka are up and running. Open separate terminal windows and start them:
# Start Zookeeper
bin\windows\zookeeper-server-start.bat config\zookeeper.properties
# Start Kafka
bin\windows\kafka-server-start.bat config\server.properties
3. Running the Microservices
Now, navigate to the deliveryboy and enduser directories in separate terminals and run:
# For DeliveryBoy microservice
mvn spring-boot:run
# For EndUser microservice
mvn spring-boot:run
4. Creating Topics in Kafka
You may need to create topics for communication between the services. Use the following commands to create topics:
# Create Kafka topics (Example)
bin\windows\kafka-topics.sh --create --topic delivery-topic --bootstrap-server localhost:9092 --partitions 1 --replication-factor 1
bin\windows\kafka-topics.sh --create --topic enduser-topic --bootstrap-server localhost:9092 --partitions 1 --replication-factor 1
5. Testing the Communication
After starting both services and creating the topics, you can test communication by sending messages through the Kafka producer and consuming them with the consumer logic in both microservices.
📜 Technologies Used
Spring Boot
Apache Kafka
Java 17
Maven
🧑💻 Contributing
Feel free to fork this repository and submit pull requests. Contributions are always welcome! 🙌
📝 License
This project is licensed under the MIT License - see the LICENSE file for details.
Feel free to connect and share your thoughts on this project! 😄
markdown
Copy
Edit
### Steps to Add to Your Repository:
1. **Create a `README.md` file** at the root of your project if it doesn't already exist.
2. **Paste the content** above into your `README.md` file.
3. **Commit and push** it to your GitHub repository:
```bash
git add README.md
git commit -m "Added stylish README with project details"
git push origin main