Spring Microservice - Event-driven Architecture - E-commerce Application #146
Replies: 19 comments 1 reply
-
|
Hi Akash, I have completed the Microservice for the ecommerce project. The last part of merging the two topics is pending. Not able to find the solution for the same. Thanks, |
Beta Was this translation helpful? Give feedback.
-
|
Hi Akash, I have completed the Microservice for e-com project. Please check and let me know your feedback.
Thanks & Regards, |
Beta Was this translation helpful? Give feedback.
-
|
Hi Akash, I have completed the ecommerce-order-service containing global exceptions, response value objects, response entities with proper http status code and docker file. Could you please let me know your feedback, I will complete rest of the services by tomorrow. https://github.com/DusaSuresh/Ecommerce-order-service/tree/main |
Beta Was this translation helpful? Give feedback.
-
|
Hi @akash-coded , Name: Anurag Mishra Implemented event driven messaging architecture using kafka between order and inventory service. It would update inventory quantity whenever new order is placed. Please find zip below:- |
Beta Was this translation helpful? Give feedback.
-
|
Hi @akash-coded Name: Jay Prakash Kumar Implemented event-driven messaging architecture with RabbitMQ using order and inventory service. Inventory quantity will be updated whenever a new order gets placed. Here are the repositories - |
Beta Was this translation helpful? Give feedback.
-
|
EDA-ecomm.zip |
Beta Was this translation helpful? Give feedback.
-
|
Session_7_eventdriven_Architecture.zip Name: Aathira PS |
Beta Was this translation helpful? Give feedback.
-
|
task146.zip |
Beta Was this translation helpful? Give feedback.
-
|
kushal naik |
Beta Was this translation helpful? Give feedback.
-
|
Assignment_05092023.zip |
Beta Was this translation helpful? Give feedback.
-
|
Hi @akash-coded please find the attached project |
Beta Was this translation helpful? Give feedback.
-
|
Hi @akash-coded , Name : Kiran Ramesh (1949256) Please find the assignment of [Event-driven Architecture] |
Beta Was this translation helpful? Give feedback.
-
|
@akash-coded : https://github.com/arghyagiri/microservice-e2/tree/main/e-commerce-microservices-event-driven |
Beta Was this translation helpful? Give feedback.
-
|
Hi @akash-coded |
Beta Was this translation helpful? Give feedback.
-
|
@akash-coded Please find attached EDA implementation with Kafka |
Beta Was this translation helpful? Give feedback.
-
|
Hi Akash @akash-coded , Please find attached the event driven code with order service and inventory service Name: Arul Adding reference to partial completed guided excercise 172 (Using this comment as placeholder for partial completed code upload) Updated 26-Nov |
Beta Was this translation helpful? Give feedback.
-
|
Hi Akash. Here are the 3 services:- Implemented using Kafka. Thanks |
Beta Was this translation helpful? Give feedback.
-
|
Hi @akash-coded , Sharing my code in zip file for Spring Microservice - Event-driven Architecture - E-commerce Application |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Creating a microservice architecture-based Spring Boot application for an e-commerce scenario involves a series of steps including creating individual services, implementing business logic, handling data storage, and ensuring asynchronous communication via events. Let's break down the steps for creating the Order Service, Inventory Service, Billing Service, and Shipping Service.
Technologies used:
1. Order Service
The Order Service is responsible for accepting customer orders and publishing events about these orders.
2. Inventory Service
The Inventory Service manages stock levels and listens for "OrderPlaced" events to update the inventory.
3. Billing Service
The Billing Service is responsible for charging customers and listens for "OrderPlaced" events to create bills.
4. Shipping Service
The Shipping Service arranges delivery for orders and listens for "InventoryUpdated" and "BillGenerated" events to arrange shipment.
5. Error Handling and Synchronization
6. Dockerization
Dockerfilefor each service, then build and run the docker containers.Note: The above steps outline the design of the microservices and the flow of events between them. The actual implementation would involve writing the Spring Boot code for controllers, services, repositories, models, and the Kafka producer/consumer configurations. Also, security, logging, monitoring, testing, and other aspects would need to be addressed in a complete, production-ready application.
Let's consider four separate services:
Order Service,Inventory Service,Billing Service, andShipping Service.1. Order Service
Folder Structure:
2. Inventory Service
3. Billing Service
│ │ │ │ │ │ │ ├── BillingRepository.java
│ │ │ │ │ │ ├── service
│ │ │ │ │ │ │ ├── BillingService.java
│ │ │ │ │ │ ├── messaging
│ │ │ │ │ │ │ ├── BillingEventConsumer.java
│ │ │ │ │ │ ├── BillingserviceApplication.java
│ │ ├── resources
│ │ │ ├── application.properties
4. Shipping Service
Spring Dependencies:
spring-boot-starter-webspring-boot-starter-data-jpaspring-kafkaorspring-rabbitmqbased on your choice of message brokerspring-boot-starter-validationKafka/RabbitMQ Configuration:
These would go inside
application.propertiesfor each service.For Kafka:
For RabbitMQ:
You would also need to define Kafka/RabbitMQ templates and consumers in your service and messaging classes.
Note: While the above does provide a good outline, building microservices with Spring Boot and integrating with Kafka/RabbitMQ is a large topic and involves a detailed understanding of Spring Boot, JPA, Kafka/RabbitMQ, and how they all interact together. I would recommend referring to comprehensive resources or tutorials to guide you through building this application.
Dependencies for Microservices
Each microservice would need at least these dependencies:
Add these dependencies in the
pom.xmlfile of each microservice:Setting Up Apache Kafka From Scratch
You need to install and run Apache Kafka locally:
Download Apache Kafka from the official website. Unzip the downloaded file.
Start the Zookeeper server (Kafka uses Zookeeper to manage the cluster). Navigate to the Kafka directory in the terminal and run this command:
Start the Kafka server. In a new terminal window, navigate to the Kafka directory again and run:
Create a Kafka Topic. You can create a topic with the following command:
Running Microservices Together
Once your microservices and Kafka are set up, you can start each microservice from the terminal by navigating to the root directory of each microservice project and running:
Tips
Beta Was this translation helpful? Give feedback.
All reactions