Search

CN-121981801-A - Event-driven-based micro-servitization order processing and transaction consistency guaranteeing method and system

CN121981801ACN 121981801 ACN121981801 ACN 121981801ACN-121981801-A

Abstract

The invention discloses a method and a system for event-driven-based microservice order processing and transaction consistency guarantee, wherein the method comprises the steps of creating an initial order event according to a multi-channel order request and carrying out asynchronous transmission; the method comprises the steps of carrying out state snapshot of a plurality of related micro services on order events to generate an order life cycle event and a state change sequence of each order, determining a cross-micro service transaction execution result of each order according to the order life cycle event and the state change sequence of each order, triggering compensation operation according to a tracing record when the execution result fails, periodically scanning micro service data streams of each order, carrying out anomaly detection and automatic data restoration, and displaying the full-link processing state of each order in real time. The final consistency of the cross-service business data is ensured, and the reliability, observability and maintainability of the order system are obviously improved through full-link state tracking and automatic exception handling.

Inventors

  • SHAN KANGNING
  • PENG WEILING
  • YANG CHENGZHI
  • NIU YING

Assignees

  • 深圳市链宇技术有限公司

Dates

Publication Date
20260505
Application Date
20260119

Claims (10)

  1. 1. The event-driven micro-servitization order processing and transaction consistency guaranteeing method is characterized by comprising the following steps of: Receiving and analyzing order requests from multiple channels, generating standardized initial order creation events based on a configurable rule engine, and asynchronously transmitting the order events by adopting a distributed message middleware; performing multiple related micro services on the order event based on the triggering business logic, storing state snapshots of objects in the field of each micro service transaction, and generating an order life cycle event and a state change sequence of each order according to the state snapshots; Determining the execution result of the cross-micro service transaction of each order according to the order life cycle event and the state change sequence thereof, and triggering compensation operation according to the traceability record when the execution result fails; And periodically scanning micro-service data streams of all orders, detecting abnormality and automatically repairing the data, and displaying the full-link processing state of each order in real time.
  2. 2. The event-driven microservice order processing and transaction consistency assurance method of claim 1, wherein the receiving and parsing order requests from multiple channels generates standardized initial order creation events based on a configurable rules engine, asynchronously delivering order events using distributed message middleware, comprising: Receiving original order requests through a multi-channel order access gateway, identifying source channels and agreement formats of each original order request, selecting a data acquisition mode based on the agreement formats, and acquiring original order data of each original order request from the source channels; Sequentially performing verification, cleaning, mapping, enriching and routing decision processing on the original order data according to a predefined rule set; converting the processed original order data into a standardized order object with uniform structure definition, and packaging the standardized order object into an initial order creation event; The initial order creation event is asynchronously published to a designated topic or queue of the distributed message middleware cluster.
  3. 3. The event-driven microservice order processing and transaction consistency assurance method according to claim 2, wherein the receiving the original order requests through the multi-channel order access gateway and identifying the source channel and the agreement format of each original order request, selecting a data acquisition mode based on the agreement format and acquiring the original order data of each original order request from the source channel comprises: Continuously monitoring connection requests from different channels through a plurality of protocol monitors deployed on the gateway; When any agreement monitor receives an original order request, extracting metadata of the original order request, and identifying a specific source channel and an agreement format of the original order request based on channel identification, agreement characteristics and request characteristics in the metadata; Dynamically selecting and loading corresponding data acquisition adapters from a preconfigured adapter registry according to the identified protocol format; And calling a data acquisition adapter, and interacting with the source channel according to the communication specification of the identified protocol format to acquire complete original order data.
  4. 4. The event-driven microservice-based order processing and transaction consistency guarantee method according to claim 1, wherein the generating an order life cycle event and a state change sequence thereof for each order according to the state snapshots by performing multiple related microservices on the order event based on triggering business logic and storing state snapshots of objects in each microservice transaction field comprises: Based on business logic of each order management micro-service, driving a domain state machine of the order management micro-service to update an initial entity state snapshot corresponding to an order event and storing the initial entity state snapshot into a global state-event storage center; Based on the inventory micro-service and the performance micro-service, each order event is processed in parallel, a respective domain state machine is driven to update the inventory reservation state and generate the performance plan state, respective subsequent entity state snapshots are stored, and related domain events are issued; Repeating the triggering, processing, storing and publishing processes for the subsequent micro-services until all related micro-services related to the order process complete the service logic and update the state; And generating a complete life cycle event of each order and a state change sequence thereof according to the time line and the business logic by an order life cycle sequence generator according to the state snapshot of all relevant entities of each order stored in the global state-event storage center.
  5. 5. The event-driven microservice-based order processing and transaction consistency guarantee method according to claim 4, wherein the generating, by the order lifecycle sequence generator, the complete lifecycle events and the state change sequences thereof for each order according to the state snapshots of all relevant entities of each order stored in the global state-event storage center according to the time line and the business logic comprises: inquiring and acquiring a state snapshot set of all field entities logically associated with each order from a global state-event storage center according to the order identification of the order; extracting a state effective time stamp field in each state snapshot in the state snapshot set, and performing global time sequence sequencing on all the snapshots to generate a state snapshot time line; Scanning a state snapshot timeline, aggregating and interpreting a plurality of consecutive related state snapshots into order lifecycle events having high level business semantics according to predefined business logic rules; And arranging all the generated order life cycle events according to the time sequence of the corresponding state snapshot, and outputting the complete life cycle event sequence of each order.
  6. 6. The event-driven microservice-based order processing and transaction consistency guarantee method according to claim 1, wherein the determining the execution result of the cross-microservice transaction of each order according to the lifecycle event of the order and the state change sequence thereof and triggering the compensation operation according to the trace record when the execution result fails comprises: Judging the final execution result of the cross-microservice distributed transaction corresponding to each order according to the order lifecycle event sequence through a preset transaction success/failure judgment rule base; analyzing the sequence of event fragments of the life cycle of the order which causes failure when judging that the execution of the transaction fails, and combining detailed event tracing records in a global state-event storage center to locate specific micro-service operation which is successfully executed but needs rollback or correction; Determining a rollback or correction operation set of a specific micro-service operation, and determining an execution object and an order of a compensation operation based on the rollback or correction operation set; and generating a compensation instruction sequence aiming at the specific micro-service based on the execution object and the sequence of the compensation operation, and calling a compensation interface of the specific micro-service to carry out the compensation operation according to the business dependence reverse sequence.
  7. 7. The event-driven microservice-based order processing and transaction consistency assurance method of claim 6, wherein the determining a rollback or correction operation set for a particular microservice operation, determining an execution object and order of compensation operations based on the rollback or correction operation set, comprises: acquiring a business activity execution list corresponding to a specific micro-service operation, and determining a necessary rollback operation subset in the business activity execution list based on a preset business activity dependency graph; evaluating whether other operations which are not included in the necessary rollback operation subset in the business activity execution list can exist independently in a business isolation state, and if not, adding the operations into the recommended correction operation subset; combining the necessary rollback operation subset with the suggested correction operation subset to form a final rollback and correction operation set; And determining the execution object and the execution sequence of each compensation operation in the rollback and correction operation set according to the dependency relationship among the operations, the data coupling degree and the business rule, and generating a compensation instruction execution plan.
  8. 8. The event-driven microservice-based order processing and transaction consistency guarantee method according to claim 1, wherein the periodically scanning microservice data streams of each order and performing anomaly detection and automatic data restoration, displaying the full-link processing state of each order in real time comprises: acquiring micro-service data streams of each order range from a global state-event storage center according to a scheduling strategy, performing rule matching on the micro-service data streams according to a preset abnormality detection rule base, and detecting abnormal data; Determining the data type of the abnormal data, matching a repair strategy according to the data type, generating and executing repair operation for an automatic repair item allowed by the repair strategy, and generating a repair work order for a manual repair item needing manual processing; Dynamically aggregating the latest all-link state information of each order after consistency verification, and rendering all nodes, states and abnormal points in the all-link state information in real time in a graphical time line or topological graph form; and highlighting, early warning or blocking prompt is carried out on the detected abnormal state.
  9. 9. The event-driven microservice-based order processing and transaction consistency guarantee method according to claim 8, wherein the obtaining the microservice data stream of each order range from the global state-event storage center according to the scheduling policy, performing rule matching on the microservice data stream according to a preset abnormality detection rule base, and detecting abnormal data comprises: Determining a current completion phase of each order from a global state-event storage center, determining whether the current completion phase meets a specific phase; If yes, acquiring the full-quantity micro-service data flow of each order range from a global state-event storage center through an order state triggering scheduling strategy; Converting the full-volume micro-service data stream into a fact object which can be processed by a rule engine, and carrying out rule matching by the rule engine according to a preset abnormality detection rule base fact object; Abnormal data existing in the full-volume micro-service data stream is detected through the matching rule, wherein the abnormal data comprises data inconsistency, logic conflict and flow violations.
  10. 10. An event-driven micro-servitization order processing and transaction consistency guaranteeing system, which is characterized by comprising: The first generation module is used for receiving and analyzing order requests from multiple channels, generating standardized initial order creation events based on a configurable rule engine and asynchronously transmitting the order events by adopting a distributed message middleware; the second generation module is used for carrying out multiple related micro services on the order event based on the triggering business logic, storing state snapshots of objects in the field of each micro service transaction, and generating an order life cycle event and a state change sequence of each order according to the state snapshots; the determining module is used for determining the execution result of the cross-micro service transaction of each order according to the order life cycle event and the state change sequence thereof, and triggering the compensation operation according to the traceability record when the execution result fails; the data anomaly detection and repair module is used for periodically scanning the micro-service data stream of each order, performing anomaly detection and automatic data repair, and displaying the full-link processing state of each order in real time.

Description

Event-driven-based micro-servitization order processing and transaction consistency guaranteeing method and system Technical Field The invention relates to the technical field of distributed systems and transaction processing, in particular to a method and a system for micro-servitization order processing and transaction consistency guarantee based on event driving. Background At present, an order management system is used as a core hub of an enterprise supply chain and sales operation and is responsible for processing a complete business flow from order receiving, performing and delivering. With the rapid development of electronic commerce, full-channel retail and complex supply chains, the order sources faced by modern enterprises are increasingly diversified (such as an electronic commerce platform, an ERP system, an EDI interface, a mobile terminal and the like), and the order processing logic is extremely complex due to the differences of product types, delivery modes and customer groups. To cope with this complexity, conventional order management systems mostly employ a single architecture or a coarse-grained server architecture. However, such architectures, when dealing with high concurrent, variable traffic demands, expose the significant drawback that existing schemes rely heavily on simple asynchronous messages or timing tasks for state synchronization, lacking a global, reliable transaction coordination mechanism. When a certain service processing fails, other service operations which are successfully executed are difficult to roll back automatically and accurately, data inconsistency is easy to be caused (such as that an order is created but inventory is not deducted, or inventory is locked but the order is finally cancelled), and the reliability of the service and the customer experience are seriously affected. The lack of active monitoring and automatic repair capabilities for business logic and business data consistency causes business loss. Disclosure of Invention Aiming at the problems shown above, the invention provides a method and a system for event-driven-based micro-serviced order processing and transaction consistency guarantee, which are used for solving the problems of weak cross-service transaction consistency guarantee mechanism and difficult positioning and solving of data abnormality problems in the background art. An event-driven-based micro-serviced order processing and transaction consistency guaranteeing method comprises the following steps: Receiving and analyzing order requests from multiple channels, generating standardized initial order creation events based on a configurable rule engine, and asynchronously transmitting the order events by adopting a distributed message middleware; performing multiple related micro services on the order event based on the triggering business logic, storing state snapshots of objects in the field of each micro service transaction, and generating an order life cycle event and a state change sequence of each order according to the state snapshots; Determining the execution result of the cross-micro service transaction of each order according to the order life cycle event and the state change sequence thereof, and triggering compensation operation according to the traceability record when the execution result fails; And periodically scanning micro-service data streams of all orders, detecting abnormality and automatically repairing the data, and displaying the full-link processing state of each order in real time. Preferably, the receiving and parsing the order requests from multiple channels generates a standardized initial order creation event based on a configurable rule engine, and asynchronously delivers the order event using distributed message middleware, including: Receiving original order requests through a multi-channel order access gateway, identifying source channels and agreement formats of each original order request, selecting a data acquisition mode based on the agreement formats, and acquiring original order data of each original order request from the source channels; Sequentially performing verification, cleaning, mapping, enriching and routing decision processing on the original order data according to a predefined rule set; converting the processed original order data into a standardized order object with uniform structure definition, and packaging the standardized order object into an initial order creation event; The initial order creation event is asynchronously published to a designated topic or queue of the distributed message middleware cluster. Preferably, the receiving the original order requests through the multi-channel order access gateway, identifying a source channel and an agreement format of each original order request, selecting a data acquisition mode based on the agreement format, and acquiring the original order data of each original order request from the source channel, includes: Continuously monitor