architecture – How to design asynchronous communication in microservices?


Hey, my question is kind of hard to explain so I apologize in advance.


I’m trying to implement microservices for our ecommerce and I’m having issues on how to respond to a request when the actual logic and data needs to be determined by other ( 2-3 ) services.

In order to make it easier to understand, I’ll give an example.

Lets say User A is trying to buy a product. after clicking on “check out” button these steps should happen.


Request comes in:

  • Ecommerce service:
    1. Check if product has enough quantity in inventory.
    2. Publish an event indicating a new order has been created. order:created
  • Anti Fraud service:
    1. Receives order:created and checks whether the user is a fraud or not
    2. Publishes an event indicating the check was successful. check:succeed
  • Payment Service:
    1. Receives check:succeed and creates a url to the gateway.
    2. Sends the gateway url to the user, possibly publishing payment:created event. (( this is where my question is ))

Since all of these steps are asynchronous, how do I respond to the Request?

Possible Solution

After the user has requested to checkout, the ecommerce service creates an order and responds immediately with the orderId of newly created order, on client-side the user has to request periodically and check whether the status of order is PENDING PAYMENT, in order to achieve this, the payment service needs to publish payment:created after the order has been approved by the system and then ecommerce service can update the order.

My solution works, but I’m really new to microservices and I want to know if there’s a better way to implement this.

I really appreciate if you read this far, Thank you for your time.