I have a microservice based application like so:
User.Microservice – stores , user information.
Product.Microservice – stores products that user created.
Order.Microservices – stores product orders
RabbitMQ – for Event based communication
MongoDB – for Data Storage
Each service has a public HTTP REST API.
Each service can publish and consume messages from RABBITMQ
Here is how everything communicates:
Client makes a request to API GATEWAY:
lets suppose client makes a
POST request to product service -> the product has user reference and other details about a product.
Well now if i want to populate product item with user details such as user’s username, the API GATEWAY should make a
GET request to user service.
Here comes the data replication part i have to add the required information about user to product service.
How can i replicate user details to product service after a product is created ? And return the response to
POST request along with user’s username ? if it is not present in product service…
I could use the current API GATEWAY method where the gateway calls user service , but if the user service goes down i will not have the required user details…
Somehow i need to run bus events before the response from
POST request is returned…