Service message processing method and apparatus, and electronic device

By judging whether the sub-service is the first sub-service of the business chain when receiving the target service message of the target sub-service, and with the help of the service processing status table and the business relationship table, the actual and preset processing status values ​​of the previous sub-service are queried, which solves the problem that the message consumption order of different topics cannot be guaranteed, and the orderly execution of sub-services in the business chain and the correctness of the overall business is achieved.

CN119603120APending Publication Date: 2025-03-11HILLSTONE NETWORKS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411487567.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-23
Publication Date
2025-03-11

AI Technical Summary

Technical Problem

In enterprise-level applications, when processing complex business chains composed of multiple sub-services, the message consumption order of different topics cannot be guaranteed, resulting in business errors.

Method used

When receiving the target service message of the target sub-service, it is determined whether the sub-service is the first sub-service of the business chain, and with the help of the service processing status table and the business relationship table, it is queried to ensure that the message is processed only when the actual status value is the same as the preset status value.

Benefits of technology

The orderly control of business message processing is realized, ensuring the correct execution order of sub-services in the business chain, and avoiding overall business errors caused by incorrect processing order.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119603120A_ABST
    Figure CN119603120A_ABST
Patent Text Reader

Abstract

The invention discloses a service message processing method and device and electronic equipment, and relates to the technical field of distribution.The method comprises the steps that under the condition that a target service message of a target sub-service is received, whether the target sub-service is a first sub-service on a target service chain or not is judged, under the condition that the target sub-service is not the first sub-service on the target service chain, in a service processing state table corresponding to the target service chain identifier, querying an actual state value used for representing an actual processing state of a previous sub-service of the target sub-service, and in a service relation table associated with the target service chain identifier, querying an actual state value used for representing an actual processing state of the previous sub-service of the target sub-service; and querying a processing completion state value preset for the previous sub-service of the target sub-service, and processing the target service message under the condition that the actual state value of the previous sub-service is the same as the preset processing completion state value. According to the invention, the technical problem of business errors caused by the fact that each business message cannot be processed according to the business sequence in the prior art is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of distributed technology, and in particular to a method and device for processing business messages, and an electronic device. Background Art

[0002] Currently, in order to process business quickly, distributed platforms (such as Kafka) can be used to process various business messages. As an efficient and reliable distributed stream processing platform, Kafka is widely used in the construction of real-time data pipelines and streaming applications. When a producer creates a message, the hash map of the message key and the partitioner can ensure that the same type of messages are written to the same partition of a specific topic in chronological order. In this way, when processing streaming data with tight internal logic and consistent data format, the order of messages can be effectively maintained, thereby simplifying the complexity of downstream processing.

[0003] However, in enterprise-level applications, it is often necessary to deal with complex business chains consisting of multiple sub-businesses. These sub-businesses may have a temporal dependency relationship between each other, but due to the heterogeneity of business data, that is, the data format and structure of different sub-businesses may be different, so these data often need to be sent to different topics. Although the messages within each topic can maintain order, the order of message consumption across topics cannot be guaranteed. Specifically, different topics are consumed by independent thread listeners, which means that even if the producer sends messages in chronological order, due to factors such as network delays and differences in thread processing speeds, the consumer side may still encounter the problem of out-of-order messages between different topics.

[0004] Figure 1 This is an optional schematic diagram of the consumption sequence of messages from different topics of Kafka based on related technologies, such as Figure 1 As shown in the figure, relying on producers to send messages in order, the purpose of multiple consumers (such as consumer 1, consumer 2, and consumer 3) consuming in order is achieved. For example, the producer sends messages in order of business (such as first sending business 1 to consumer 1, then sending business 2 to consumer 2, and then sending business 3 to consumer 3), and then consumer 1 processes business 1 first, and after business 1 is processed, consumer 2 processes business 2, and after business 2 is processed, consumer 3 processes business 3.

[0005] Figure 2 This is an optional schematic diagram of the out-of-order consumption sequence of messages from different topics of Kafka based on related technologies, such as Figure 2As shown in the figure, although the producer sends messages in order, due to network delays, different processing speeds of different threads, etc., the previous business has not been processed or is being processed, and the next business has been processed. For example, the producer sends messages in order of business (such as sending business 1 to consumer 1 first, then sending business 2 to consumer 2, and then sending business 3 to consumer 3), and then consumer 1 processes business 1 first. When business 1 is not processed, consumer 2 starts to process business 2. When business 2 is not processed, consumer 3 also starts to process business 3, which leads to the problem of disorderly consumption of messages.

[0006] However, the related technologies can only guarantee the orderly production and consumption of messages in the same partition of the same topic. Therefore, in business processing scenarios involving multiple topics, messages from different topics cannot be guaranteed to be consumed in an orderly manner, and cannot meet the processing requirements of businesses with order requirements.

[0007] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0008] The embodiments of the present invention provide a method and device for processing a business message, and an electronic device, so as to at least solve the technical problem in the related art that it is impossible to ensure that each business message is processed in a business order, resulting in business errors.

[0009] According to one aspect of an embodiment of the present invention, a method for processing a business message is provided, comprising: upon receiving a target business message of a target sub-business, determining whether the target sub-business is the first sub-business on a target business chain, wherein the target business message carries a target business chain identifier; in a business processing status table corresponding to the target business chain identifier, querying an actual status value for characterizing an actual processing status of a previous sub-business of the target sub-business; in a business relationship table associated with the target business chain identifier, querying a processing completion status value preset for the previous sub-business of the target sub-business; and processing the target business message when the actual status value of the previous sub-business is the same as the preset processing completion status value.

[0010] Furthermore, the processing method also includes: determining a business chain for each business, wherein each of the business chains contains N sub-businesses, and N is a positive integer; for each business chain, using the identifier of the nth sub-business on the business chain as the primary key, and using the identifier of the n-1th sub-business and the processing completion status value preset for the nth sub-business as the key value of the primary key, constructing a business relationship table associated with the business chain identifier of the business chain, wherein n is an integer greater than 1 and less than or equal to N.

[0011] Furthermore, the target sub-business is the nth sub-business on the target business chain, and in the business relationship table associated with the target business chain identifier, the preset processing completion status value of the previous sub-business of the target sub-business is queried, including: when querying the preset processing completion status value of the previous sub-business of the nth sub-business, the identifier of the nth sub-business is used as the primary key to query in the business relationship table, and after querying the identifier of the n-1th sub-business, the identifier of the n-1th business is used as the primary key to query in the business relationship table for the preset processing completion status value of the n-1th sub-business.

[0012] Furthermore, after querying the processing completion status value preset for the previous sub-business of the target sub-business in the business relationship table associated with the target business chain identifier, it also includes: when the actual status value is different from the processing completion status value, pausing the processing of the target business message and determining the waiting time threshold of the target sub-business; when the pause time reaches the waiting time threshold, re-determining the latest actual status value corresponding to the previous sub-business of the target sub-business from the business processing status table; when the latest actual status value is different from the processing completion status value, continuing to suspend the waiting time threshold and then re-determining the actual status value until the re-determined actual status value is equal to the processing completion status value, or the number of times the actual status value is re-determined reaches a preset retry threshold.

[0013] Furthermore, the step of determining the waiting time threshold of the target sub-service includes: determining a basic waiting time, and determining an arrangement number of the target sub-service on the target service chain; determining a waiting coefficient of the target sub-service, wherein the waiting coefficient is positively correlated with the arrangement number and is greater than 1; determining an initial waiting time based on the basic waiting time and the waiting coefficient; when the waiting time is greater than or equal to the maximum waiting time, using the maximum waiting time as the waiting time threshold of the target sub-service, or, when the initial waiting time is less than the maximum waiting time, using the initial waiting time as the waiting time threshold of the target sub-service.

[0014] Further, determining whether the target sub-business is the first sub-business on the target business chain includes: when the processing completion status value of the target sub-business recorded in the business relationship table is equal to the initial value, determining that the target sub-business is the first sub-business on the target business chain; or, when the previous sub-business identifier of the target sub-business recorded in the business relationship table is an empty identifier, determining that the target sub-business is the first sub-business on the target business chain.

[0015] Furthermore, before querying the actual status value used to characterize the actual processing status of the previous sub-business of the target sub-business in the business processing status table corresponding to the target business chain identifier, the processing method also includes: judging whether the target business chain is in a normal state based on the actual status values ​​of all sub-businesses located before the target sub-business on the target business chain recorded in the business processing status table, so as to query the actual status value of the actual processing status of the previous sub-business of the target sub-business when the target business chain is in the normal state.

[0016] Furthermore, after processing the target business message, it also includes: when the processing result indicates that the processing is completed, the processing completion status value preset for the target sub-business in the business relationship table is used as the actual status value of the target sub-business, and is recorded in the business processing status table; or, when the processing result indicates that the processing is abnormal, the actual status value of the target sub-business in the business processing status table is recorded as the abnormal status value.

[0017] According to another aspect of an embodiment of the present invention, a service message processing device is also provided, including: a first judgment unit, used to determine whether the target sub-service is the first sub-service on the target service chain when a target service message of the target sub-service is received, wherein the target service message carries a target service chain identifier; a first query unit, used to query, in the service processing status table corresponding to the target service chain identifier, an actual status value used to characterize the actual processing status of the previous sub-service of the target sub-service when the target sub-service is not the first sub-service on the target service chain; a second query unit, used to query, in the service relationship table associated with the target service chain identifier, a processing completion status value preset for the previous sub-service of the target sub-service; and a processing unit, used to process the target service message when the actual status value of the previous sub-service is the same as the preset processing completion status value.

[0018] Furthermore, the processing device also includes: a first determination unit, used to determine the business chain of each business, wherein each of the business chains contains N sub-businesses, and N is a positive integer; a first construction unit, used to construct, for each business chain, a business relationship table associated with the business chain identifier of the business chain, using the identifier of the nth sub-business on the business chain as the primary key, and the identifier of the n-1th sub-business and the processing completion status value preset for the nth sub-business as the key value of the primary key, wherein n is an integer greater than 1 and less than or equal to N.

[0019] Furthermore, the target sub-business is the nth sub-business on the target business chain, and the second query unit includes: a first query module, used to use the identifier of the nth sub-business as the primary key to query in the business relationship table, and after querying the identifier of the n-1th sub-business, use the identifier of the n-1th business as the primary key to query the preset processing completion status value of the n-1th sub-business in the business relationship table.

[0020] Furthermore, the processing device also includes: a second determination unit, which is used to query the processing completion status value preset for the previous sub-business of the target sub-business in the business relationship table associated with the target business chain identifier, and, if the actual status value is different from the processing completion status value, suspend processing of the target business message and determine the waiting time threshold of the target sub-business; a third determination unit, which is used to re-determine the latest actual status value corresponding to the previous sub-business of the target sub-business from the business processing status table when the suspension time reaches the waiting time threshold; and a fourth determination unit, which is used to, if the latest actual status value is different from the processing completion status value, continue to suspend the waiting time threshold and then re-determine the actual status value until the re-determined actual status value is equal to the processing completion status value, or the number of times the actual status value is re-determined reaches a preset retry threshold.

[0021] Furthermore, the second determination unit includes: a first determination module, used to determine a basic waiting time and determine an arrangement number of the target sub-service on the target service chain; a second determination module, used to determine a waiting coefficient of the target sub-service, wherein the waiting coefficient is positively correlated with the arrangement number and is greater than 1; a third determination module, used to determine an initial waiting time based on the basic waiting time and the waiting coefficient; a first acting module, used to use the maximum waiting time as the waiting time threshold of the target sub-service when the waiting time is greater than or equal to the maximum waiting time, or to use the initial waiting time as the waiting time threshold of the target sub-service when the initial waiting time is less than the maximum waiting time.

[0022] Furthermore, the first judgment unit includes: a fourth determination module, used to determine that the target sub-business is the first sub-business on the target business chain when the processing completion status value of the target sub-business recorded in the business relationship table is equal to the initial value; a fifth determination module, used to determine that the target sub-business is the first sub-business on the target business chain when the previous sub-business identifier of the target sub-business recorded in the business relationship table is an empty identifier.

[0023] Furthermore, the processing device also includes: a second judgment unit, which is used to judge whether the target business chain is in a normal state based on the actual status values ​​of all sub-businesses on the target business chain located before the target sub-business recorded in the business processing status table before querying the actual status value of the actual processing status of the previous sub-business of the target sub-business in the business processing status table corresponding to the target business chain identifier, so as to query the actual status value of the actual processing status of the previous sub-business of the target sub-business when the target business chain is in the normal state.

[0024] Furthermore, the processing device also includes: a first recording unit, which is used to, after processing the target business message, when the processing result indicates that the processing is completed, use the processing completion status value preset for the target sub-business in the business relationship table as the actual status value of the target sub-business, and record it in the business processing status table; a second recording unit, which is used to, when the processing result indicates that the processing is abnormal, record the actual status value of the target sub-business in the business processing status table as an abnormal status value.

[0025] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, comprising one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement any one of the above-mentioned methods for processing business messages.

[0026] In the present invention, when a target business message of a target sub-business is received, it is determined whether the target sub-business is the first sub-business on the target business chain. If the target sub-business is not the first sub-business on the target business chain, the actual status value used to characterize the actual processing status of the previous sub-business of the target sub-business is queried in the business processing status table corresponding to the target business chain identifier. In the business relationship table associated with the target business chain identifier, the processing completion status value preset for the previous sub-business of the target sub-business is queried. When the actual status value of the previous sub-business is the same as the preset processing completion status value, the target business message is processed, thereby solving the technical problem in the related art that it is impossible to ensure that each business message is processed in the business order, resulting in business errors.

[0027] In the present invention, by introducing a business processing status table and a business relationship table, when the currently processed sub-business is not the first sub-task in the business chain, the actual status value corresponding to the previous sub-business of the sub-business can be obtained from the business processing status table, and the processing completion status value corresponding to the previous sub-business of the sub-business can be obtained from the business relationship table. By comparing the actual status value with the processing completion status value, the business message of the sub-business can be processed when the two values ​​are equal, thereby realizing orderly control of business message processing, ensuring the correct execution order of sub-businesses in the business chain, avoiding the problem of overall business errors caused by disordered processing order, and achieving the technical effect that even if each business message is stored in a different topic, each business message can still be processed in the business order. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0029] Figure 1 It is a schematic diagram of the optional consumption sequence of messages from different topics of Kafka based on relevant technologies;

[0030] Figure 2 This is a schematic diagram of an optional out-of-order consumption sequence of messages from different topics of Kafka based on related technologies;

[0031] Figure 3 is a flowchart of an optional method for processing a service message according to an embodiment of the present invention;

[0032] Figure 4 is a schematic diagram of an optional business relationship table structure according to an embodiment of the present invention;

[0033] Figure 5 is a flow chart of an optional method for processing a service message according to an embodiment of the present invention;

[0034] Figure 6 is a schematic diagram of an optional service message processing device according to an embodiment of the present invention;

[0035] Figure 7 The present invention is a hardware structure block diagram of an electronic device for a method for processing business messages according to an embodiment of the present invention. DETAILED DESCRIPTION

[0036] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0037] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention 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 interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0038] It should be noted that the relevant information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) collected and involved in the present invention are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of relevant data are in compliance with the relevant laws, regulations and standards of the relevant regions, necessary confidentiality measures are taken, and public order and good customs are not violated, and corresponding operation entrances are provided for users to choose to authorize or refuse. For example, an interface is set between the system and the relevant users or organizations. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain relevant information after receiving the consent information fed back by the aforementioned user or organization.

[0039] The present invention proposes a method for ensuring the order of message consumption. When there are multiple business associations, even if the information is stored in different topics of Kafka, consumers can consume in the established business order, coordinate the disordered consumption, ensure the overall order and correctness of the business chain, and effectively avoid the problem of overall business errors caused by disordered consumption order.

[0040] In the present invention, by constructing a business processing state table and a business relationship table, orderly control and state tracking of business message processing are achieved, ensuring the correct execution order of sub-businesses in the business chain. In addition, by using a business coordinator and a sequential waiting retry mechanism, it can be ensured that even if the messages are stored in different topics of Kafka, the purpose of sequential consumption of messages can still be achieved.

[0041] The present invention is described in detail below in conjunction with various embodiments.

[0042] Embodiment 1

[0043] According to an embodiment of the present invention, an embodiment of a method for processing a business message is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0044] In an embodiment of the present invention, when a producer (such as each business system for producing business messages) creates messages for each business, the topic can be determined according to the business type, and a message key value can be specified. The partitioner then generates a hash value according to the message key value to map the message to the specified partition of the topic. When the producer produces messages of the same business type in accordance with the business sequence, by specifying the partition, it can be ensured that the messages with the same message key value are written to a partition of the same topic, thereby achieving the sequentiality of message consumption in the same partition or the same topic. For messages of different business types, due to different topics, it is necessary to achieve the sequentiality of message consumption on different topics according to the following business message processing steps.

[0045] Figure 3 is a flowchart of an optional method for processing a service message according to an embodiment of the present invention. Figure 3 As shown, the method comprises the following steps:

[0046] Step S301: upon receiving a target service message of a target sub-service, determining whether the target sub-service is the first sub-service on a target service chain, wherein the target service message carries a target service chain identifier.

[0047] In step S301, if the consumer thread (i.e., the consumer, used to process business messages) receives a target business message of a target sub-business (i.e., the sub-business currently being processed), it is necessary to first determine whether the target sub-business is the first sub-business on the target business chain (i.e., the business chain indicated by the target business chain identifier carried by the target business message).

[0048] In an embodiment of the present invention, if the sub-business is the first sub-business, the target business message can be directly processed, and after the processing is completed, the actual status value of the sub-business in the business processing status table is updated according to the processing result, wherein the actual status value refers to the actual status of the sub-business after the processing is completed. For example, if the processing result indicates that the processing is completed normally, the status value of the sub-business in the business processing status table is updated to the processing completion status value, indicating that the sub-business is processed normally; if the processing result indicates that the processing is abnormal, the status value of the sub-business in the business processing status table is updated to the abnormal status value (such as -1), indicating that an abnormality occurs during the processing of the sub-business.

[0049] In the embodiment of the present invention, a complete business may be composed of different sub-businesses, and there may be dependencies between the sub-businesses. When all sub-businesses are processed, it means that the business is completed. Here, the complete business can be defined as a business chain, each business chain can contain multiple sub-businesses, and different sub-businesses can also be represented by business 1, business 2, etc. The business types of different sub-businesses on the same business chain can be different.

[0050] Step S302: when the target sub-business is not the first sub-business on the target business chain, query the actual status value representing the actual processing status of the previous sub-business of the target sub-business in the business processing status table corresponding to the target business chain identifier.

[0051] In step S302, if the target sub-business is not the first sub-business on the target business chain, the actual status value (i.e., the current latest status value) corresponding to the previous sub-business of the target sub-business can be obtained from the business processing status table corresponding to the target business chain identifier. For example, the previous sub-business corresponding to the target sub-business can be first determined from the business relationship table, and then the actual status value of the actual processing status corresponding to the previous sub-business can be queried from the business processing status table.

[0052] In some examples, if the target sub-service is not the first sub-service in the target service chain, the target service message of the target sub-service is sent directly.

[0053] In an embodiment of the present invention, the business processing status table is used to record the current actual status value of each sub-business on each business chain (including: the status value of completed processing (the processing completion status value of each sub-business on the same business chain is different), the unprocessed status value (such as 0), and the abnormal status value (such as -1)).

[0054] Step S303: In the business relationship table associated with the target business chain identifier, a processing completion status value preset for a previous sub-business of the target sub-business is searched.

[0055] In step S303, the processing completion status value corresponding to the previous sub-business of the target sub-business can be obtained from the business relationship table associated with the target business chain identifier, so as to determine whether the business message can be processed at present by comparing the actual status value with the processing completion status value. For example, the previous sub-business corresponding to the target sub-business can be determined from the business relationship table first, and then the preset processing completion status value corresponding to the previous sub-business can be queried.

[0056] In an embodiment of the present invention, each business chain corresponds to a business relationship table, which is used to record the sequential relationship between the sub-businesses on the business chain and the processing completion status value of each sub-business. The processing completion status value of each sub-business is pre-set, and the processing completion status value of each sub-business is different.

[0057] Step S304: When the actual status value of the previous sub-service is the same as the preset processing completion status value, the target service message is processed.

[0058] In step S304, if the actual status value is determined to be equal to the preset processing completion status value, it indicates that all sub-services before the current sub-service have been processed and the current service message can be processed. If the actual status value is determined to be different from the preset processing completion status value, it indicates that the previous sub-service of the current sub-service is still being processed or is in an abnormal processing state. It is necessary to wait for a period of time and re-acquire the actual status value of the previous sub-service to determine whether the previous sub-service has been processed. If not, continue to wait and retry until the maximum number of retries is reached and no more retries are made.

[0059] In summary, when a target business message of a target sub-business is received, it can be determined whether the target sub-business is the first sub-business on the target business chain. When the target sub-business is not the first sub-business on the target business chain, the actual status value used to characterize the actual processing status of the previous sub-business of the target sub-business is queried in the business processing status table corresponding to the target business chain identifier. In the business relationship table associated with the target business chain identifier, the processing completion status value preset for the previous sub-business of the target sub-business is queried. When the actual status value of the previous sub-business is the same as the preset processing completion status value, the target business message is processed, which solves the technical problem in the related technology that it is impossible to ensure that each business message is processed in the business order, resulting in business errors.

[0060] In order to accurately construct a business relationship table, in the business message processing method provided in Example 1 of the present application, the business chain of each business is determined, wherein each business chain contains N sub-businesses, and N is a positive integer; for each business chain, the identifier of the nth sub-business on the business chain is used as the primary key, and the identifier of the n-1th sub-business and the processing completion status value preset for the nth sub-business are used as the key value of the primary key to construct a business relationship table associated with the business chain identifier of the business chain, wherein n is an integer greater than 1 and less than or equal to N.

[0061] In some optional embodiments, after determining the business chain of each business, for each business, based on the execution order of the sub-businesses included in the business, the previous sub-business identifier of each sub-business on the business chain and the processing completion status value of the sub-business are determined, and when the sub-business is the first sub-business on the business chain, the previous sub-business identifier of the sub-business is determined to be an empty identifier; the sub-business identifier of each sub-business on the business chain is used as the primary key, and the previous sub-business identifier and the processing completion status value corresponding to the sub-business are used as the key value of the primary key; for each business, all primary keys are arranged based on the execution order, and based on all the arranged primary keys and the key values ​​corresponding to the primary keys, a business relationship table of the business is constructed.

[0062] In an embodiment of the present invention, the business chain of each business can be determined first (that is, by dividing the complete business to obtain multiple independent sub-businesses, such as business 1, business 2, etc., so as to determine the corresponding business chain according to the business execution order). Then, according to the order relationship between the sub-businesses, the current sub-business name, the previous sub-business name of the current sub-business and the processing completion status value corresponding to the current sub-business can be saved to form a business relationship table (that is, the business relationship table). Specifically: according to the execution order of the sub-businesses included in the business, the previous sub-business identifier (which can be the previous sub-business name) of each sub-business on the business chain and the processing completion status value of the sub-business can be determined (the processing completion status value can be determined according to the execution order number of the sub-business, for example, if the sub-business is ranked 2 in the business chain, the processing completion status value can be 2). If the sub-business is the first sub-business on the business chain, the previous sub-business identifier of the sub-business is determined to be a null identifier (null) to indicate that the sub-business is the first sub-business to be processed on the business chain. Then, the sub-business identifier of each sub-business on the business chain is used as the primary key, and the previous sub-business identifier and the processing completion status value corresponding to the sub-business are used as the key value of the primary key. Then, all primary keys are arranged according to the execution order of the sub-businesses, and a business relationship table of the business is constructed based on all the arranged primary keys and the key values ​​corresponding to the primary keys. That is, the identifier of the nth (n is an integer greater than 1 and less than or equal to N) sub-business on the business chain is used as the primary key, the identifier of the n-1th sub-business and the processing completion status value preset for the nth sub-business are used as the key value of the primary key, and a business relationship table associated with the business chain identifier of the business chain is constructed.

[0063] Figure 4 is a schematic diagram of an optional business relationship table structure according to an embodiment of the present invention, such as Figure 4 As shown, a business relationship table of a business chain is shown, wherein the business chain includes business 1, business 2, business 3, ..., business n-1, and business n. The sub-business identifier of each sub-business (i.e., business 1, business 2, business 3, ..., business n-1, and business n) is used as the primary key, and the previous sub-business identifier of each sub-business and the processing completion status value are used as the key value of the corresponding primary key. For example, the key value corresponding to the primary key business 1 is null and 1; the key value corresponding to the primary key business 2 is business 1 and 2; the key value corresponding to the primary key business 3 is business 2 and 3; the key value corresponding to the primary key business n-1 is business n-2 and n-1; the key value corresponding to the primary key business n is business n-1 and n.

[0064] In the embodiment of the present invention, the service relationship table is a data structure for storing the order relationship between sub-services. This data structure can be in the form of a hash table, where the key is the sub-service name, and the value is an object containing the name of the previous sub-service and the processing completion status value of the current sub-service. In this way, the previous sub-service of a specific sub-service and its processing completion status value can be quickly located, thereby effectively supporting the order judgment and control between sub-services.

[0065] like Figure 4 As shown, in the business relationship table, for each sub-business, the name of its previous sub-business is either the name of another sub-business or null, indicating that the sub-business has no direct previous item. In this way, the sequential dependency of the sub-businesses can be clearly defined. The existence of null indicates that the sub-business is the starting point of the business chain and can start processing without waiting for other previous sub-businesses to be completed. In addition, each sub-business is also associated with a status value in the business relationship table, which is used to record the processing completion status value of the sub-business, so that it can be judged whether the previous sub-business of the sub-business being executed has been processed according to the processing completion status value of the sub-business in the future, thereby effectively avoiding out-of-order execution.

[0066] In some optional embodiments, an initialization business processing status table can be established, in which the initialization actual status value of the sub-business of each business chain is an unprocessed status value (such as 0), and then the actual status value corresponding to each sub-business in the business processing status table is updated according to the actual processing status of each sub-business (including: processing completion status value, unprocessed completion status value, abnormal status value) (that is, the actual status value of each sub-business in the business processing status table is updated after the business message of the sub-business is processed).

[0067] In an embodiment of the present invention, the business status of each sub-business on each business chain can be initialized first, that is, the actual status value of each sub-business is initialized to an unprocessed status value (such as 0), and then a business processing status table (business processing status record table) is constructed based on the actual status values ​​of the sub-businesses with the business chain.

[0068] In the embodiment of the present invention, the service processing status table is used to track the service status of each sub-service, and record whether the sub-service has been processed in the form of a numerical value, for example, 0 indicates unprocessed, and -1 indicates abnormal processing. This status recording mechanism provides real-time feedback on the progress of service processing, which facilitates the service coordinator to determine whether to continue processing the next sub-service.

[0069] In the embodiment of the present invention, the actual status value of each sub-service in the service processing status table is updated after the service message of the sub-service is processed, thereby ensuring that the actual status value of each sub-service is always kept up to date.

[0070] Table 1 is an optional business processing status record table in this embodiment. As shown in Table 1, the actual status value of each sub-business on each business chain is recorded, where 0 represents an unprocessed business status, -1 represents an abnormal business status, and 1, 2, and 3 represent the business status of business 1, business 2, and business 3 after processing is completed, respectively.

[0071] Table 1

[0072] Business chain name Business 1 Business 2 Business 3 Business Business Chain 1 1 2 3 0 Business Chain 2 1 -1 0 0 Business Chain 0 0 0 0

[0073] In order to accurately query the preset processing completion status value of the previous sub-business of the current sub-business, in the business message processing method provided in Example 1 of the present application, the target sub-business is the nth sub-business on the target business chain, and the identifier of the nth sub-business is used as the primary key to query in the business relationship table, and after querying the identifier of the n-1th sub-business, the identifier of the n-1th business is used as the primary key to query the preset processing completion status value of the n-1th sub-business in the business relationship table.

[0074] In an embodiment of the present invention, when querying the preset processing completion status value of the previous sub-business of the nth sub-business, the identifier of the nth sub-business can be used as the primary key to query the identifier of the previous sub-business corresponding to the nth sub-business (that is, the identifier of the n-1th sub-business) in the business relationship table, and after querying the identifier of the n-1th sub-business, the identifier of the n-1th business can be used as the primary key to query the preset processing completion status value corresponding to the n-1th sub-business in the business relationship table.

[0075] In order to ensure the sequential consumption of messages, in the business message processing method provided in Example 1 of the present application, in the business relationship table associated with the target business chain identifier, after querying the processing completion status value preset for the previous sub-business of the target sub-business, if the actual status value is different from the processing completion status value, the processing of the target business message is suspended, and the waiting time threshold of the target sub-business is determined; if the suspension time reaches the waiting time threshold, the latest actual status value corresponding to the previous sub-business of the target sub-business is re-determined from the business processing status table; if the latest actual status value is different from the processing completion status value, continue to suspend the waiting time threshold and then redetermine the actual status value until the re-determined actual status value is equal to the processing completion status value, or the number of times the actual status value is re-determined reaches the preset retry threshold.

[0076] In an embodiment of the present invention, if the actual status value is not equal to the processing completion status value, then after waiting for the waiting time threshold corresponding to the target sub-business, the latest actual status value of the previous sub-business is re-acquired to determine whether the previous sub-business has been processed. If it is not completed (that is, the latest actual status value is not equal to the processing completion status value), continue to wait and retry until the re-determined actual status value is equal to the processing completion status value, or, the number of retries reaches a preset retry threshold (that is, the maximum number of retries, which can be dynamically set according to the situation to avoid infinite attempts and waste of resources) and no retries are made.

[0077] In an embodiment of the present invention, each sub-business in the business chain is processed independently. Before processing each sub-business, the processing status of the previous sub-business is checked, and combined with the sequential waiting and retry mechanism of the business coordinator, it can effectively ensure that messages are consumed in sequence, avoid data processing errors caused by disorderly consumption, optimize resource utilization, and improve the efficiency and reliability of business processes.

[0078] In order to improve the accuracy of determining the waiting time threshold, the service message processing method provided in the first embodiment of the present application includes: determining a basic waiting time and determining an arrangement number of a target sub-service on a target service chain; determining a waiting coefficient of the target sub-service, wherein the waiting coefficient is positively correlated with the arrangement number and is greater than 1; determining an initial waiting time based on the basic waiting time and the waiting coefficient; when the waiting time is greater than or equal to the maximum waiting time, using the maximum waiting time as the waiting time threshold of the target sub-service, or, when the initial waiting time is less than the maximum waiting time, using the initial waiting time as the waiting time threshold of the target sub-service.

[0079] In the embodiment of the present invention, considering that a business chain may contain multiple sub-businesses and each sub-business is executed sequentially, if the time when the producer triggers each sub-business is almost the same, the consumer end of each sub-business may receive these business messages with a very small time difference. Therefore, if the consumer end of each sub-business still waits for the same time and retries the same number of times, the sub-business ranked later is likely to mistakenly believe that the previous sub-business processing is abnormal simply because the waiting time is insufficient, thereby terminating the processing of the current business chain. Based on this, a sequential waiting and retrying mechanism is proposed, which can avoid business processing failures caused by unreasonable design of the waiting and retrying mechanism.

[0080] In some examples, the step of determining the waiting coefficient of the target sub-service may include: determining an exponential function with a preset base, wherein the preset base is greater than 1, and using the arrangement number as the exponent of the exponential function to determine the waiting coefficient of the target sub-service.

[0081] In some examples, based on the basic waiting time and the waiting coefficient, the step of determining the initial waiting time may include: taking the product of the basic waiting time and the waiting coefficient as the initial waiting time, or taking the sum of the basic waiting time and the waiting coefficient as the initial waiting time.

[0082] In this embodiment, since the waiting coefficient is positively correlated with the arrangement number and is greater than 1, when the arrangement number of the target sub-service continues to increase, the waiting coefficient increases accordingly, so that the waiting time set for the target sub-service will become longer relative to the waiting time of its previous sub-service, thereby avoiding the situation where a sub-service with a relatively large arrangement number (i.e., a sub-service with a lower ranking) may not be processed simply because of insufficient waiting time.

[0083] In some other examples, determining the initial waiting time based on the basic waiting time and the waiting coefficient may include:

[0084] Based on the arrangement number, a delay range is determined, and a random value is selected from the delay range as the delay duration of the target sub-service; based on the basic waiting duration, the waiting coefficient and the delay duration, an initial waiting duration is determined.

[0085] In the embodiment of the present invention, the basic waiting time may be determined as the minimum waiting time, such as 1 second. In addition, the arrangement number of the target sub-service on the target service chain may be determined, so as to determine the waiting coefficient of the target sub-service according to the arrangement number. For example, for the sub-service with the arrangement number n, its waiting coefficient is 2. n-1 Then, a random delay is added before each sub-service starts to avoid all sub-services starting at the same time. That is, the delay range is determined according to the arrangement number, and a random value is selected from the delay range as the delay duration of the target sub-service. For example, for the nth service, a random value can be added to its waiting time, ranging from 0 to 2. n-1 Afterwards, the initial waiting time is calculated according to the basic waiting time, the waiting coefficient and the delay time. Here, the waiting coefficient may be positively correlated with the arrangement number of the current service, for example, the waiting coefficient is an exponential function with the arrangement number of the current service as an index.

[0086] In one example, the calculation formula of the initial waiting time T is: T = base × 2 n-1 +random(0,2 n-1 ), base is the basic waiting time, 2 n-1 is the waiting coefficient, random(0,2 n-1 ) is the delay duration.

[0087] In an embodiment of the present invention, since the waiting time threshold is set to exponential growth, in order to avoid excessively long waiting time, it is necessary to set a maximum waiting time (such as 60 seconds). If the calculated waiting time is greater than or equal to the maximum waiting time, the maximum waiting time is used as the waiting time threshold of the target sub-service; if the initial waiting time is less than the maximum waiting time, the initial waiting time is directly used as the waiting time threshold of the target sub-service. In this way, long waiting can be avoided and the processing efficiency of the service can be improved.

[0088] In some optional embodiments, due to the rapid exponential growth, it is necessary to ensure that the number of sub-services in each service chain is within a reasonable range. On the one hand, it can avoid excessive total waiting time. On the other hand, if there are many sub-services and the waiting time quickly reaches the maximum waiting time, the waiting time of many sub-services will be set to the maximum waiting time. If multiple sub-services are set to the maximum waiting time, they are fixed and the same waiting time will still cause the problem of misjudging service abnormality due to insufficient waiting time. Therefore, it is necessary to limit the number of sub-services contained in each service chain.

[0089] In this embodiment, after determining the maximum waiting time and the basic waiting time base, the formula: maximum waiting time = base × 2 n-1 , and inversely deduce the number n of sub-services. In this way, it can effectively avoid that the waiting time of many sub-services will be set to the maximum waiting time.

[0090] In order to accurately determine the first sub-business on the business chain, in the business message processing method provided in Example 1 of the present application, when the processing completion status value of the target sub-business recorded in the business relationship table is equal to the initial value, it is determined that the target sub-business is the first sub-business on the target business chain; or, when the previous sub-business identifier of the target sub-business recorded in the business relationship table is an empty identifier, it is determined that the target sub-business is the first sub-business on the target business chain.

[0091] In an embodiment of the present invention, the processing completion status value of the first sub-business on the target business chain can be determined according to the business relationship table associated with the target business chain identifier, and the processing completion status value is used as the initial value, and then it is determined whether the processing completion status value of the current sub-business (i.e., the target sub-business) is the initial value. If it is the initial value, the current sub-business is considered to be the first sub-business; or, the previous sub-business identifier of the current sub-business is obtained from the business relationship table associated with the target business chain identifier, and it is determined whether the previous sub-business of the current sub-business is null. If it is null, the current sub-business is the first sub-business and can be processed directly. After the processing is completed, the actual status value of the corresponding sub-business is updated to the business processing status table. If there is an exception during the processing, the actual status value of the current sub-business is updated to -1, otherwise it is updated to its processing completion status value.

[0092] In order to accurately determine whether the business chain is in a normal state, in the business message processing method provided in Example 1 of the present application, before querying the actual status value of the actual processing status of the previous sub-business of the target sub-business in the business processing status table corresponding to the target business chain identifier, it is determined whether the target business chain is in a normal state based on the actual status values ​​of all sub-businesses located before the target sub-business on the target business chain recorded in the business processing status table, so that when the target business chain is in a normal state, the actual status value of the actual processing status of the previous sub-business of the target sub-business can be queried.

[0093] Here, based on the actual status values ​​of all sub-businesses located before the target sub-business on the target business chain recorded in the business processing status table, judging whether the target business chain is in a normal state may include: when any actual status value is an abnormal status value, determining that the target business chain is in an abnormal state; when all actual status values ​​are not abnormal status values, determining that the target business chain is in a normal state.

[0094] In an embodiment of the present invention, before querying the actual status value of the actual processing status of the previous sub-business of the target sub-business, it is also necessary to determine whether the target business chain is in a normal state, specifically: the actual status values ​​of all sub-businesses located before the target sub-business on the target business chain can be obtained from the business processing status table. If any actual status value is an abnormal processing status value (that is, an abnormal status value, such as -1), it is determined that the target business chain is in an abnormal state; if all actual status values ​​are not abnormal processing status values ​​(that is, processing completion status values ​​or unprocessed status values), it can be determined that the target business chain is in a normal state.

[0095] In the embodiment of the present invention, if the service chain is in a normal state, it means that the sub-services on the service chain can be processed normally; if the service chain is in an abnormal state, the service chain will not be processed, and the sub-service in the abnormal state needs to be adjusted, and the processing will continue after the abnormal state disappears. In this way, the abnormality of the service chain can be discovered in time to avoid the inability to complete the processing of the service due to the abnormality of a sub-service.

[0096] In order to accurately record the actual status value of the sub-business, in the business message processing method provided in Example 1 of the present application, after processing the target business message, when the processing result indicates that the processing is completed, the processing completion status value preset for the target sub-business in the business relationship table is used as the actual status value of the target sub-business, and is recorded in the business processing status table; or, when the processing result indicates that the processing is abnormal, the actual status value of the target sub-business in the business processing status table is recorded as the abnormal status value.

[0097] In an embodiment of the present invention, after each processing of a business message, the status value of the corresponding sub-business in the business processing status table can be updated in real time according to the processing result. For example, if after processing the target business message, the processing result indicates that the processing is completed, it is necessary to determine the processing completion status value of the target sub-business from the business relationship table associated with the target business chain identifier, and update the actual status value of the target sub-business in the business processing status table to the same value as the processing completion status value (that is, if the processing is successful, the status value of the corresponding sub-business in the business processing status table is updated to the corresponding processing completion status value). If the processing result indicates that the processing is abnormal, it is necessary to update the actual status value of the target sub-business in the business processing status table to an abnormal status value (such as -1). In this way, it is possible to ensure that the status values ​​of all sub-businesses in the business processing status table are updated in real time, which is convenient for subsequent accurate judgment of whether the business information of the sub-business can be processed, thereby ensuring the sequential processing of business messages.

[0098] Figure 5 is a flow chart of an optional method for processing a service message according to an embodiment of the present invention. Figure 5As shown, after receiving the message, the business topic can start consuming the message. It can query Table 1 (i.e., the business relationship table) according to the current business name to determine whether the previous business of the current business exists. If not, it indicates that the current business is the first business on the current business chain, and the current business message can be processed directly; if yes, query whether there is an exception in the current business chain. If there is an exception, directly end the processing of the business chain; if there is no exception, obtain the name and value of the previous business, query Table 2 (i.e., the business processing status record table) according to the name of the previous business, and determine whether the value of the previous business is the same as the value of the business in Table 1. If not, wait for a period of time, retry, and determine whether the number of retries is less than or equal to the maximum number of retries. If yes, re-obtain the name and value of the previous business, otherwise, end directly. If the value of the previous business is the same as the value of the business in Table 1, process the current business message, and update Table 2 after the processing is completed.

[0099] The following uses the device registration process as an example to illustrate the business.

[0100] Assume that the services of the device registration process include: sending device information to the server (service 1) and sending device online information to the server (service 2).

[0101] In this embodiment, if there is a network delay, the interval between the producer producing messages for service 1 and service 2 is relatively short, and the consumers corresponding to service 1 and service 2 may receive messages for service 1 and service 2 at the same time. In this case, service 1 and service 2, which should have been processed sequentially, are processed simultaneously; or the consumer of service 2 receives the message of service 2 first, and the consumer of service 1 receives the message of service 1 later, so service 2 will be processed first, and then service 1. The processing order of service 1 and service 2 is incorrect, the overall service becomes chaotic, and ultimately the expected results cannot be obtained. In addition, since the consumption processing speeds of consumers of different services may be different, if the message of service 1 is received first, consumer 1 is processing it, but the processing is not completed; consumer 2 receives the message of service 2 and also starts processing it. Since service 2 depends on service 1, if service 1 is not processed completely, directly processing service 2 will fail or data errors will occur.

[0102] Therefore, in order to ensure the sequential processing of the device registration process. Specifically, in the device registration process, it is necessary to first send the device information to the server, the server stores the device information, and then send the device online information to the server, and the server updates the device status to online. If the device online message is processed first, the update will fail because there is no device-related message yet. When the device information is received for storage, the device status cannot be updated to online because the online message will only be sent once. However, by applying the processing method of the business message in this embodiment, if the device online message is received first, the waiting retry mechanism can be used to ensure that the device status is updated to online after the device information storage is completed.

[0103] In the embodiment of the present invention, the processing order of the business is sorted out through the established business relationship, and the disordered messages can be coordinated and processed in the established order, which not only ensures the integrity of the business chain, but also avoids errors in the overall business caused by short-term disorder.

[0104] The following is a detailed description in conjunction with another embodiment.

[0105] Embodiment 2

[0106] A service message processing device provided in this embodiment includes multiple implementation units, each implementation unit corresponds to each implementation step in the above-mentioned embodiment 1.

[0107] Figure 6 is a schematic diagram of an optional service message processing device according to an embodiment of the present invention, such as Figure 6 As shown, the processing device may include: a first judgment unit 60, a first query unit 61, a second query unit 62, and a processing unit 63.

[0108] The first judgment unit 60 is used to judge whether the target sub-service is the first sub-service on the target service chain when receiving the target service message of the target sub-service, wherein the target service message carries the target service chain identifier;

[0109] The first query unit 61 is used to query the actual status value representing the actual processing status of the previous sub-business of the target sub-business in the business processing status table corresponding to the target business chain identifier when the target sub-business is not the first sub-business on the target business chain;

[0110] The second query unit 62 is used to query the processing completion status value preset for the previous sub-business of the target sub-business in the business relationship table associated with the target business chain identifier;

[0111] The processing unit 63 is used to process the target service message when the actual status value of the previous sub-service is the same as the preset processing completion status value.

[0112] The above-mentioned processing device can determine whether the target sub-business is the first sub-business on the target business chain through the first judgment unit 60 when receiving the target business message of the target sub-business; when the target sub-business is not the first sub-business on the target business chain, query the actual status value used to characterize the actual processing status of the previous sub-business of the target sub-business in the business processing status table corresponding to the target business chain identifier through the first query unit 61; query the processing completion status value preset for the previous sub-business of the target sub-business in the business relationship table associated with the target business chain identifier through the second query unit 62; and process the target business message through the processing unit 63 when the actual status value of the previous sub-business is the same as the preset processing completion status value, thereby solving the technical problem in the related technology that it is impossible to ensure that each business message is processed in the business order, resulting in business errors.

[0113] Optionally, the processing device also includes: a first determination unit, used to determine the business chain of each business, wherein each business chain contains N sub-businesses, and N is a positive integer; a first construction unit, used to construct, for each business chain, a business relationship table associated with the business chain identifier of the business chain, using the identifier of the nth sub-business on the business chain as the primary key, and using the identifier of the n-1th sub-business and the processing completion status value preset for the nth sub-business as the key value of the primary key, wherein n is an integer greater than 1 and less than or equal to N.

[0114] Optionally, the target sub-business is the nth sub-business on the target business chain, and the second query unit includes: a first query module, used to use the identifier of the nth sub-business as the primary key to query in the business relationship table, and after querying the identifier of the n-1th sub-business, use the identifier of the n-1th business as the primary key to query the preset processing completion status value of the n-1th sub-business in the business relationship table.

[0115] Optionally, the processing device also includes: a second determination unit, which is used to query the processing completion status value preset for the previous sub-business of the target sub-business in the business relationship table associated with the target business chain identifier, and when the actual status value is different from the processing completion status value, suspend processing the target business message and determine the waiting time threshold of the target sub-business; a third determination unit, which is used to re-determine the latest actual status value corresponding to the previous sub-business of the target sub-business from the business processing status table when the suspension time reaches the waiting time threshold; and a fourth determination unit, which is used to continue to suspend the waiting time threshold and re-determine the actual status value when the latest actual status value is different from the processing completion status value, until the re-determined actual status value is equal to the processing completion status value, or the number of times the actual status value is re-determined reaches a preset retry threshold.

[0116] Optionally, the second determination unit includes: a first determination module, used to determine the basic waiting time and determine the arrangement number of the target sub-business on the target business chain; a second determination module, used to determine the waiting coefficient of the target sub-business, wherein the waiting coefficient is positively correlated with the arrangement number and is greater than 1; a third determination module, used to determine the initial waiting time based on the basic waiting time and the waiting coefficient; a first acting module, used to use the maximum waiting time as the waiting time threshold of the target sub-business when the waiting time is greater than or equal to the maximum waiting time, or, when the initial waiting time is less than the maximum waiting time, use the initial waiting time as the waiting time threshold of the target sub-business.

[0117] Optionally, the first judgment unit includes: a fourth determination module, used to determine that the target sub-business is the first sub-business on the target business chain when the processing completion status value of the target sub-business recorded in the business relationship table is equal to the initial value; a fifth determination module, used to determine that the target sub-business is the first sub-business on the target business chain when the previous sub-business identifier of the target sub-business recorded in the business relationship table is an empty identifier.

[0118] Optionally, the processing device also includes: a second judgment unit, which is used to judge whether the target business chain is in a normal state based on the actual status values ​​of all sub-businesses on the target business chain located before the target sub-business recorded in the business processing status table before querying the actual status value of the actual processing status of the previous sub-business of the target sub-business in the business processing status table corresponding to the target business chain identifier, so as to query the actual status value of the actual processing status of the previous sub-business of the target sub-business when the target business chain is in a normal state.

[0119] Optionally, the processing device also includes: a first recording unit, which is used to, after processing the target business message, when the processing result indicates that the processing is completed, use the processing completion status value preset for the target sub-business in the business relationship table as the actual status value of the target sub-business, and record it in the business processing status table; a second recording unit, which is used to, when the processing result indicates that the processing is abnormal, record the actual status value of the target sub-business in the business processing status table as an abnormal status value.

[0120] The above-mentioned processing device may also include a processor and a memory. The above-mentioned first judgment unit 60, first query unit 61, second query unit 62, processing unit 63, etc. are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize corresponding functions.

[0121] The processor includes a kernel, which retrieves the corresponding program unit from the memory. One or more kernels can be set to process the target service message by adjusting kernel parameters when the actual status value of the previous sub-service is the same as the preset processing completion status value.

[0122] The above-mentioned memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash memory (fl ash RAM), and the memory includes at least one storage chip.

[0123] The present invention also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that is initialized with the following method steps: when a target business message of a target sub-business is received, determining whether the target sub-business is the first sub-business on the target business chain; when the target sub-business is not the first sub-business on the target business chain, querying the actual status value used to characterize the actual processing status of the previous sub-business of the target sub-business in the business processing status table corresponding to the target business chain identifier; querying the processing completion status value preset for the previous sub-business of the target sub-business in the business relationship table associated with the target business chain identifier; and processing the target business message when the actual status value of the previous sub-business is the same as the preset processing completion status value.

[0124] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, comprising one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by one or more processors, the one or more processors implement the above-mentioned method for processing business messages.

[0125] Figure 7 1 is a hardware structure block diagram of an electronic device for a method for processing a service message according to an embodiment of the present invention. Figure 7 As shown, the electronic device may include one or more processors (e.g., Figure 7 The processor 702a, processor 702b, ..., processor 702n, etc., which may include but are not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 704 for storing data. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a keyboard, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 7 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 7More or fewer components as shown, or with Figure 7 Different configurations are shown.

[0126] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0127] The embodiments or examples of the present disclosure are not exhaustive, but are only illustrative of some embodiments or examples, and are not intended to be specific limitations on the scope of protection of the present disclosure. In the absence of contradiction, each step in a certain embodiment or example can be implemented as an independent example, and the steps can be combined arbitrarily. For example, the scheme after removing some steps in a certain embodiment or example can also be implemented as an independent example, and the order of the steps in a certain embodiment or example can be arbitrarily exchanged. In addition, the optional methods or optional examples in a certain embodiment or example can be combined arbitrarily; in addition, the various embodiments or examples can be combined arbitrarily, for example, some or all steps of different embodiments or examples can be combined arbitrarily, and a certain embodiment or example can be combined arbitrarily with the optional methods or optional examples of other embodiments or examples.

[0128] In the above embodiments of the present invention, 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.

[0129] In the several embodiments provided by the present invention, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic, for example, the division of units can be a logical function division, and there can be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0130] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed over multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0131] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0132] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.

[0133] The above are only preferred embodiments of the present invention. It should be pointed out that, for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A method for processing a business message, characterized in that: include: Upon receiving a target service message of a target sub-service, determining whether the target sub-service is the first sub-service on a target service chain, wherein the target service message carries a target service chain identifier; In the case where the target sub-service is not the first sub-service on the target service chain, querying, in the service processing status table corresponding to the target service chain identifier, an actual status value used to characterize the actual processing status of a previous sub-service of the target sub-service; In the service relationship table associated with the target service chain identifier, querying the processing completion status value preset for the previous sub-service of the target sub-service; When the actual status value of the previous sub-service is the same as the preset processing completion status value, the target service message is processed.

2. The processing method according to claim 1, characterized in that: The processing method also includes: Determine a service chain for each service, wherein each service chain includes N sub-services, where N is a positive integer; For each business chain, the identifier of the nth sub-business on the business chain is used as the primary key, the identifier of the n-1th sub-business and the processing completion status value preset for the nth sub-business are used as the key value of the primary key, and a business relationship table associated with the business chain identifier of the business chain is constructed, where n is an integer greater than 1 and less than or equal to N.

3. The processing method according to claim 2, characterized in that: The target sub-business is the nth sub-business on the target business chain, and in the business relationship table associated with the target business chain identifier, querying the processing completion status value preset for the previous sub-business of the target sub-business includes: Using the identifier of the nth sub-business as the primary key, query the business relationship table, and after querying the identifier of the n-1th sub-business, use the identifier of the n-1th business as the primary key to query the preset processing completion status value of the n-1th sub-business in the business relationship table.

4. The processing method according to claim 1, characterized in that: After searching the service relationship table associated with the target service chain identifier for the processing completion status value preset for the previous sub-service of the target sub-service, the method further includes: When the actual status value is different from the processing completion status value, suspending the processing of the target service message and determining a waiting time threshold of the target sub-service; When the pause duration reaches the waiting duration threshold, re-determining the latest actual status value corresponding to the previous sub-service of the target sub-service from the service processing status table; When the latest actual status value is different from the processing completion status value, the actual status value is redetermined after continuing to pause the waiting time threshold until the redetermined actual status value is equal to the processing completion status value, or the number of times the actual status value is redetermined reaches a preset retry threshold.

5. The processing method according to claim 4, characterized in that: The step of determining the waiting time threshold of the target sub-service includes: Determine a basic waiting time, and determine an arrangement number of the target sub-service on the target service chain; Determine a waiting coefficient of the target sub-service, wherein the waiting coefficient is positively correlated with the arrangement number and is greater than 1; Determining an initial waiting time based on the basic waiting time and the waiting coefficient; In the case where the initial waiting time is greater than or equal to the maximum waiting time, the maximum waiting time is used as the waiting time threshold of the target sub-service, or, In the case where the initial waiting time is less than the maximum waiting time, the initial waiting time is used as the waiting time threshold of the target sub-service.

6. The processing method according to any one of claims 1 to 5, characterized in that: Determining whether the target sub-service is the first sub-service on the target service chain includes: In the case where the processing completion status value of the target sub-service recorded in the service relationship table is equal to the initial value, determining that the target sub-service is the first sub-service on the target service chain; or, In the case that the previous sub-service identifier of the target sub-service recorded in the service relationship table is an empty identifier, it is determined that the target sub-service is the first sub-service on the target service chain.

7. The processing method according to any one of claims 1 to 5, characterized in that: Before searching the service processing status table corresponding to the target service chain identifier for an actual status value representing an actual processing status of a previous sub-service of the target sub-service, the processing method further includes: Based on the actual status values ​​of all sub-businesses located before the target sub-business on the target business chain recorded in the business processing status table, determine whether the target business chain is in a normal state, so as to query the actual status value of the actual processing status of the previous sub-business of the target sub-business when the target business chain is in the normal state.

8. The processing method according to any one of claims 1 to 5, characterized in that: After processing the target service message, the method further includes: If the processing result indicates that the processing is completed, the processing completion status value preset for the target sub-business in the business relationship table is used as the actual status value of the target sub-business and recorded in the business processing status table; or When the processing result indicates that the processing is abnormal, the actual status value of the target sub-service in the service processing status table is recorded as the abnormal status value.

9. A device for processing business messages, characterized in that: include: A first judgment unit is used to judge whether the target sub-service is the first sub-service on the target service chain when receiving a target service message of the target sub-service, wherein the target service message carries a target service chain identifier; A first query unit is used to query, in a business processing state table corresponding to the target business chain identifier, an actual state value used to characterize an actual processing state of a previous sub-business of the target sub-business when the target sub-business is not the first sub-business on the target business chain; A second query unit, configured to query a processing completion status value preset for the previous sub-business of the target sub-business in a business relationship table associated with the target business chain identifier; A processing unit is used to process the target service message when the actual status value of the previous sub-service is the same as the preset processing completion status value.

10. An electronic device, characterized in that: It includes one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the service message processing method described in any one of claims 1 to 8.