Asynchronous message processing method, device and system
Through the asynchronous message processing method, distributed message queues and cache clusters are used to decouple the data processing process, which improves data flow efficiency, reduces dependence on database performance, and solves the problems of low data flow efficiency and difficulty in horizontal expansion in the existing technology.
Patent Information
- Application Number
- CN202410843012.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-10-01
AI Technical Summary
The existing method of using relational databases for data transfer has problems such as low data transfer efficiency, long time consumption, and heavy reliance on database performance. Especially when the amount of business data increases, the scanning efficiency is greatly reduced, affecting other applications' access to the database, and making it difficult to access the database. Support horizontal expansion.
Using the asynchronous message processing method, the business data is written into the database through the sub-nodes in the business processing cluster and sent to the distributed message queue. The distributed cache cluster is used to cache and lock the filtering results to achieve multi-layer data processing, and based on The preset topological sorting sequence repeatedly updates the database to achieve decoupling of data flow.
It improves the efficiency of data transfer between different application nodes, reduces dependence on database performance, simplifies horizontal expansion of applications, and ensures data reliability.
Smart Images

Figure CN118733675A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to an asynchronous message processing method, device and system. Background Art
[0002] For distributed systems, when asynchronous collaborative processing of business data is performed, relational databases are mainly used for data storage and circulation. After receiving the business data, the distributed system directly stores the business data in the database. Each business data record in the database sets a specific field to identify the current processing node. Each application node of the distributed system obtains the business data to be processed by actively scanning the specific field, and updates the specific field to enter the next processing node. By continuously scanning and updating the identified specific fields, the business data can be circulated between different application nodes, and finally the asynchronous collaborative processing of the business data is completed.
[0003] However, the existing data flow method using relational databases has the problems of low data flow efficiency, long time consumption and heavy reliance on database performance. When the amount of business data increases, the scanning efficiency will be greatly reduced, and even affect other applications' access to the database. In addition, this method is only friendly to the system's single application nodes. For system application nodes that need to support horizontal expansion, this method will also increase the difficulty of deployment. Therefore, there is an urgent need for an asynchronous message processing method that can improve the efficiency of data flow between different application nodes while ensuring data reliability, reduce dependence on database performance, and reduce the difficulty of horizontal expansion of applications. Summary of the invention
[0004] In view of the current method of using relational databases for data flow, there are problems such as low data flow efficiency, long time consumption and heavy dependence on database performance. When the amount of business data increases, the scanning efficiency will be greatly reduced, and even affect other applications' access to the database. In addition, this method is only friendly to the system's single application nodes. For system application nodes that need to support horizontal expansion, this method will also increase the difficulty of deployment. This solution is proposed to overcome the above problems or at least partially solve the above problems.
[0005] On the one hand, an object of some embodiments of this specification is to provide an asynchronous message processing method, the method comprising:
[0006] Receive business data;
[0007] Using the first child node in the business processing cluster, the business data is written into a database and sent to a distributed message queue;
[0008] Using a second sub-node in the business processing cluster to monitor the distributed message queue in real time, and screening to obtain business data corresponding to a message topic matching the second sub-node;
[0009] Use distributed cache cluster to cache the screening results and lock the data;
[0010] The second sub-node performs multi-layer data processing on the locked screening result to obtain a processing result, and updates the processing result to the database;
[0011] The other sub-nodes in the business processing cluster repeat the above steps of monitoring and filtering the corresponding business data to update the database based on the preset topological sorting sequence, thereby completing the asynchronous message processing.
[0012] Further, using the first child node in the business processing cluster, writing the business data into a database, and sending the business data to a distributed message queue, including:
[0013] Using the first sub-node, numbering the service data;
[0014] Write the numbered business data and its corresponding number into the database, and return a data writing completion flag;
[0015] In response to the data writing completion flag, the business data is sent to the distributed message queue in a serialized manner.
[0016] Further, using the first sub-node to number the service data includes:
[0017] The first sub-node uniquely numbers each piece of business data using a sequential self-increasing number according to a timestamp corresponding to each piece of business data.
[0018] Further, using the second sub-node in the business processing cluster to monitor the distributed message queue in real time, and screening to obtain business data corresponding to the message subject matching the second sub-node, includes:
[0019] Determine a message subject that matches the second sub-node from a preset message subject matching table;
[0020] The second sub-node is used to monitor the distributed message queue in real time to obtain business data corresponding to the message topic.
[0021] Furthermore, the distributed cache cluster is used to cache the screening results and lock the data, including:
[0022] Utilizing a distributed cache cluster to cache the screening results;
[0023] Determine a lock timeout period for each piece of business data in the screening result according to the business type of each piece of business data in the screening result;
[0024] The distributed cache cluster is used to lock the data of the screening result by taking the unique number of each business data in the screening result as the key value lock and taking the lock timeout time as the lock time.
[0025] Further, according to the business type of each business data in the screening result, determining the lock timeout time of each business data in the screening result includes:
[0026] Classifying the screening results according to the business type of each piece of business data in the screening results;
[0027] Based on the classification results, the processing time of obtaining the historical business data corresponding to each business type in the screening results;
[0028] Calculate the average processing time of a single piece of business data corresponding to each business type in the screening result according to the processing time of the historical business data and the amount of historical business data;
[0029] For different business types, the product of the average processing time of the single business data and a preset coefficient is used as the lock timeout time.
[0030] Furthermore, the second sub-node performs multi-layer data processing on the locked screening result to obtain a processing result, and updates the processing result to the database, including:
[0031] The second sub-node uses a preset rule model to perform multi-layer data processing on the screening result to obtain a processing result;
[0032] The processing result is updated to the database.
[0033] Furthermore, other sub-nodes in the business processing cluster repeat the above steps of monitoring and updating the database by screening the corresponding business data based on a preset topological sorting sequence, thereby completing the asynchronous message processing, further comprising:
[0034] The other sub-nodes determine the node execution order based on a preset topological sorting sequence;
[0035] Determine a traffic distribution strategy based on a load balancing mechanism according to the message topics matched by each sub-node in the other sub-nodes and the execution order of the nodes;
[0036] According to the traffic distribution strategy, the other sub-nodes repeat the above steps of monitoring and updating the database by screening the corresponding business data in the order of node execution, thereby completing asynchronous message processing.
[0037] On the other hand, some embodiments of the present specification further provide an asynchronous message processing device, the device comprising:
[0038] A receiving module, used for receiving business data;
[0039] A transmission module, used to write the business data into a database using a first sub-node in the business processing cluster, and send it to a distributed message queue;
[0040] A screening module, used to monitor the distributed message queue in real time by using the second sub-node in the business processing cluster, and screen and obtain business data corresponding to the message subject matching the second sub-node;
[0041] The locking module is used to cache the screening results and lock the data using the distributed cache cluster;
[0042] An updating module, used for the second sub-node to perform multi-layer data processing on the locked screening result to obtain a processing result, and update the processing result to the database;
[0043] The repetition module is used for other sub-nodes in the business processing cluster to repeat the above steps of updating the database by monitoring and screening the corresponding business data based on a preset topological sorting sequence, thereby completing asynchronous message processing.
[0044] On the other hand, some embodiments of the present specification also provide an asynchronous message processing system, which includes a business processing cluster, a distributed cache cluster, a distributed message queue and a database, and the asynchronous message processing system is used to execute the method described in any of the above embodiments.
[0045] On the other hand, some embodiments of the present specification further provide a computer device, including a memory, a processor, and a computer program stored in the memory, wherein when the computer program is executed by the processor, the instructions of the above method are executed.
[0046] On the other hand, some embodiments of the present specification further provide a computer storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor of a computer device, the instructions of the above method are executed.
[0047] On the other hand, some embodiments of the present specification further provide a computer program product, wherein the computer program product comprises a computer program, and when the computer program is executed by a processor of a computer device, the instructions of the above method are executed.
[0048] One or more technical solutions provided by some embodiments of this specification have at least the following technical effects:
[0049] The embodiment of the present specification first automatically receives business data, and then uses the first child node in the business processing cluster to write the business data into the database and send it to the distributed message queue, so that the second child node after the first child node monitors the distributed message queue in real time, subscribes to the business data that the second child node needs to process from the distributed message queue according to the matching of the message subject, and caches the subscribed data to the distributed cache cluster. In order to ensure that the business data is not consumed repeatedly, the distributed cache cluster is used to lock the data of the screening results, and then the second child node continues to perform multi-layer data processing on the locked screening results, and updates the processing results to the database, and then jumps to other child nodes in the business processing cluster, so that the other child nodes repeat the above steps of monitoring and screening the corresponding business data based on the preset topological sorting sequence to update the database, thereby realizing the decoupling of the business data processing process, improving the data flow efficiency under the premise of ensuring data reliability, avoiding the problem of database performance dependence that always needs to interact with the database to process business data, and when processing business data, the other child nodes of the business processing cluster follow the same steps as the second child node to process business data, which is convenient for subsequent horizontal expansion of applications.
[0050] The above description is only an overview of the technical solutions of some embodiments of this specification. In order to more clearly understand the technical means of some embodiments of this specification, they can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of some embodiments of this specification more obvious and easy to understand, the specific implementation methods of some embodiments of this specification are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate some embodiments of this specification or technical solutions in the prior art, the following briefly introduces the drawings required for the embodiments or prior art descriptions. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor. In the drawings:
[0052] Figure 1 A schematic diagram of an implementation system of an asynchronous message processing method in some embodiments of this specification is shown;
[0053] Figure 2 A flowchart of an asynchronous message processing method in some embodiments of this specification is shown;
[0054] Figure 3 A schematic diagram of node connection relationships of a service processing cluster in some embodiments of this specification;
[0055] Figure 4 This is a schematic diagram of data flow in some embodiments of this specification;
[0056] Figure 5 This is a schematic diagram of the structure of an asynchronous message processing device in some embodiments of this specification;
[0057] Figure 6 This is a schematic diagram of the computer device structure provided in some embodiments of this specification.
[0058] [Description of Reference Numerals]
[0059] 101. Business processing cluster;
[0060] 102. Distributed cache cluster;
[0061] 103. Database;
[0062] 104. Distributed message queue;
[0063] 501, receiving module;
[0064] 502, transmission module;
[0065] 503. Screening module;
[0066] 504, locking module;
[0067] 505. Update module;
[0068] 602. Computer equipment;
[0069] 604, processor;
[0070] 606. Memory;
[0071] 608, driving mechanism;
[0072] 610, input / output interface;
[0073] 612. Input devices;
[0074] 614. Output devices;
[0075] 616. Presentation equipment;
[0076] 618. Graphical user interface;
[0077] 620, network interface;
[0078] 622, communication link;
[0079] 624. Communication bus. DETAILED DESCRIPTION
[0080] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in some embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on some embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.
[0081] It should be noted that the terms "first", "second", etc. in the specification and claims of this document and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of this document described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, device, product or equipment that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment. It should be noted that the acquisition, storage, use, processing, etc. of data in the technical solution of this application comply with the relevant provisions of relevant laws and regulations.
[0082] like Figure 1The diagram is a schematic diagram of an implementation system of an asynchronous message processing method according to an embodiment of the present invention, which may include: a business processing cluster 101, a distributed cache cluster 102, a database 103, and a distributed message queue 104. The business processing cluster 101, the distributed cache cluster 102, the database 103, and the distributed message queue 104 communicate with each other through a network, and the network may include a local area network (LAN), a wide area network (WAN), the Internet, or a combination thereof, and is connected to a website, a user device (such as a computing device), and a back-end system. The staff may send business data to the business processing cluster 101 through the business system. After receiving the business data, the business processing cluster 101 calls the distributed cache cluster 102, the database 103, and the distributed message queue 104 to perform asynchronous message calculation processing, obtain the processing result, and send the processing result to the business system, so that the staff can process the business according to the processing result.
[0083] In addition, it should be noted that Figure 1 What is shown is only an application environment provided by the present disclosure. In actual applications, the business processing cluster 101 may also include multiple sub-nodes, and the multiple sub-nodes communicate with the distributed cache cluster 102, the database 103 and the distributed message queue 104 through the network respectively, and this specification does not impose any limitation.
[0084] Figure 2 It is a flowchart of an asynchronous message processing method provided by an embodiment of the present invention. This specification provides method operation steps as described in the embodiment or flowchart, but may include more or fewer operation steps based on conventional or non-creative labor. The order of steps listed in the embodiment is only one way of executing the steps among many orders, and does not represent the only order of execution. When the actual system or device product is executed, it can be executed in the order or in parallel according to the method shown in the embodiment or the accompanying drawings. Specifically, Figure 2 As shown, applied to the above-mentioned server side, the method may include:
[0085] S201: receiving business data;
[0086] S202: Using the first child node in the business processing cluster, write the business data into a database and send it to a distributed message queue;
[0087] S203: using a second sub-node in the business processing cluster to monitor the distributed message queue in real time, and filtering to obtain business data corresponding to a message topic matching the second sub-node;
[0088] S204: Utilize the distributed cache cluster to cache the screening results and lock the data;
[0089] S205: the second sub-node performs multi-layer data processing on the locked screening result to obtain a processing result, and updates the processing result to the database;
[0090] S206: other sub-nodes in the business processing cluster repeat the above steps of monitoring and filtering corresponding business data to update the database based on a preset topological sorting sequence, thereby completing asynchronous message processing.
[0091] The embodiment of the present specification first automatically receives business data, and then uses the first child node in the business processing cluster to write the business data into the database and send it to the distributed message queue, so that the second child node after the first child node monitors the distributed message queue in real time, subscribes to the business data that the second child node needs to process from the distributed message queue according to the matching of the message subject, and caches the subscribed data to the distributed cache cluster. In order to ensure that the business data is not consumed repeatedly, the distributed cache cluster is used to lock the data of the screening results, and then the second child node continues to perform multi-layer data processing on the locked screening results, and updates the processing results to the database, and then jumps to other child nodes in the business processing cluster, so that the other child nodes repeat the above steps of monitoring and screening the corresponding business data based on the preset topological sorting sequence to update the database, thereby realizing the decoupling of the business data processing process, improving the data flow efficiency under the premise of ensuring data reliability, avoiding the problem of database performance dependence that always needs to interact with the database to process business data, and when processing business data, the other child nodes of the business processing cluster follow the same steps as the second child node to process business data, which is convenient for subsequent horizontal expansion of applications.
[0092] It can be understood that in some embodiments, the business data is complete data that has completed data processing, and the asynchronous message processing process does not need to introduce new data from other parties. Figure 3 , Kafka distributed message queue can be used as a distributed message queue, and Redis can be used to implement storage services to achieve asynchronous and highly reliable flow of message data between distributed system applications. Business data is first written to the database for recording, and the data is sent to the Kafka message queue and transferred to the business processing cluster. The business processing cluster can be understood as a business processing application with multiple sub-nodes, such as Figure 3APP-1, APP-2, and APP-3 in the figure are all child nodes. The business processing application listens to the business data sent to the Kafka message queue. After obtaining the business data, in order to ensure that the data is processed uniquely, the data is locked by adding a distributed lock to Redis. After the lock is successful, the business processing is carried out. The business processing process includes multiple read and write operations on the business data, and the processing results are updated to the database. For further information, refer to the attached Figure 4 The implementation premise can be: kafka is clustered and deployed, and the cluster contains 3 kafka nodes; redis is clustered and deployed in cluster mode, and the cluster contains 3 master nodes and 3 slave nodes; the database is an oracle database, deployed using RAC technology, and contains 2 nodes; business processing applications are all developed in JAVA language, and containerized cluster deployment is adopted, and the cluster contains 2 application copies, attached Figure 4 The data flow process is implemented using the following steps:
[0093] Step 1: The external system initiates business data submission via HTTP request;
[0094] Step 2: Business acceptance application APP-1 receives business data submitted by the external system, uniquely numbers the data, and writes the data into the database for storage;
[0095] Step 3: After the business acceptance application APP-1 completes data storage, it serializes the data and sends it to the Kafka message queue. The message topic is topic1.
[0096] Step 4: After the business acceptance application APP-1 sends the data to the Kafka message queue, it returns the acceptance response to the external system. At this point, the business data acceptance process is completed, and the data will be processed asynchronously by the processing application;
[0097] Step 5: Business processing application APP-2 monitors the messages with the subject of topic 1 in the Kafka message queue in real time, and consumes them in time when new data enters the message queue;
[0098] Step 6: After the business processing application APP-2 obtains the message data, in order to ensure that the data is not consumed repeatedly, a distributed lock is added to Redis with the unique data number as the key value to lock the data, and the lock timeout is set synchronously when locking;
[0099] Step 7: After the business processing application APP-2 successfully locks the data, it performs business processing on the data;
[0100] Step 8: After the business processing application APP-2 completes the data processing, it updates the processing results to the database and records the latest processing information;
[0101] Step 9: After the business processing application APP-2 completes the data processing result update, it serializes the latest data and sends it to the Kafka message queue. The message topic is topic2.
[0102] Step 10: Business processing application APP-3 monitors the messages with the subject of topic 2 in the Kafka message queue in real time, and consumes them in time when new data enters the message queue;
[0103] Step 11: After the business processing application APP-3 obtains the message data, in order to ensure that the data is not consumed repeatedly, a distributed lock is added to Redis with the unique data number as the key value to lock the data, and the lock timeout time is set synchronously when locking;
[0104] Step 12: After the business processing application APP-3 successfully locks the data, it performs business processing on the data;
[0105] Step 13: After the business processing application APP-3 completes the data processing, it updates the processing results to the database and records the latest processing information;
[0106] Through the above process, the business processing cluster includes 3 sub-nodes, and the topology is arranged as APP-1→APP-2→APP-3, and asynchronous high-reliability flow of business data is achieved.
[0107] In some embodiments, using a first sub-node in a business processing cluster to write the business data into a database and sending the business data to a distributed message queue includes:
[0108] Using the first sub-node, numbering the service data;
[0109] Write the numbered business data and its corresponding number into the database, and return a data writing completion flag;
[0110] In response to the data writing completion flag, the business data is sent to the distributed message queue in a serialized manner.
[0111] It can be understood that, in some embodiments, numbering the business data can ensure the orderliness of the business data. After the business data is numbered, the data is stored in the database to pre-save the business data and its corresponding numbers to avoid exceptions in subsequent processes that may cause the business data to be unable to be found. After the operation of writing the data to the database is completed, the business data is sent to the distributed message queue in a serialized manner, and the business data can be entered into the computer device disk to ensure persistent storage and avoid the loss of business data due to abnormal interruptions.
[0112] Further, in some embodiments, using the first sub-node to number the service data includes:
[0113] The first sub-node uniquely numbers each piece of business data using a sequential self-increasing number according to a timestamp corresponding to each piece of business data.
[0114] It can be understood that in some embodiments, when business data enters the system, a unique number of date + serial number can be generated, for example, an 18-digit unique digital number of "date (yyyymmdd) + 10-digit digital number", where the "10-digit digital number" is maintained in a database table, and the database row-level lock mechanism is used to limit it to only allow single-row operations, so as to achieve sequential self-increment and unique use, thereby quickly numbering the business data.
[0115] In some embodiments, using a second sub-node in a business processing cluster to monitor the distributed message queue in real time and screening to obtain business data corresponding to a message topic matching the second sub-node includes:
[0116] Determine a message subject that matches the second sub-node from a preset message subject matching table;
[0117] The second sub-node is used to monitor the distributed message queue in real time to obtain business data corresponding to the message topic.
[0118] It can be understood that, in some embodiments, the first sub-node is responsible for writing all business data into the database and sending it to the distributed message queue, and the second sub-node and subsequent sub-nodes are responsible for the decoupling of the business data processing process. Specifically, the second sub-node first needs to determine the message subject it needs to process, and then quickly obtain the business data corresponding to the message subject that matches the second sub-node from the distributed message queue in real time to facilitate subsequent data processing.
[0119] In some embodiments, the distributed cache cluster is used to cache and lock the screening results, including:
[0120] Utilizing a distributed cache cluster to cache the screening results;
[0121] Determine a lock timeout period for each piece of business data in the screening result according to the business type of each piece of business data in the screening result;
[0122] The distributed cache cluster is used to lock the data of the screening result by taking the unique number of each business data in the screening result as the key value lock and taking the lock timeout time as the lock time.
[0123] It can be understood that in some embodiments, in order to ensure that data is not consumed repeatedly, it is necessary to add a distributed lock to the distributed cache cluster (such as redis) with the unique number of the data as the key value to lock the data. Specifically, the lock timeout period of each business data is determined by its corresponding business type. The business type can be set according to the business scenario to achieve accurate classification. After that, the lock timeout period is used as the lock time, and the unique number of each business data is used as the key value lock to achieve fast and accurate locking of the screening results.
[0124] In some embodiments, determining the lock timeout time of each piece of business data in the screening result according to the business type of each piece of business data in the screening result includes:
[0125] Classifying the screening results according to the business type of each piece of business data in the screening results;
[0126] Based on the classification results, the processing time of obtaining the historical business data corresponding to each business type in the screening results;
[0127] Calculate the average processing time of a single piece of business data corresponding to each business type in the screening result according to the processing time of the historical business data and the amount of historical business data;
[0128] For different business types, the product of the average processing time of the single business data and a preset coefficient is used as the lock timeout time.
[0129] It can be understood that, in some embodiments, the screening results may contain business data of multiple business types. When determining the lock timeout time, the screening results are first classified according to the business type, and then the historical time consumption information is called. The average processing time of a single business data corresponding to the screening results of each business type is calculated based on the classification results. In order to ensure that the lock timeout time can prevent deadlock and provide high availability to a certain extent, and ensure that the lock does not fail prematurely when the operation is not completed, the average processing time of a single business data needs to be multiplied by a preset coefficient. In some typical embodiments, the preset coefficient can be 10. The preset coefficients and lock timeout times of business data of different business types may be different, and this document does not limit this.
[0130] In some embodiments, the second sub-node performs multi-layer data processing on the locked screening result to obtain a processing result, and updates the processing result to the database, including:
[0131] The second sub-node uses a preset rule model to perform multi-layer data processing on the screening result to obtain a processing result;
[0132] The processing result is updated to the database.
[0133] It can be understood that in some embodiments, the preset rule model has preset calculation rules, and the second sub-node processes the screening results based on the rule model to quickly and accurately obtain the processing results, and updates the processing results to the database in a timely manner so that the next node can start the business data processing process.
[0134] In some embodiments, other sub-nodes in the business processing cluster repeat the above steps of monitoring and updating the database by screening the corresponding business data based on a preset topological sorting sequence, thereby completing the asynchronous message processing, further comprising:
[0135] The other sub-nodes determine the node execution order based on a preset topological sorting sequence;
[0136] Determine a traffic distribution strategy based on a load balancing mechanism according to the message topics matched by each sub-node in the other sub-nodes and the execution order of the nodes;
[0137] According to the traffic distribution strategy, the other sub-nodes repeat the above steps of monitoring and updating the database by screening the corresponding business data in the order of node execution, thereby completing asynchronous message processing.
[0138] It can be understood that, in some embodiments, the preset topological sorting sequence means that the sub-nodes of the business processing cluster have a preset topological sorting, and the topological sorting sequence can reflect the execution order of the sub-nodes. However, since parallel execution may occur between different sub-nodes, and the amount of business data that needs to be processed by the sub-nodes executed in parallel is also different, or it changes dynamically over time, in the face of possible high-concurrency scenarios, it is necessary to consider the traffic distribution strategy during parallel execution. Specifically, it is first necessary to measure the number of message topics matched by each sub-node and the amount of business data involved in each message topic in the process of historical business data processing. For a sub-node, the more message topics and the more business data involved in the message topics, the more traffic the sub-node needs. The node execution order can be used to determine the parallel execution of the sub-nodes. For scenarios where parallel execution is not required, the traffic distribution strategy There is no need to consider which sub-node to allocate traffic to. At the same time, based on the load balancing mechanism, in the case of parallel execution, more traffic is allocated to the sub-nodes that currently need to process more business data. At the same time, based on the historical business processing process, the traffic distribution is adjusted dynamically in real time to allocate more traffic to the sub-nodes that may need to process more business data. For example, in a specified time period every day, sub-node X needs to process more business data, and sub-node Y that processes in parallel with it needs to process less business data. In this case, the traffic distribution strategy can be set in advance before the specified time period every day to adjust the traffic distribution. According to the traffic distribution strategy, other sub-nodes in the business processing cluster repeat the above listening and filtering corresponding business data in the order of node execution to update the database, thereby completing asynchronous message processing, improving data flow efficiency, and reducing dependence on database performance.
[0139] It should be noted that, although the operations of the method of the present invention are described in a specific order in the above embodiments and the accompanying drawings, this does not require or imply that the operations must be performed in the specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.
[0140] Corresponding to the above-mentioned asynchronous message processing method, some embodiments of this specification also provide a device, referring to Figure 5 As shown, in some embodiments, the apparatus may include:
[0141] Receiving module 501, used for receiving business data;
[0142] The transmission module 502 is used to write the business data into the database and send it to the distributed message queue by using the first sub-node in the business processing cluster;
[0143] A screening module 503 is used to monitor the distributed message queue in real time using the second sub-node in the business processing cluster, and screen the business data corresponding to the message subject matching the second sub-node;
[0144] The locking module 504 is used to cache and lock the data of the screening results by using the distributed cache cluster;
[0145] The updating module 505 is used for the second sub-node to perform multi-layer data processing on the locked screening result to obtain a processing result, and update the processing result to the database.
[0146] Corresponding to the above-mentioned asynchronous message processing method, based on the same inventive concept, some embodiments of this specification also provide an asynchronous message processing system. In some embodiments, the asynchronous message processing system includes a business processing cluster, a distributed cache cluster, a distributed message queue and a database. The asynchronous message processing system is used to execute the method described in any of the above embodiments.
[0147] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0148] It should be noted that in the embodiments of this specification, the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved are all information and data authorized by the user and fully authorized by all parties.
[0149] It should be noted that the computer program product described in this application is a software product that mainly implements the method described in this application through a computer program.
[0150] The embodiments of this specification also provide a computer device. Figure 6As shown, in some embodiments of the present specification, the computer device 602 may include one or more processors 604, such as one or more central processing units (CPUs) or graphics processing units (GPUs), and each processing unit may implement one or more hardware threads. The computer device 602 may also include any memory 606, which is used to store any kind of information such as code, settings, data, etc. In a specific embodiment, the computer program on the memory 606 and can be run on the processor 604, when the computer program is run by the processor 604, the instructions of the method described in any of the above embodiments may be executed. Non-limiting, for example, the memory 606 may include any one or more combinations of the following: any type of RAM, any type of ROM, flash memory device, hard disk, optical disk, etc. More generally, any memory may use any technology to store information. Further, any memory may provide volatile or non-volatile retention of information. Further, any memory may represent a fixed or removable component of the computer device 602. In one case, when the processor 604 executes an associated instruction stored in any memory or a combination of memories, the computer device 602 may perform any operation of the associated instruction. The computer device 602 also includes one or more drive mechanisms 608 for interacting with any storage, such as a hard disk drive mechanism, an optical disk drive mechanism, etc.
[0151] The computer device 602 may also include an input / output interface 610 (I / O) for receiving various inputs (via input devices 612) and for providing various outputs (via output devices 614). A specific output mechanism may include a presentation device 616 and an associated graphical user interface 618 (GUI). In other embodiments, the input / output interface 610 (I / O), input device 612, and output device 614 may not be included, and the computer device 602 may be used as a computer device in a network. The computer device 602 may also include one or more network interfaces 620 for exchanging data with other devices via one or more communication links 622. One or more communication buses 624 couple the components described above together.
[0152] The communication link 622 may be implemented in any manner, for example, through a local area network, a wide area network (e.g., the Internet), a point-to-point connection, etc., or any combination thereof. The communication link 622 may include any combination of hardwired links, wireless links, routers, gateway functions, name servers, etc. governed by any protocol or combination of protocols.
[0153] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), computer-readable storage media, and computer program products of some embodiments of the present specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processor to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processor generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0154] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processor to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0155] These computer program instructions can also be loaded onto a computer or other programmable data processor so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0156] In a typical configuration, a computer device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0157] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0158] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computer device. As defined in this specification, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0159] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, the embodiments of this specification may take the form of complete hardware embodiments, complete software embodiments or embodiments combining software and hardware. Moreover, the embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0160] The present specification embodiments may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present specification embodiments may also be practiced in distributed computing environments where tasks are performed by remote processors connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0161] It should also be understood that in the embodiments of this specification, the term "and / or" is only a description of the association relationship of the associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0162] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0163] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the embodiments of this specification. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0164] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. An asynchronous message processing method, characterized in that: The method comprises: Receive business data; Using the first child node in the business processing cluster, the business data is written into a database and sent to a distributed message queue; Using a second sub-node in the business processing cluster to monitor the distributed message queue in real time, and screening to obtain business data corresponding to a message topic matching the second sub-node; Use distributed cache cluster to cache the screening results and lock the data; The second sub-node performs multi-layer data processing on the locked screening result to obtain a processing result, and updates the processing result to the database; The other sub-nodes in the business processing cluster repeat the above steps of monitoring and filtering the corresponding business data to update the database based on the preset topological sorting sequence, thereby completing the asynchronous message processing.
2. The method according to claim 1, characterized in that Using a first child node in a business processing cluster, writing the business data into a database, and sending the business data to a distributed message queue, including: Using the first sub-node, numbering the service data; Write the numbered business data and its corresponding number into the database, and return a data writing completion flag; In response to the data writing completion flag, the business data is sent to the distributed message queue in a serialized manner.
3. The method according to claim 2, characterized in that Using the first sub-node to number the service data includes: The first sub-node uniquely numbers each piece of business data using a sequential self-increasing number according to a timestamp corresponding to each piece of business data.
4. The method according to claim 1, characterized in that: Using the second sub-node in the business processing cluster to monitor the distributed message queue in real time, and screening to obtain business data corresponding to the message subject matching the second sub-node, includes: Determine a message subject that matches the second sub-node from a preset message subject matching table; The second sub-node is used to monitor the distributed message queue in real time to obtain business data corresponding to the message topic.
5. The method according to claim 1, characterized in that Use the distributed cache cluster to cache the screening results and lock the data, including: Utilizing a distributed cache cluster to cache the screening results; Determine a lock timeout period for each piece of business data in the screening result according to the business type of each piece of business data in the screening result; The distributed cache cluster is used to lock the data of the screening result by taking the unique number of each business data in the screening result as the key value lock and taking the lock timeout time as the lock time.
6. The method according to claim 5, characterized in that Determining a lock timeout period for each piece of business data in the screening result according to the business type of each piece of business data in the screening result includes: Classifying the screening results according to the business type of each piece of business data in the screening results; Based on the classification results, the processing time of obtaining the historical business data corresponding to each business type in the screening results; Calculate the average processing time of a single piece of business data corresponding to each business type in the screening result according to the processing time of the historical business data and the amount of historical business data; For different business types, the product of the average processing time of the single business data and a preset coefficient is used as the lock timeout time.
7. The method according to claim 1, characterized in that The second sub-node performs multi-layer data processing on the locked screening result to obtain a processing result, and updates the processing result to the database, including: The second sub-node uses a preset rule model to perform multi-layer data processing on the screening result to obtain a processing result; The processing result is updated to the database.
8. The method according to claim 1, characterized in that The other sub-nodes in the business processing cluster repeat the above steps of monitoring and updating the database by screening the corresponding business data based on the preset topological sorting sequence, thereby completing the asynchronous message processing, further comprising: The other sub-nodes determine the node execution order based on a preset topological sorting sequence; Determine a traffic distribution strategy based on a load balancing mechanism according to the message topics matched by each sub-node in the other sub-nodes and the execution order of the nodes; According to the traffic distribution strategy, the other sub-nodes repeat the above steps of monitoring and updating the database by screening the corresponding business data in the order of node execution, thereby completing asynchronous message processing.
9. An asynchronous message processing device, characterized in that: The device comprises: A receiving module, used for receiving business data; A transmission module, used to write the business data into a database using a first sub-node in the business processing cluster, and send it to a distributed message queue; A screening module, used to monitor the distributed message queue in real time by using the second sub-node in the business processing cluster, and screen and obtain business data corresponding to the message subject matching the second sub-node; The locking module is used to cache the screening results and lock the data using the distributed cache cluster; An updating module, used for the second sub-node to perform multi-layer data processing on the locked screening result to obtain a processing result, and update the processing result to the database; The repetition module is used for other sub-nodes in the business processing cluster to repeat the above steps of updating the database by monitoring and screening the corresponding business data based on a preset topological sorting sequence, thereby completing asynchronous message processing.
10. An asynchronous message processing system, characterized in that: The asynchronous message processing system includes a business processing cluster, a distributed cache cluster, a distributed message queue and a database, and the asynchronous message processing system is used to execute the method described in any one of claims 1-8.
11. A computer device comprising a memory, a processor, and a computer program stored in the memory, characterized in that: When the computer program is executed by the processor, the computer program executes the instructions of the method according to any one of claims 1 to 8.
12. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor of a computer device, the computer program executes the instructions of the method according to any one of claims 1 to 8.
13. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the instructions of the method according to any one of claims 1 to 8 are executed.
Citation Information
Patent Citations
Visual assembly line generation method and device, storage medium and electronic equipment
CN114398115A
Cluster multi-node caching method and device
CN115242811A
Orchestration method, orchestration device, electronic equipment, storage medium and program product
CN117931473A
Distributed dispatch system deployment method, system and apparatus, distributed dispatch system dispatch method, system and apparatus, and medium
WO2024103983A1
Cited By
Data processing method and device, equipment and storage medium
CN120849412A
