Event message processing method and device, computer equipment and storage medium
By splitting the main event into multiple subevents and processing asynchronously, the problems of low data consistency and transaction control performance in the prior art are solved, system performance and efficiency are improved, and partially successful compensation mechanisms and timely data consistency processing are achieved.
Patent Information
- Application Number
- CN202311065309.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-22
- Publication Date
- 2025-02-25
AI Technical Summary
When handling complex business events, the prior art is difficult to ensure data consistency, and the transaction control performance is low, and partial success and compensation cannot be achieved, and the entire business is easily unavailable due to exceptions, and data inconsistency problems are difficult to identify in a timely manner.
Split the main event into multiple sub-events and improve system performance and efficiency through asynchronous processing. The specific steps include obtaining the main event information, splitting it into sub-events, assigning it to the target subsystem for execution, and receiving the execution result information. If some sub-events are executed successfully or all sub-events fail, the failed sub-events are executed again to obtain a new execution result.
By asynchronously processing sub-events, the system performance and efficiency are improved, the entire business unavailability caused by exceptions is avoided, and data inconsistency problems are identified and processed in a timely manner, and a partially successful compensation mechanism is achieved.
Smart Images

Figure CN119512771A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to an event message processing method, device, computer equipment and storage medium. Background Art
[0002] As the system business grows, the business becomes more and more complex, the modular splitting becomes more refined, and the multi-database design comes into being. The system often needs to process business data in multiple modules when an event message occurs to ensure data consistency processing results on the entire business chain.
[0003] First, step-by-step transaction control is becoming increasingly difficult, and its performance and response efficiency are relatively low. Second, a transaction is either successful or failed, and it is impossible to achieve partial success and perform compensation. Third, once a transaction exception causes a rollback, the entire business will be unavailable. Fourth, once data inconsistency problems are caused by inadequate transaction control, it is difficult for the system and humans to identify them in a timely manner. Summary of the invention
[0004] Based on this, it is necessary to provide an event message processing method, device, computer equipment and storage medium to address the above technical problems, split the main event into multiple sub-events for asynchronous processing to improve system performance and efficiency.
[0005] In a first aspect, the present application provides an event message processing method, comprising:
[0006] Get the main event information of the main event to be executed;
[0007] Splitting the main event into at least one sub-event according to the main event information;
[0008] Allocating the sub-event to a target sub-system for execution based on preset sub-system registration information, and receiving execution result information of the sub-event returned by the target sub-system;
[0009] If some sub-events in the main event are executed successfully or all sub-events fail to execute, the failed sub-events are executed again and new execution result information is obtained.
[0010] In some embodiments of the present application, after allocating the sub-event to the target sub-system for execution based on the preset sub-system registration information and receiving the execution result information of the sub-event returned by the target sub-system, the method further includes:
[0011] When all sub-events in the main event are executed successfully, clearing the execution threads of the sub-events in each of the target subsystems;
[0012] When some sub-events in the main event are executed successfully or all sub-events fail to be executed, the execution threads of the executed sub-events in the target subsystem are maintained.
[0013] In some embodiments of the present application, if some sub-events in the main event are executed successfully or all sub-events are executed unsuccessfully, then executing the failed sub-events again and obtaining new execution result information includes:
[0014] If some sub-events in the main event are executed successfully or all sub-events fail to execute, then obtaining the execution subsystem of the first sub-event that failed to execute;
[0015] Generate an event execution instruction according to the first sub-event, and send it to the execution subsystem;
[0016] When the execution subsystem determines, according to the event execution instruction, that the execution thread of the first sub-event is executed successfully, execution success information is returned through the execution subsystem.
[0017] In some embodiments of the present application, the main event information includes an event execution order and an event execution subject, and splitting the main event into at least one sub-event according to the main event information includes:
[0018] Splitting the main event into at least one sub-event according to the event execution order and the event execution subject;
[0019] The sub-event execution order of the at least one sub-event is determined according to the event execution order.
[0020] In some embodiments of the present application, allocating the sub-event to the target sub-system for execution based on the preset sub-system registration information, and receiving the execution result information of the sub-event returned by the target sub-system, includes:
[0021] Obtaining sub-event information of each of the sub-events;
[0022] Compare the sub-event information with the sub-event message processing information in the preset subsystem registration information to determine the target subsystem for executing each sub-event;
[0023] Each of the target subsystems is called to execute each of the subevents, and execution result information of each of the subevents returned by the target subsystem is received.
[0024] In some embodiments of the present application, calling each of the target subsystems to execute each of the subevents, and receiving execution result information of each of the subevents returned by the target subsystem, includes:
[0025] Invoke the target subsystem to execute each of the sub-events according to the execution order of the sub-events;
[0026] If the execution result information of executing a target sub-event returned by a target subsystem indicates that the execution has failed, the execution of the sub-events after the target sub-event is stopped.
[0027] In some embodiments of the present application, the main event information further includes an event execution thread, and the main event is split into at least one sub-event according to the event execution order and the event execution subject, including:
[0028] Splitting the main event into at least one execution step according to the event execution sequence and the event execution subject;
[0029] The at least one execution step is split into at least one sub-event according to the event execution thread.
[0030] In a second aspect, the present application provides an event message processing device, including:
[0031] An information acquisition module, used to acquire the main event information of the main event to be executed;
[0032] An event splitting module, which is in communication with the information acquisition module and is used to split the main event into at least one sub-event according to the main event information;
[0033] An event execution module is communicatively connected with the event splitting module, and is used to assign the sub-event to the target subsystem for execution based on preset subsystem registration information, and receive the execution result information of the sub-event returned by the target subsystem; if some sub-events in the main event are executed successfully or all sub-events fail to execute, the failed sub-events are executed again and new execution result information is obtained.
[0034] In some embodiments of the present application, the event execution module is also used to clear the execution threads of the sub-events in each of the target subsystems when all sub-events in the main event are executed successfully; and to maintain the execution threads of the executed sub-events in the target subsystem when some sub-events in the main event are executed successfully or all sub-events fail to execute.
[0035] In some embodiments of the present application, the event execution module is also used to obtain the execution subsystem of the first sub-event that failed to execute if some sub-events in the main event execute successfully or all sub-events fail to execute; generate an event execution instruction based on the first sub-event and send it to the execution subsystem; when the execution subsystem determines that the execution thread of the first sub-event is successfully executed based on the event execution instruction, return execution success information through the execution subsystem.
[0036] In some embodiments of the present application, the main event information includes an event execution order and an event execution subject, and the event splitting module is further used to split the main event into at least one sub-event according to the event execution order and the event execution subject; and determine the sub-event execution order of the at least one sub-event according to the event execution order.
[0037] In some embodiments of the present application, the event execution module is also used to obtain sub-event information of each sub-event; compare the sub-event information with the sub-event message processing information in the preset subsystem registration information to determine the target subsystem for executing each sub-event; call each target subsystem to execute each sub-event, and receive the execution result information of each sub-event returned by the target subsystem.
[0038] In some embodiments of the present application, the event execution module is also used to call the target subsystem to execute each of the sub-events in the order of execution of the sub-events; if the execution result information of the target sub-event returned by a target subsystem is an execution failure, the execution of the sub-events after the target sub-event is stopped.
[0039] In some embodiments of the present application, the main event information also includes an event execution thread, and the event splitting module is further used to split the main event into at least one execution step according to the event execution order and the event execution subject; and split the at least one execution step into at least one sub-event according to the event execution thread.
[0040] In a third aspect, the present application further provides a computer device, the computer device comprising:
[0041] one or more processors;
[0042] A memory; and one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the event message processing method.
[0043] In a fourth aspect, the present application also provides a computer-readable storage medium on which a computer program is stored, and the computer program is loaded by a processor to execute the steps in the event message processing method.
[0044] The above-mentioned event message processing method, device, computer equipment and storage medium split the main event into multiple sub-events for asynchronous processing, thereby improving system performance and efficiency. In addition, for a main event in which some sub-events are successfully executed, only the failed sub-events are re-executed when re-triggered, and the sub-events that have been successfully executed are no longer executed repeatedly, thereby avoiding re-triggering of all main events and reducing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0046] Figure 1 It is a flowchart of an event message processing method in an embodiment of the present application;
[0047] Figure 2 is a flow chart of an event message processing method in another embodiment of the present application;
[0048] Figure 3 It is a structural diagram of an event message processing device in an embodiment of the present application;
[0049] Figure 4 It is a schematic diagram of the structure of a computer device in an embodiment of the present application. DETAILED DESCRIPTION
[0050] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0051] In the description of this application, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this application, "plurality" means two or more, unless otherwise clearly and specifically defined.
[0052] In the description of the present application, the word "for example" is used to mean "used as an example, illustration or explanation". Any embodiment described as "for example" in the present application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is given to enable any technician in the field to implement and use the present invention. In the following description, details are listed for the purpose of explanation. It should be understood that a person of ordinary skill in the art can recognize that the present invention can be implemented without using these specific details. In other examples, well-known structures and processes will not be elaborated in detail to avoid obscuring the description of the present invention with unnecessary details. Therefore, the present invention is not intended to be limited to the embodiments shown, but is consistent with the widest scope consistent with the principles and features disclosed in the present application.
[0053] See also Figure 1 The embodiment of the present application provides an event message processing method, which includes steps S101 to S104, which are as follows:
[0054] S101, obtaining main event information of a main event to be executed.
[0055] Specifically, the main event is an event to be executed initiated by the user through the client. For example, the main event to be executed is to transfer money from account A in bank A to account B in bank B. The main event information is various information related to the execution of the main event, including but not limited to the client identification information that initiates the execution request, network interface information and other information.
[0056] In addition, the main event may require the cooperation of multiple different execution entities, that is, the main event information also includes the event execution entity, for example, the event execution entities in the above example include Bank A and Bank B. In addition, the events executed by different execution entities in the main event have a sequence that must be followed, that is, the main event information also includes the event execution order, for example, the event execution order in the above example must be that Account A of Bank A deducts money first, and Account B of Bank B adds money later.
[0057] S102: Split the main event into at least one sub-event according to the main event information.
[0058] Specifically, the main event is split into at least one sub-event, and each sub-event is assigned to different subsystems for processing, so as to realize step-by-step transaction control. The main event is split into at least one sub-event according to the main event information, for example, it can be divided into each sub-event according to each execution step in the main event information, or it can be divided into each sub-event according to the event execution subject in the main event information.
[0059] In one embodiment, the main event information includes an event execution order and an event execution subject. This step includes: S201, splitting the main event into at least one sub-event according to the event execution order and the event execution subject; S202, determining the sub-event execution order of the at least one sub-event according to the event execution order.
[0060] Specifically, the main event may require the cooperation of multiple different execution subjects, and multiple different execution subjects execute alternately. For example, the main event S is that the execution subject A executes event A first, and then the execution subject B executes event B, and the execution subject A executes event C. The main event is split into at least one sub-event according to the event execution order and the event execution subject. In the above example, the main event S is split into three sub-events, namely event A, event B and event C.
[0061] At the same time, in order to avoid event execution errors due to changes in the order of events with execution order requirements, the event execution order of each event in the main event is the sub-event execution order of the sub-event.
[0062] In one embodiment, the main event information also includes an event execution thread, step S201, splitting the main event into at least one sub-event according to the event execution sequence and the event execution subject, including: S301, splitting the main event into at least one execution step according to the event execution sequence and the event execution subject; S302, splitting the at least one execution step into at least one sub-event according to the event execution thread.
[0063] Specifically, when the main event is split only according to the event execution order and the event execution subject, the obtained sub-events may still contain multiple steps. If the event containing multiple steps is divided into the same sub-event, it is impossible to quickly and accurately locate the abnormal position when an abnormality occurs in the execution of the sub-event. For example, the main event S is split into three sub-events, namely event A, event B and event C. The execution subject A executes event A, which may include steps a, b and c in sequence. If an error occurs in the execution of event A, it is impossible to quickly determine the specific abnormal steps in steps a, b and c.
[0064] Therefore, the main event information also includes the event execution thread. The event execution thread is the most detailed step for executing each event in the main event. The main event is split into at least one execution step according to the event execution order and the event execution subject. For example, in the above, the main event S is split into three execution steps according to the event execution order and the event execution subject. Subject A executes event A, execution subject B executes event B, and execution subject A executes event C.
[0065] Then, each execution step is further split according to the event execution thread to obtain at least one sub-event. For example, in the above, subject A executes event A, which includes steps a, b, and c in sequence. Then the main event S is split into five sub-events, namely, subject A executes step a, subject A executes step b, subject A executes step c, subject B executes event B, and subject A executes event C.
[0066] S103: Allocate the sub-event to a target sub-system for execution based on preset sub-system registration information, and receive execution result information of the sub-event returned by the target sub-system.
[0067] Specifically, the subsystem used to execute each sub-event is pre-registered, registers the sub-events that it can execute, and integrates the sub-event processing information of the sub-events executed by each subsystem to generate subsystem registration information and store it for easy calling. The sub-event processing information is relevant information that describes the sub-event, including but not limited to event execution steps, event execution objects and other information.
[0068] Based on the subsystem registration information, the target subsystem for executing each split sub-event is identified, each sub-event is assigned to the corresponding target subsystem for execution, and the execution result information of the sub-event returned by the target subsystem is received, and the execution result information includes execution success and execution failure.
[0069] In one embodiment, this step includes: S401, obtaining sub-event information of each of the sub-events; S402, comparing the sub-event information with the sub-event processing information in the preset subsystem registration information to determine the target subsystem for executing each of the sub-events; S403, calling each of the target subsystems to execute each of the sub-events, and receiving the execution result information of each of the sub-events returned by the target subsystem.
[0070] Specifically, the sub-event information of each sub-event obtained by splitting is obtained. The sub-event information is similar to the sub-event processing information in the above embodiment, and is also the relevant information describing the sub-event, including but not limited to event execution steps, event execution objects and other information.
[0071] The sub-event information is compared with the sub-event processing information in the preset subsystem registration information to determine the target subsystem for executing each sub-event, and then each target subsystem is called to execute the corresponding sub-events respectively. At the same time, the execution result information of each sub-event returned by each target subsystem is received. The execution result information includes execution success and execution failure.
[0072] In one embodiment, step S403, calling each of the target subsystems to execute each of the sub-events, and receiving the execution result information of each of the sub-events returned by the target subsystem, includes: S501, calling the target subsystem to execute each of the sub-events in the order of execution of the sub-events; S502, if the execution result information of executing the target sub-event returned by a certain target subsystem is execution failure, stopping the execution of the sub-events after the target sub-event.
[0073] Specifically, in the above embodiment, the sub-event execution order of each sub-event is determined according to the event execution order in the main event information, and therefore the target subsystem is called to execute each sub-event according to the sub-event execution order. It should be noted that, based on the sub-event execution order, if there is a sequence that must be followed between two sub-events, the target subsystems of the two sub-events must be called and executed in sequence; if the sequence between the two sub-events can be freely set, the target subsystems of the two sub-events can be called in sequence, or the target subsystems of the two sub-events can be called at the same time.
[0074] Each target subsystem returns the corresponding execution result information when executing a sub-event, and the execution result information includes execution success and execution failure. If a target subsystem executes a target sub-event, the execution result information returned for executing the target sub-event is execution failure, and the sub-event to be executed later depends on the result of the target sub-event. If the target sub-event fails to execute, the subsequent sub-event execution will inevitably fail, and the sub-events after the target sub-event will be stopped. For example, the main event to be executed is to transfer the money from account A in bank A to account B in bank B. The sub-events obtained by splitting are deducting money from account A in bank A and adding money to account B in bank B. When the target sub-event of deducting money from account A in bank A fails, based on the consistency of the event, the sub-event of adding money to account B in bank B will inevitably fail, so the sub-event of adding money to account B in bank B does not need to be executed again.
[0075] In addition, it should be noted that if a certain sub-system executes a target sub-event, and the execution result information of the target sub-event returned is execution failure, the dependency relationship between the remaining sub-events to be executed and the target sub-event can be further analyzed, and whether the remaining sub-events to be executed are executed or not can be determined based on the dependency relationship. The dependency relationship is whether the execution of the sub-event to be executed requires the target sub-event to be executed successfully. If so, the execution of the sub-event to be executed stops, and if not, the sub-event to be executed can continue to be executed.
[0076] In one embodiment, step S103, after allocating the sub-event to the target subsystem for execution based on preset subsystem registration information and receiving the execution result information of the sub-event returned by the target subsystem, also includes: S601, when all sub-events in the main event are executed successfully, clearing the execution threads of the sub-events in each of the target subsystems; S602, when some sub-events in the main event are executed successfully or all sub-events fail to execute, maintaining the execution threads of the executed sub-events in the target subsystem.
[0077] Specifically, the main event is executed successfully when all sub-events in the main event are executed successfully; the main event is executed unsuccessfully when all sub-events in the main event are executed unsuccessfully; and the main event is partially executed successfully when some sub-events in the main event are executed successfully. The sub-events that are not executed successfully in the partially successfully executed main event may be the returned execution result information of execution failure, or may be not executed due to the failure of the previous target sub-event to execute.
[0078] When all sub-events in the main event are successfully executed, the main event is successfully executed, that is, the main event is executed, so the execution threads of the sub-events in each target subsystem are cleared to release thread resources for subsequent scheduling. When some sub-events in the main event are successfully executed or all sub-events fail to execute, the user may re-trigger the execution or query and analyze the failure location and cause, so the execution threads of the executed sub-events in each target subsystem are maintained.
[0079] S104: If some sub-events in the main event are executed successfully or all sub-events are executed unsuccessfully, the failed sub-events are executed again and new execution result information is obtained.
[0080] Specifically, if some sub-events in the main event are executed successfully or all sub-events are executed unsuccessfully, the sub-events that failed are executed again and new execution result information is obtained. Based on the above embodiment, when some sub-events in the main event are executed successfully, the execution thread of the sub-event that has been executed in the target subsystem is maintained, so the sub-events that failed or were not executed can be directly triggered, and the sub-events that are successfully executed do not need to be executed repeatedly. For example, the main event to be executed is to transfer the money of account A in bank A to account B in bank B, and the sub-events obtained by splitting are account A in bank A deducting money and account B in bank B adding money. The sub-event account A in bank A deducting money is executed successfully, and the sub-event account B in bank B adding money fails to execute. Then, when the main event is triggered again, the sub-event account B in bank B adding money is directly triggered. The execution thread of the sub-event account A in bank A deducting money still exists and is in the state of successful execution. Therefore, if the sub-event account B in bank B adding money that is triggered again is executed successfully, the main event is executed successfully.
[0081] In one embodiment, this step includes: S701, if some sub-events in the main event are executed successfully or all sub-events fail to execute, then obtain the execution subsystem of the first sub-event that failed to execute; S702, generate an event execution instruction according to the first sub-event, and send it to the execution subsystem; S703, when the execution subsystem determines that the execution thread of the first sub-event is executed successfully according to the event execution instruction, return the execution success information through the execution subsystem.
[0082] Specifically, the successful execution or failed execution of the sub-event in the main event mentioned in this embodiment refers to the execution result information received by the system. However, if the received execution result information is an execution failure, it may be that the target subsystem failed to execute the sub-event, or it may be that network instability and other reasons caused signal transmission errors, so that the target subsystem actually executed the sub-event successfully, and the execution result information sent by the target subsystem is a successful execution, but the received execution result information is an execution failure.
[0083] Therefore, if some sub-events in the main event execute successfully or all sub-events fail to execute, and the failed sub-events need to be re-triggered, the execution subsystem of the first sub-event that failed to execute is obtained. According to the sub-event execution order, the previous sub-event of the first sub-event is the successfully executed sub-event. Since the first sub-event has been identified as having the corresponding subsystem executed, the execution subsystem of the first sub-event can be directly obtained through historical log records.
[0084] Generate an event execution instruction according to the first sub-event and send it to the execution subsystem. The event execution instruction includes the identity information of the terminal that issued the instruction, sub-event information, etc. After the execution subsystem receives the event execution instruction, it queries the execution thread that previously executed the first sub-event according to the event execution instruction. If the execution thread fails to execute, the execution subsystem re-triggers the execution of the first sub-event. If the execution thread succeeds, it means that the execution result information received by the system is an error message of execution failure, and the execution thread that succeeded is still retained in the execution subsystem. Therefore, the execution subsystem does not need to execute the first sub-event again, but directly returns the execution success information. After the system receives the execution success information, it continues to execute the next sub-event in the sub-event execution order. The specific steps are consistent with those described in the above embodiment, so they are not repeated one by one.
[0085] This embodiment splits the main event into multiple sub-events for asynchronous processing, thereby improving system performance and efficiency. The execution threads of executed sub-events are maintained so that partially successful main events can directly trigger failed sub-events here without the need to repeatedly execute previously successfully executed sub-events.
[0086] The present application embodiment provides an event message processing system. An event message refers to a request from one system to tell another system about an action to be performed. The event message processing system has the following roles:
[0087] 1. Event Processing Center
[0088] Unified event management provides producers with an interface for producing main events and consumers with processors for registering and handling sub-events.
[0089] 2. Producers
[0090] When a specific business request occurs, the main event is published to the event processing center.
[0091] 3. Consumers
[0092] Responsible for registering the processor to the event processing center to process the sub-events, while ensuring the idempotence of the sub-event business logic.
[0093] 4. Subsystem (submodule)
[0094] A subsystem is a complete entity that can exist independently and consists of a set of functions to complete a specific business. It can be either a producer or a consumer depending on the business scenario of the event.
[0095] Specific processing plan of the event processing center:
[0096] 1. According to the business scenario, the event processing center maps the main event and sub-events into a one-to-many relationship and manages the sub-event execution order of the sub-events;
[0097] 2. Provide the producer module with an interface for producing main events, and save the main events in an unprocessed state;
[0098] 3. Provide the consumer module with a registration interface for the sub-event processor (subsystem), and save the listeners that need to be processed for each sub-event into memory;
[0099] 4. The event processing center captures unprocessed main events every minute, and calls and processes the sub-event processors registered in the memory (subsystem registration information) in sequence, and writes the sub-event processing results into a table (if all sub-events are successful, the main event is successfully processed; if some sub-events are successful, the main event is partially successful; if all sub-events fail to be processed, the main event fails), and issues early warning notifications for failed sub-events;
[0100] 5. The event processing center captures recent (within 3 hours) failed or partially successful main events every half hour and re-trigger the processing of failed sub-events;
[0101] 6. For the sub-events of the early warning notification, it is necessary to manually check the corresponding sub-system problems and re-trigger the sub-event processing;
[0102] 7. For the consumer module, sub-event deduplication processing is required. For the consumer module, the actual execution is successful, but the event processing center receives the sub-event of failed execution to avoid multiple processing of events due to exceptions.
[0103] 3. Event definition structure
[0104] 1. Main event structure:
[0105] public class EventEntity{
[0106] / / Event id
[0107] private String id;
[0108] / / Producer business id
[0109] private String outId;
[0110] / / Main event name
[0111] private String type;
[0112] / / Event processing status
[0113] private String status;
[0114] / / Message data passed by the event
[0115] private String data;
[0116] / / The time when the event occurred
[0117] private String timeCreate;
[0118] / / Update time after event processing
[0119] private String timeUpdate;
[0120] }
[0121] 2. Sub-event structure:
[0122] public class EventSubEntity{
[0123] / / Sub-event id
[0124] private String id;
[0125] / / Main event id
[0126] private String eventId;
[0127] / / Sub-event name
[0128] private String type;
[0129] / / Sub-event processing status
[0130] private String status;
[0131] / / The time when the sub-event occurs
[0132] private String timeCreate;
[0133] / / Update time after sub-event processing
[0134] private String timeUpdate;
[0135] }
[0136] like Figure 2 As shown, the execution steps of the event message processing system are as follows:
[0137] 1. Consumers (submodules or subsystems) register event processors (sub-event processing information) with the event processing center, which caches event processors. Producers (submodules or subsystems) register production main events with the event processing center, which stores the main events in the database as unprocessed.
[0138] 2. The producer publishes the main event to be executed to the event processing center. The event processing center stores the main event to be executed as an unprocessed state and returns the result to the producer.
[0139] 3. The event processing center splits the main event to be executed into at least one sub-event, creates a sub-event repository, and assigns the sub-event to the corresponding target subsystem to call the sub-event processing listener according to the sub-event processing information in the subsystem registration information;
[0140] 4. The consumer processes the sub-event business, that is, the target subsystem executes the corresponding sub-event and returns the processing result (success / failure);
[0141] 5. The event processing center will record the sub-event processing results (if all sub-events are successful, the main event is successfully processed; if some sub-events are successful, the main event is partially successful; if all sub-events fail to be processed, the main event fails), and issue early warning notifications for failed sub-events;
[0142] 6. The event processing center captures the recent (within 3 hours) failed or partially successful main events every half hour to re-trigger the processing of the failed sub-events; re-call the failed sub-event processing listener, that is, execute the first sub-event again through the target subsystem and return the processing result (success / failure).
[0143] This embodiment splits a large transaction into multiple sub-events for asynchronous processing, thereby improving system performance and efficiency; making data consistency processing more flexible and scalable; and making the compensation mechanism more convenient when data processing of a sub-module is abnormal.
[0144] like Figure 3 As shown, the embodiment of the present application provides an event message processing device 900, including:
[0145] An information acquisition module 910 is used to acquire the main event information of the main event to be executed;
[0146] An event splitting module 920, which is in communication with the information acquisition module 910 and is used to split the main event into at least one sub-event according to the main event information;
[0147] The event execution module 930 is communicatively connected with the event splitting module 920, and is used to assign the sub-event to the target subsystem for execution based on the preset subsystem registration information, and receive the execution result information of the sub-event returned by the target subsystem; if some sub-events in the main event are executed successfully or all sub-events fail to execute, the failed sub-events are executed again and new execution result information is obtained.
[0148] In some embodiments of the present application, the event execution module 930 is also used to clear the execution threads of the sub-events in each of the target subsystems when all sub-events in the main event are executed successfully; and to maintain the execution threads of the executed sub-events in the target subsystem when some sub-events in the main event are executed successfully or all sub-events fail to execute.
[0149] In some embodiments of the present application, the event execution module 930 is also used to obtain the execution subsystem of the first sub-event that failed to execute if some sub-events in the main event execute successfully or all sub-events fail to execute; generate an event execution instruction based on the first sub-event and send it to the execution subsystem; when the execution subsystem determines that the execution thread of the first sub-event is successfully executed according to the event execution instruction, the execution success information is returned through the execution subsystem.
[0150] In some embodiments of the present application, the main event information includes an event execution order and an event execution subject, and the event splitting module 920 is also used to split the main event into at least one sub-event according to the event execution order and the event execution subject; and determine the sub-event execution order of the at least one sub-event according to the event execution order.
[0151] In some embodiments of the present application, the event execution module 930 is also used to obtain sub-event information of each sub-event; compare the sub-event information with the sub-event message processing information in the preset subsystem registration information to determine the target subsystem for executing each sub-event; call each target subsystem to execute each sub-event, and receive the execution result information of each sub-event returned by the target subsystem.
[0152] In some embodiments of the present application, the event execution module 930 is also used to call the target subsystem to execute each of the sub-events in the sub-event execution order; if the execution result information of the target sub-event returned by a target subsystem is an execution failure, the execution of the sub-events after the target sub-event is stopped.
[0153] In some embodiments of the present application, the main event information also includes an event execution thread, and the event splitting module 920 is also used to split the main event into at least one execution step according to the event execution order and the event execution subject; and split the at least one execution step into at least one sub-event according to the event execution thread.
[0154] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0155] For example, Figure 4 The computer device shown can be Figure 3 The information acquisition module 910 in the event message processing device 900 shown executes step S101. The computer device can execute step S102 through the event splitting module 920. The computer device can execute steps S103 and S104 through the event execution module 930. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external computer device through a network connection. When the computer program is executed by the processor, an event message processing method is implemented.
[0156] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0157] In some embodiments of the present application, a computer device is provided, comprising one or more processors; a memory; and one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor in the steps of the above event message processing method. The steps of the event message processing method here may be the steps of the event message processing method in each of the above embodiments.
[0158] In some embodiments of the present application, a computer-readable storage medium is provided, which stores a computer program, and the computer program is loaded by a processor, so that the processor executes the steps of the event message processing method described above. The steps of the event message processing method here can be the steps of the event message processing method in each of the above embodiments.
[0159] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Any reference to memory, storage, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0160] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0161] The above is a detailed introduction to an event message processing method, device, computer equipment and storage medium provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for technical personnel in this field, according to the ideas of the present invention, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A method for processing an event message, characterized in that: include: Get the main event information of the main event to be executed; Splitting the main event into at least one sub-event according to the main event information; Allocating the sub-event to a target sub-system for execution based on preset sub-system registration information, and receiving execution result information of the sub-event returned by the target sub-system; If some sub-events in the main event are executed successfully or all sub-events fail to execute, the failed sub-events are executed again and new execution result information is obtained.
2. The event message processing method according to claim 1, characterized in that: After allocating the sub-event to the target sub-system for execution based on the preset sub-system registration information and receiving the execution result information of the sub-event returned by the target sub-system, the method further includes: When all sub-events in the main event are executed successfully, clearing the execution threads of the sub-events in each of the target subsystems; When some sub-events in the main event are executed successfully or all sub-events fail to be executed, the execution threads of the executed sub-events in the target subsystem are maintained.
3. The event message processing method according to claim 2, characterized in that: If some sub-events in the main event are executed successfully or all sub-events fail to execute, the failed sub-events are executed again and new execution result information is obtained, including: If some sub-events in the main event are executed successfully or all sub-events fail to execute, then obtaining the execution subsystem of the first sub-event that failed to execute; Generate an event execution instruction according to the first sub-event, and send it to the execution subsystem; When the execution subsystem determines, according to the event execution instruction, that the execution thread of the first sub-event is executed successfully, execution success information is returned through the execution subsystem.
4. The event message processing method according to claim 1, characterized in that: The main event information includes an event execution sequence and an event execution subject, and the main event is split into at least one sub-event according to the main event information, including: Splitting the main event into at least one sub-event according to the event execution order and the event execution subject; The sub-event execution order of the at least one sub-event is determined according to the event execution order.
5. The event message processing method according to claim 4, characterized in that: The step of allocating the sub-event to the target sub-system for execution based on the preset sub-system registration information, and receiving the execution result information of the sub-event returned by the target sub-system, includes: Obtaining sub-event information of each of the sub-events; Compare the sub-event information with the sub-event message processing information in the preset subsystem registration information to determine the target subsystem for executing each sub-event; Each of the target subsystems is called to execute each of the subevents, and execution result information of each of the subevents returned by the target subsystem is received.
6. The event message processing method according to claim 5, characterized in that: The calling of each of the target subsystems to execute each of the subevents, and receiving the execution result information of each of the subevents returned by the target subsystem, includes: Invoke the target subsystem to execute each of the sub-events according to the execution order of the sub-events; If the execution result information of executing a target sub-event returned by a target subsystem indicates that the execution has failed, the execution of the sub-events after the target sub-event is stopped.
7. The event message processing method according to claim 4, characterized in that: The main event information also includes an event execution thread, and the main event is split into at least one sub-event according to the event execution sequence and the event execution subject, including: Splitting the main event into at least one execution step according to the event execution sequence and the event execution subject; The at least one execution step is split into at least one sub-event according to the event execution thread.
8. An event message processing device, characterized in that: include: An information acquisition module, used to acquire the main event information of the main event to be executed; An event splitting module, which is in communication with the information acquisition module and is used to split the main event into at least one sub-event according to the main event information; An event execution module, which is in communication with the event splitting module, is used to assign the sub-event to the target subsystem for execution based on the preset subsystem registration information, and receive the execution result information of the sub-event returned by the target subsystem; If some sub-events in the main event are executed successfully or all sub-events fail to execute, the failed sub-events are executed again and new execution result information is obtained.
9. A computer device, characterized in that: The computer device comprises: one or more processors; A memory; and one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the event message processing method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, the computer program being loaded by a processor to execute the steps in the event message processing method according to any one of claims 1 to 7.