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

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.

主站蜘蛛池模板: 阜城县| 区。| 张家口市| 乐安县| 昌图县| 天峻县| 靖远县| 璧山县| 岳阳县| 福鼎市| 宁阳县| 孝义市| 灵石县| 玉林市| 吉林市| 博乐市| 贡嘎县| 荆门市| 桃园县| 兴国县| 鄢陵县| 安康市| 商都县| 恩平市| 和田市| 多伦县| 许昌县| 定边县| 蓬溪县| 冕宁县| 定兴县| 合肥市| 太康县| 高淳县| 石台县| 泾源县| 湄潭县| 从化市| 宜章县| 鹤壁市| 上犹县|