Event-driven processing method and system based on transaction state awareness and dynamic routing

By using an event-driven processing method that combines transaction state awareness and dynamic routing, the problem of scattered and inconsistent logic after transaction commit in traditional business systems is solved. This achieves unified abstraction and dynamic expansion of processing logic, improving the system's flexibility and processing efficiency.

CN121387448APending Publication Date: 2026-01-23CHONGQING KAILINJIAN GUANJIA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511519217.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-23
Publication Date
2026-01-23

AI Technical Summary

Technical Problem

Traditional business systems suffer from problems such as scattered post-transaction processing logic, inconsistent transaction states, and lack of dynamic routing, leading to high code coupling and poor scalability.

Method used

The event publisher senses the transaction status, the event listener verifies the legality and uniqueness of events, and the event dispatcher performs dynamic routing to match event handlers, thus realizing event-driven processing with transaction status awareness and dynamic routing.

Benefits of technology

It unifies the post-transaction processing logic into an event-driven model, reduces code coupling, ensures transaction consistency, supports dynamic scalability and efficient parallel processing, and improves system flexibility and throughput.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121387448A_ABST
    Figure CN121387448A_ABST
Patent Text Reader

Abstract

The invention provides an event-driven processing method based on transaction state awareness and dynamic routing, which comprises the following steps: calling an event publisher to throw an event in business logic, the event having a type identifier for identifying a business scene to which the event belongs; the event publisher judges a current thread state and determines a triggering opportunity based on the current thread state; the event monitor subscribes to the event and verifies legality and repeatability of the event; the event dispatcher matches the corresponding event processor according to the event type identification dynamic route; and the event processor executes the specific business logic after the transaction is submitted. The problems that in the prior art, after transactions are submitted, logic processing is scattered, the transaction states are inconsistent, and the dynamic routing capacity is insufficient are solved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer software application, and particularly relates to an event-driven processing method and system based on transaction state awareness and dynamic routing. BACKGROUND

[0002] In a traditional business system, the logical processing after the database transaction is submitted usually needs to be manually coded to be implemented, and the following problems exist:

[0003] 1. Logic is scattered: the processing logic (such as cache update, message notification, log recording, etc.) after the transaction is submitted needs to be hard-coded into the business method, resulting in high code coupling degree and difficult maintenance.

[0004] 2. Transaction state is inconsistent: if the asynchronous processing logic is triggered directly before the transaction is submitted, data inconsistency may be caused due to transaction rollback.

[0005] 3. Lack of dynamic routing: the existing event-driven framework is difficult to dynamically allocate processors according to the event type, and has poor scalability.

[0006] Therefore, a method and system are needed to be urgently developed, which can uniformly manage the asynchronous processing logic after the transaction is submitted based on the transaction state awareness and dynamic routing mechanism, and improve the flexibility and stability of the system. SUMMARY

[0007] The technical problem to be solved by the present application is to provide an event-driven processing method and system based on transaction state awareness and dynamic routing to solve at least one of the above problems existing in the prior art.

[0008] To achieve the above purpose, one or more embodiments in the present application provide an event-driven processing method based on transaction state awareness and dynamic routing, comprising:

[0009] An event publisher is called in the business logic to throw an event, and the event has a type identifier for identifying the business scenario to which the event belongs;

[0010] The event publisher determines the triggering time based on the current thread state;

[0011] An event listener subscribes to the event and checks the legality and repeatability of the event;

[0012] An event dispatcher dynamically routes the corresponding event processor according to the event type identifier;

[0013] An event processor executes specific business logic after the transaction is submitted.

[0014] Based on the above technical solutions of the present application, the following improvements can also be made:

[0015] Optionally, when judging the current thread state, if the current thread state is in a transaction, the event publisher temporarily stores the event to be triggered after the transaction is committed; if not in a transaction, the event is triggered immediately.

[0016] Optionally, when the event listener subscribes to the event and checks the legality and repeatability of the event, if the event is legal and not repeated, the subsequent steps are continued to be executed; if the event is illegal or repeated, the event is discarded.

[0017] Optionally, when the event dispatcher dynamically routes the corresponding event processor according to the event type identifier, the event processor can be multiple, supporting parallel processing; the event dispatcher allocates the processor through a configuration file or a rule engine.

[0018] Optionally, the event listener checks the event in the following ways:

[0019] checking the completeness and format validity of the event parameters;

[0020] checking whether the event is repeated through a unique identifier.

[0021] Optionally, the event dispatcher supports parallel processing of multiple types of events, and manages the execution of the event processor through a thread pool.

[0022] According to another aspect of the present application, an event-driven processing system based on transaction state awareness and dynamic routing is provided, comprising:

[0023] an event publisher configured to receive events thrown by a business method and to perceive a transaction state;

[0024] an event listener configured to subscribe to the event and to perform a check;

[0025] an event dispatcher configured to dynamically route the event to a corresponding event processor;

[0026] an event processor configured to execute specific post-transaction business logic.

[0027] Based on the above technical solutions of the present application, the following improvements can be made:

[0028] Optionally, a transaction state detection module is further included, configured to judge whether the current thread is in a transaction.

[0029] According to another aspect of the present application, a computer readable storage medium is provided, which stores computer instructions, the computer instructions being invoked to execute the steps of the event-driven processing method based on transaction state awareness and dynamic routing according to any one of the above aspects.

[0030] According to another aspect of the present application, there is provided an electronic device comprising the computer readable storage medium.

[0031] The present application has the beneficial effect of providing a transaction state-aware and dynamic routing based event-driven processing method and system, solving the problems of dispersed logic processing after transaction submission, inconsistent transaction state and insufficient dynamic routing capability in the prior art, and providing a transaction state-aware and dynamic routing based event-driven processing method and system. Unified management is achieved: the processing logic after transaction submission is uniformly abstracted into an event-driven model, reducing code coupling. Transaction consistency is guaranteed: through a transaction state-aware mechanism, it is ensured that events are triggered only after transaction submission, avoiding data inconsistency. Dynamic scalability: supporting dynamic addition / modification of event processors through configuration or rules, improving system flexibility. Efficient processing: multiple types of events are processed in parallel through an event dispatcher, improving system throughput. BRIEF DESCRIPTION OF DRAWINGS

[0032] Figure 1 A logic flow diagram of an embodiment of the present application. DETAILED DESCRIPTION

[0033] In order to make the objectives, technical solutions and advantages of the present disclosure clearer, the present disclosure is further described in detail below with reference to the embodiments and the accompanying drawings.

[0034] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in one or more embodiments of the present application should be understood as the usual meaning understood by a person with ordinary skill in the art to which the present disclosure belongs. The terms "first", "second" and the like used in one or more embodiments of the present application do not represent any order, quantity or importance, but are only used to distinguish different components. The terms "include" or "contain" and the like mean that the elements or objects before the terms encompass the elements or objects listed after the terms and their equivalents, without excluding other elements or objects. The terms "connect" or "connected" and the like do not mean physical or mechanical connection, but can include electrical connection, whether direct or indirect. The terms "up", "down", "left", "right" and the like are only used to represent relative positional relationships, and when the absolute positions of the described objects change, the relative positional relationships may also change accordingly.

[0035] As shown in FIG. 1, a transaction state-aware and dynamic routing based event-driven processing method and system according to one or more embodiments of the present application includes the following steps. Figure 1

[0036] ​Event publishing: In business method logic, call event publisher, throw an event; Specifically, after the business method is executed, call the publish method of the event publisher, pass in the event object.

[0037] The event contains a type identifier (Event Type) to identify the business scenario to which the event belongs.

[0038] Transaction state awareness: The event publisher determines whether the current thread is in a transaction:

[0039] If it is in a transaction, register the event in the callback function after the transaction is committed, and temporarily store it to be triggered after the transaction is committed.

[0040] If it is not in a transaction, trigger the event immediately.

[0041] Event listening and verification: The event listener subscribes to all events and verifies the events:

[0042] Verify the legality of the event (such as parameter integrity, format validity);

[0043] Verify if the event is duplicated (such as through event ID or business identifier to remove duplicates);

[0044] If the event is not legal or duplicated, discard the event.

[0045] Dynamic routing and distribution: The event distributor calls the corresponding event handler according to the event type identifier;

[0046] The event handler can be multiple, supporting parallel processing; The event handler implements an abstract interface definition processing logic, and multiple processors can be executed in parallel or in series.

[0047] The event distributor assigns the processor through a dynamic routing strategy (such as based on a configuration file or a rule engine).

[0048] Event processing: The event handler executes specific transaction commit business logic (such as updating cache, sending messages, recording logs, etc.).

[0049] In another embodiment, an event-driven processing system based on transaction state awareness and dynamic routing is provided, comprising:

[0050] An event publisher for receiving events thrown by business methods and sensing transaction states;

[0051] An event listener for subscribing to events and performing verification;

[0052] An event distributor for dynamically routing events to corresponding event handlers;

[0053] An event processor is configured to execute specific post-transaction commit business logic.

[0054] A transaction state detection module is further included to determine whether the current thread is in a transaction.

[0055] In another embodiment, a computer readable storage medium storing computer instructions is provided, which, when invoked, is configured to perform the steps of the transaction state-aware and dynamic routing based event-driven processing method according to any one of the preceding embodiments.

[0056] In another embodiment, an electronic device is provided, which includes the computer readable storage medium.

[0057] Those skilled in the art will appreciate that embodiments of the present application can be further implemented as a method, a system, or a computer program product. Accordingly, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, etc.) embodying computer readable program code.

[0058] The present application is described in reference to the flowchart illustrations and / or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams block or blocks.

[0059] These computer program instructions can also be stored in a computer- readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams block or blocks.

[0060] These computer program instructions can also be loaded into a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks. Figure 1 one or more flowcharts and / or blocks Figure 1 one or more flowcharts and / or blocks

[0061] Although preferred embodiments of the application have been described herein, it will be apparent to those skilled in the art that various modifications can be made within the scope of the application without departing from the spirit of the application. Accordingly, it is intended that all such possible modifications be included within the scope of the application as set forth in the following claims in which the

[0062] Obviously, numerous modifications and variations of the present application are possible in light of the above teachings. It is therefore to be understood that within the scope of the appended claims and their equivalents, the application can be practiced otherwise than as specifically described.

Claims

1. A method for event-driven processing based on transaction state awareness and dynamic routing, characterized in that, The application relates to an event-driven processing method based on transaction state sensing and dynamic routing. In the business logic, an event publisher is called to throw an event, which has a type identifier for identifying a business scenario to which the event belongs; The event publisher judges a current thread state and decides a triggering time based on the current thread state; An event listener subscribes to the event and checks the legality and repetition of the event; An event dispatcher dynamically routes and matches a corresponding event processor according to the event type identifier; An event processor executes specific business logic after a transaction is committed.

2. The transaction state-aware and dynamic routing based event-driven processing method according to claim 1, wherein, When judging the current thread state, if the current thread state is in a transaction, the event publisher temporarily stores the event to be triggered after the transaction is committed; if the current thread state is not in a transaction, the event publisher immediately triggers the event.

3. The transaction state-aware and dynamic routing based event-driven processing method according to claim 1, wherein, When the event listener subscribes to the event and checks the legality and repetition of the event, if the event is legal and not repeated, the subsequent steps are executed; if the event is illegal or repeated, the event is discarded.

4. The transaction state-aware and dynamic routing based event-driven processing method according to claim 1, wherein, When the event dispatcher dynamically routes and matches the corresponding event processor according to the event type identifier, the event processor can be multiple, supporting parallel processing; The event dispatcher allocates the processor through a configuration file or a rule engine.

5. The transaction state-aware and dynamic route based event-driven processing method according to claim 1, wherein, The event listener checks the event in the following ways: Checking the completeness and format validity of event parameters; Checking whether the event is repeated through a unique identifier.

6. The transaction state-aware and dynamic route-based event-driven processing method according to claim 1, wherein, The event dispatcher supports parallel processing of multiple types of events and manages the execution of the event processor through a thread pool.

7. A transaction state-aware and dynamic routing based event-driven processing system, characterized in that, The application relates to an event-driven processing method based on transaction state sensing and dynamic routing. An event publisher is used for receiving an event thrown by a business method and sensing a transaction state; An event listener is used for subscribing to the event and performing checking; An event dispatcher is used for dynamically routing the event to a corresponding event processor; An event processor is used for executing specific business logic after a transaction is committed.

8. The transaction state-aware and dynamic routing based event-driven processing system of claim 7, wherein, The application further relates to a transaction state detection module for judging whether a current thread is in a transaction.

9. A computer readable storage medium characterized by, The computer readable storage medium stores computer instructions, which are called to execute the steps of the event-driven processing method based on transaction state sensing and dynamic routing.

10. An electronic device, comprising: The electronic device comprises the computer readable storage medium. The application relates to an event-driven processing method based on transaction state sensing and dynamic routing. An event publisher is used for receiving an event thrown by a business method and sensing a transaction state; An event listener is used for subscribing to the event and performing checking; An event dispatcher is used for dynamically routing the event to a corresponding event processor; An event processor is used for executing specific business logic after a transaction is committed. The application further relates to a transaction state detection module for judging whether a current thread is in a transaction. The computer readable storage medium stores computer instructions, which are called to execute the steps of the event-driven processing method based on transaction state sensing and dynamic routing. The electronic device comprises the computer readable storage medium.