官术网_书友最值得收藏!

A reactive microservice-based order management system

Let's examine another microservices example: an online retail web site. In this case, we will focus more on the backend services, such as the order event generated when the customer places an order through the website:

This microservices system is completely designed based on reactive programming practices.

When an event is published, a number of microservices are ready to kick start upon receiving the event. Each one of them is independent and is not relying on other microservices. The advantage of this model is that we can keep adding or replacing microservices to achieve specific needs.

In the preceding diagram, there are eight microservices shown. The following activities take place on arrival of an OrderEvent:

  • OrderService kicks off when an OrderEvent is received. OrderService creates an order and saves details to its own database.
  • If the order is successfully saved, an OrderSuccessfulEvent is created by OrderService and published.
  • A series of actions will take place when OrderSuccessfulEvent arrives.
  • DeliveryService accepts the event and places a DeliveryRecord to deliver the order to the customer. This in turn generates DeliveryEvent and publishes the event.
  • The TruckingService picks up the DeliveryEvent and processes it. For instance, TruckingService creates a trucking plan.
  • CustomerNotificationService sends a notification to the customer informing the customer that an order is placed.
  • InventoryCacheService updates the inventory cache with the available product count.
  • StockReorderService checks whether the stock limits are adequate and generates ReplenishEvent if required.
  • CustomerPointsService recalculates the customer's loyalty points based on this purchase.
  • CustomerAccountService updates the order history in the customer account.

In this approach, each service is responsible for only one function. Services accept and generate events. Each service is independent and is not aware of its neighborhoods. Hence, the neighborhood can organically grow as mentioned in the honeycomb analogy. New services could be added as and when necessary. Adding a new service does not impact any of the existing service.

主站蜘蛛池模板: 阿勒泰市| 淅川县| 武穴市| 武义县| 赣州市| 西充县| 葵青区| 尼玛县| 都江堰市| 永登县| 宁强县| 邛崃市| 长沙市| 日照市| 临泉县| 林州市| 镶黄旗| 土默特右旗| 胶州市| 甘孜县| 仙游县| 鸡东县| 都匀市| 巴林左旗| 定安县| 酒泉市| 新干县| 札达县| 万载县| 甘孜| 来凤县| 汉中市| 南投市| 进贤县| 兴城市| 娄底市| 岳普湖县| 濮阳县| 五莲县| 丰顺县| 枣强县|