A message processing method and apparatus

By dynamically adjusting the number and configuration of sub-message queues, the problems of message queue backlog and resource waste during traffic changes are solved, enabling orderly and rapid consumption and efficient delivery.

CN117271164BActive Publication Date: 2026-11-06CHINA CONSTRUCTION BANK +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311263908.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-27
Publication Date
2026-11-06
Estimated Expiration
2043-09-27

AI Technical Summary

Technical Problem

In existing technologies, message queues are prone to message accumulation when the message traffic is high, and serious resource waste when the traffic is low, which cannot effectively solve this problem.

Method used

By dynamically adjusting the number of sub-message queues and redefining the sub-queue configuration based on the message's business identifier and allocation record, we can ensure that messages are consumed in an orderly and rapid manner, avoid message backlog, and optimize resource utilization.

Benefits of technology

It avoids message backlog and resource waste when message traffic changes, thus improving the accuracy and efficiency of message delivery.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117271164B_ABST
    Figure CN117271164B_ABST
Patent Text Reader

Abstract

The message processing method and device provided by the embodiment of the present application are applied to the technical field of data processing, and include the following steps: when it is determined that there is a first message exception in any sub-message queue, obtaining an allocation record of the first message from a target database based on a service identifier of the first message; the target database records the allocation record of any message when the message is taken out from a total message queue and allocated to a sub-message queue; obtaining a second sub-queue configuration according to a first sub-queue configuration indicated by the allocation record of the first message; the second sub-queue configuration is a previous sub-queue configuration corresponding to the first sub-queue configuration; any sub-queue configuration is used to indicate the number of effective sub-queues of a message processing system during message allocation; and the sub-message queue corresponding to the first message is re-determined and the first sub-queue configuration in the allocation record of the first message is updated to the second sub-queue configuration according to the second sub-queue configuration and the service identifier of the first message.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and in particular to a message processing method and apparatus. Background Technology

[0002] Message passing is a common communication method, often employing message middleware solutions. Message middleware is typically used for cross-system data transfer, data distribution, and big data analysis and transmission. A key component of message middleware solutions is the message queue, a container that stores messages during transmission. The primary purpose of a message queue is to provide routing and ensure message delivery. Messages in a message queue are ordered, and their consumption must maintain this order.

[0003] Currently, messages are typically forwarded from a main message queue to multiple sub-queues, with each sub-queue having a consumer that processes the messages. However, the number of sub-queues is limited, and this can lead to message backlog if the message traffic is high.

[0004] How to avoid message backlog is a technical problem that urgently needs to be solved. Summary of the Invention

[0005] This invention provides a message processing method and apparatus to solve the problem of message backlog in the prior art.

[0006] In a first aspect, the present invention provides a message processing method applicable to a message processing system including a main message queue, multiple sub-message queues, and a target database, comprising: when it is determined that a first message exception exists in any sub-message queue, obtaining the allocation record of the first message from the target database based on the service identifier of the first message; the target database records the allocation record when any message is retrieved from the main message queue and allocated to a sub-message queue; obtaining a second sub-queue configuration according to the first sub-queue configuration indicated by the allocation record of the first message; the second sub-queue configuration is the preceding sub-queue configuration corresponding to the first sub-queue configuration; any sub-queue configuration is used to indicate the number of valid sub-queues in the message processing system during message allocation; and re-determining the sub-message queue corresponding to the first message and updating the first sub-queue configuration in the allocation record of the first message to the second sub-queue configuration according to the second sub-queue configuration and the service identifier of the first message.

[0007] In the above technical solution, the message processing system includes a main message queue and multiple sub-message queues. By adjusting the number of sub-message queues, resource waste is avoided when message traffic is low, and message backlog is prevented when message traffic is high. Since adjusting the number of sub-message queues can cause abnormal consumption of the first message, this solution finds the configuration of the preceding sub-queue for the first message based on its first sub-queue configuration. This allows the first message to be consumed in an orderly and rapid manner by finding the corresponding sub-message queue according to the preceding sub-queue configuration.

[0008] Optionally, determining that a first message exception exists in any sub-message queue includes: determining that a first message exception exists when a consumer of any sub-message queue obtains the first message but has not consumed the second message; the second message is the preceding message of the first message.

[0009] In the above technical solution, by identifying message anomalies, it is easier to re-deliver the message to the queue, thereby improving the accuracy of message delivery.

[0010] Optionally, it also includes: for any third message in the total message queue, determining the sub-message queue corresponding to the third message based on the service identifier of the third message and the configuration of the third sub-queue in a valid state in the message processing system, and storing the allocation record of the third message in the target database; the allocation record of any message includes a message identifier, a message content with a service identifier and a sub-queue configuration identifier corresponding to the message; and distributing the third message to the sub-message queue corresponding to the third message.

[0011] In the above technical solution, by storing the allocation record table of the third message in the target database, the data leakage of the third message is avoided and the overhead of the sub-queue and network is reduced.

[0012] Optionally, it also includes: dynamically adjusting the sub-message queues in the message processing system based on the number of messages in the total message queue; updating the adjusted sub-queue configurations to the dynamic configuration table; wherein, any sub-queue configuration in the dynamic configuration table includes a configuration identifier that is in effect, a predecessor configuration identifier that is ineffective, an effective identifier of the configuration identifier that is in effect, and the number of valid sub-queues.

[0013] In the above technical solution, if the number of ordered messages is large during a certain period, the dynamic configuration module needs to increase the number of current sub-message queues to avoid message backlog. Conversely, if the number of ordered messages is small during another period, the dynamic configuration module needs to decrease the number of current sub-message queues to avoid resource waste.

[0014] Optionally, the second sub-queue configuration can be obtained according to the first sub-queue configuration indicated by the allocation record of the first message, including: determining the first sub-queue configuration corresponding to the first message from the dynamic configuration table according to the configuration identifier in the allocation record of the first message; and obtaining the second sub-queue configuration from the dynamic configuration table according to the preceding configuration identifier in the first sub-queue configuration.

[0015] In the above technical solution, the configuration of the second sub-queue is obtained from the dynamic configuration table by using the configuration identifier in the allocation record of the first message, and then the adjusted number of sub-message queues is determined according to the number of sub-queues corresponding to the configuration of the second sub-queue.

[0016] Optionally, based on the number of messages in the total message queue, the sub-message queues in the message processing system are dynamically adjusted, including: increasing the number of sub-message queues in the message processing system when the number of messages in the total message queue is greater than a first threshold; decreasing the number of sub-message queues in the message processing system when the number of messages in the total message queue is less than a second threshold, and closing the sub-message queues after all messages in the sub-message queues to be closed have been consumed; wherein the first threshold is greater than the second threshold.

[0017] In the above technical solution, the number of sub-message queues in the message processing system is dynamically adjusted according to the number of messages in the sub-message queues, thereby avoiding message backlog and resource waste.

[0018] Secondly, embodiments of the present invention provide a message processing apparatus applicable to a message processing system including a main message queue, multiple sub-message queues, and a target database, comprising: an acquisition unit, configured to, when it is determined that a first message exception exists in any sub-message queue, acquire an allocation record of the first message from the target database based on the service identifier of the first message; the target database records allocation records when any message is retrieved from the main message queue and allocated to a sub-message queue; and a processing unit, configured to, according to a first sub-queue configuration indicated by the allocation record of the first message, acquire a second sub-queue configuration; the second sub-queue configuration is the preceding sub-queue configuration corresponding to the first sub-queue configuration; any sub-queue configuration is used to indicate the number of valid sub-queues in the message processing system during message allocation; and, according to the second sub-queue configuration and the service identifier of the first message, re-determine the sub-message queue corresponding to the first message and update the first sub-queue configuration in the allocation record of the first message to the second sub-queue configuration.

[0019] Optionally, the acquisition unit is specifically used to: determine that there is an anomaly in the first message when a consumer of any sub-message queue acquires the first message but has not consumed the second message; the second message is the preceding message of the first message.

[0020] Optionally, the processing unit is further configured to: for any third message in the total message queue, determine the sub-message queue corresponding to the third message based on the service identifier of the third message and the configuration of the third sub-queue in a valid state in the message processing system, and store the allocation record of the third message in the target database; the allocation record of any message includes a message identifier, a message content with a service identifier and a sub-queue configuration identifier corresponding to the message; and distribute the third message to the sub-message queue corresponding to the third message.

[0021] Optionally, the processing unit is also used to: dynamically adjust the sub-message queues in the message processing system based on the number of messages in the total message queue; update the adjusted sub-queue configuration to the dynamic configuration table; wherein, any sub-queue configuration in the dynamic configuration table includes a configuration identifier that is in effect, a predecessor configuration identifier that is in failure, an effective identifier of the configuration identifier that is in effect, and the number of valid sub-queues.

[0022] Optionally, the processing unit is specifically used to: determine the configuration of the first sub-queue corresponding to the first message from the dynamic configuration table based on the configuration identifier in the allocation record of the first message; and obtain the configuration of the second sub-queue from the dynamic configuration table based on the preceding configuration identifier in the configuration of the first sub-queue.

[0023] Optionally, the processing unit is specifically used to: increase the number of sub-message queues in the message processing system when the number of messages in the total message queue is greater than a first threshold; and decrease the number of sub-message queues in the message processing system when the number of messages in the total message queue is less than a second threshold, and close the sub-message queues after all messages in the sub-message queues to be closed have been consumed; wherein the first threshold is greater than the second threshold.

[0024] Thirdly, embodiments of this application provide a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes any of the message processing methods described in the first aspect.

[0025] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program executable by a computer device, which, when run on the computer device, causes the computer device to execute any of the message processing methods described in the first aspect.

[0026] Fifthly, embodiments of this application provide a computer program product, which includes a computer program stored on a computer-readable storage medium. The computer program includes program instructions, which, when executed by a computer device, cause the computer device to perform any of the message processing methods described in the first aspect. Attached Figure Description

[0027] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0028] Figure 1 This is a schematic diagram of a typical message queue system provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of the structure of a message queue system provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of another message queue system provided in an embodiment of the present invention; Figure 4 A flowchart of a message processing method provided in an embodiment of the present invention; Figure 5 This is a schematic diagram of the structure of a message processing device provided in an embodiment of the present invention; Figure 6 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present invention. Detailed Implementation

[0029] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.

[0030] It should be noted that the acquisition, storage, use, and processing of data in the technical solution of this application all comply with the relevant provisions of national laws and regulations.

[0031] like Figure 1The diagram illustrates a typical message queue system according to an embodiment of the present invention. Message queue systems (also known as message middleware) are widely used in various internet companies. As a message buffering mechanism, it can effectively reduce server load. Message queue system 100 includes a producer 110, a message queue 120, and a consumer 130. The producer 110 is responsible for sending messages to the message queue. The consumer 130 is responsible for retrieving messages from the message queue. The message queue 120 is used as middleware for storing messages. Typically, the middleware of a message queue system includes multiple message queues, which are used to store messages sent from the producer. Message queues are usually set up on at least one server, and in practice, multiple servers are commonly used. In one possible scenario, since the messages in the message queue are ordered, the original order must be maintained when consuming these ordered messages; otherwise, the business scenario cannot be met. However, if multiple consumers consume messages simultaneously, the message consumption order cannot be guaranteed.

[0032] like Figure 2 The diagram illustrates the structure of a message queue system according to an embodiment of the present invention. The message queue system 200 includes a producer 210, a message queue 220, and a consumer 230. The producer 210 sends ordered messages to the message queue 220, and then only one consumer 230 consumes the messages in the message queue 220, ensuring that the message consumption order remains unchanged. However, if the producer 210 produces messages quickly, it can easily cause message backlog in the message queue.

[0033] like Figure 3 The diagram illustrates the structure of another message queue system provided in this embodiment of the invention. The message queue system 300 includes a producer 310, a consumer 320, and a message queue 330. The message queue 330 includes a main message queue and two sub-message queues: main message queue 331, sub-message queue 332, and sub-message queue 333. Each sub-message queue corresponds to one consumer. In most cases, it is not necessary to guarantee that all messages are consumed in a strictly ordered manner; it is only necessary to guarantee the consumption order of related messages under an order. For example, when the last node processes order A, it is only necessary to ensure that the second-to-last node has processed order A. It is not necessary to consider whether the preceding nodes have processed order B, because the state and data modifications between order A and order B are not interdependent. Therefore, messages can be grouped to ensure that messages for the same order are delivered to the same queue in order. Figure 3In the system architecture, producer 310 sends ordered messages to the main message queue 331, and then the main message queue 331 forwards the messages of different orders to the corresponding sub-message queues 332 and 333.

[0034] In this way, adding multiple sub-queues can alleviate message backlog to some extent. However, forwarding message content between the main message queue and the corresponding sub-queues carries the risk of message loss. Furthermore, since the number of sub-queues in this message queue system is pre-set and fixed, it cannot effectively solve the message backlog problem. For example, with N sub-queues, if the number of ordered messages is very large, forwarding messages to sub-queues can only reduce the backlog to 1 / N, but if the number of messages is still very large, it cannot effectively solve the message backlog problem. As another example, with N sub-queues, since the number of messages is dynamic—there may be periods with a large number of messages and periods with a small number—using more sub-queues to consume messages during periods of low message volume is wasteful of resources.

[0035] In summary, the embodiments of the present invention provide a message processing method to solve the problem of message backlog.

[0036] like Figure 4 The diagram shows a flowchart of a message processing method provided in an embodiment of the present invention. The method includes the following steps: Step 401: When it is determined that there is a first message exception in any sub-message queue, the allocation record of the first message is obtained from the target database based on the service identifier of the first message.

[0037] In one possible scenario of this invention, due to the large number of messages, the number of sub-message queues needs to be adjusted. After adjusting the number of sub-message queues, the first message may become abnormal. When a consumer is consuming the first message but has not consumed the second message, where the second message is a preceding message to the first message, the first message is determined to be abnormal. Therefore, it is first necessary to retrieve the allocation record of the first message from the target database based on the business identifier of the first message. The target database records the allocation records when any message is retrieved from the main message queue and allocated to a sub-message queue.

[0038] Step 402: Obtain the second sub-queue configuration according to the first sub-queue configuration indicated by the allocation record of the first message; the second sub-queue configuration is the preceding sub-queue configuration corresponding to the first sub-queue configuration.

[0039] In this embodiment of the invention, a first sub-queue configuration is obtained from the target database based on the allocation record of the first message. Then, a second sub-queue configuration is obtained from the target database based on the first sub-queue configuration, wherein the second sub-queue configuration is the preceding sub-queue configuration corresponding to the first sub-queue configuration. Any sub-queue configuration is used to indicate the number of valid sub-queues in the message processing system during message allocation.

[0040] Step 403: Based on the second sub-queue configuration and the service identifier of the first message, redetermine the sub-message queue corresponding to the first message and update the first sub-queue configuration in the allocation record of the first message to the second sub-queue configuration.

[0041] In this embodiment of the invention, since the first message is abnormal because the number of sub-message queues has changed, in order to ensure that the first message can be consumed normally, the sub-message queue corresponding to the first message is determined based on the original number of sub-message queues, where the original number of sub-message queues is the second sub-queue configuration. Therefore, it is necessary to redetermine the sub-message queue corresponding to the first message based on the second sub-queue configuration and the service identifier of the first message, and update the first sub-queue configuration in the allocation record of the first message to the second sub-queue configuration.

[0042] As can be seen from steps 401 to 403 above, the message processing system includes a main message queue and multiple sub-message queues. By adjusting the number of sub-message queues, resource waste is avoided when message traffic is low, and message backlog is prevented when message traffic is high. Since adjusting the number of sub-message queues can cause abnormal consumption of the first message, this solution finds the configuration of the preceding sub-queue for the first message based on the configuration of the first sub-queue. This allows the first message to be consumed in an orderly and fast manner by finding the corresponding sub-message queue according to the configuration of the preceding sub-queue.

[0043] In this embodiment of the invention, the message processing system includes a main message queue, multiple sub-message queues, and a target database. The main message queue receives ordered messages sent from the producer end, and includes a message routing module and a dynamic configuration module. The message routing module is used to route messages in the main message queue. Specifically, the message routing module first obtains the configuration identifiers in an active state and the number of valid sub-queues from the dynamic configuration table in the target database. The dynamic configuration table can be found in Table 1.

[0044] Table 1 Dynamic Configuration Table

[0045] The dynamic configuration table includes the identifiers of configurations in an active state, the identifiers of their predecessors in an inactive state, the identifiers of the active configuration identifiers, and the number of valid sub-queues. For example, the identifier of the active configuration is A1, the identifier of its predecessor in an inactive state is A2, the identifier of the active configuration identifier is active, and the number of valid sub-queues is 3.

[0046] In this embodiment of the invention, the allocation record of the third message is stored in the message storage table of the target database according to the message routing module. The allocation record of any message includes a message identifier, a message content with a business identifier, and a sub-queue configuration identifier corresponding to the message. The message storage table can be found in Table 2.

[0047] Table 2 Message Storage Table

[0048] For example, the allocation record stored in the message storage table includes message identifier C1, message content ABC with business identifier, and sub-queue configuration identifier A1 corresponding to the message.

[0049] In this embodiment of the invention, to ensure ordered message consumption, messages under the same order need to be assigned to the same sub-queue for consumption. Messages under the same order all have the same business identifier. For example, order A includes messages 1, 2, and 3, and order B includes messages 4, 5, and 6. Messages 1, 2, and 3 all use business identifier 1, while messages 4, 5, and 6 all use business identifier 2.

[0050] Optionally, to ensure that messages under the same order are all assigned to the same sub-queue for consumption, for any third message in the total message queue, the corresponding sub-message queue is determined based on the third message's business identifier and the valid third sub-queue configuration in the message processing system. The third message is then distributed to this sub-message queue. Specifically, the hash value of the third message's business identifier is determined, and then the hash value is modulo the number of sub-queues corresponding to the third sub-queue configuration to determine the corresponding sub-message queue. The third message is then distributed to this sub-message queue. For example, if message A's business identifier is business identifier 1, and its hash value is 11, and the number of valid sub-queues in the message processing system is 3, then taking the modulo of 11 with 3 yields 2. Therefore, message A corresponds to the third sub-message queue, and message A is then distributed to this third sub-message queue.

[0051] In one possible scenario, since the number of ordered messages is dynamically changing, during a period when the number of ordered messages is high, the dynamic configuration module needs to increase the number of current sub-message queues to avoid message backlog. During another period when the number of ordered messages is low, the dynamic configuration module needs to decrease the number of current sub-message queues to avoid resource waste. When the total message queue receives more than a first threshold or less than a second threshold from the producer, the dynamic configuration module dynamically adjusts the sub-message queues in the message processing system, where the first threshold is greater than the second threshold. The adjusted sub-queue configuration is updated in the dynamic configuration table, where each sub-queue configuration in the dynamic configuration table includes a configuration identifier in an active state, a preceding configuration identifier in an inactive state, and the number of valid sub-queues. The configuration identifier in an active state is the current sub-queue configuration identifier. The preceding configuration identifier in an inactive state is the preceding sub-queue configuration identifier. The active identifier of the active configuration identifier is the active state of the current sub-queue configuration identifier. The number of valid sub-queues is the number of sub-queues corresponding to the current sub-queue configuration.

[0052] For example, if the total message queue receives more than a first threshold number of ordered messages from the producer, and the current number of sub-message queues is 3, the number of sub-message queues needs to be changed from 3 to 5. Specifically, the current sub-queue is configured as the first sub-queue configuration, the preceding sub-queue is configured as the second sub-queue configuration, and the number of sub-message queues corresponding to the first sub-queue configuration is 3. In the dynamic configuration table, the configuration identifier in the active state is the first sub-queue configuration identifier, and the preceding configuration identifier in the inactive state is the second sub-queue configuration identifier. The first sub-queue configuration identifier is A3, the second sub-queue configuration identifier is A4, and the active configuration identifier is active. The number of effective sub-queues is 3. The current dynamic configuration table can be found in Table 3.

[0053] Table 3 Dynamic Configuration Table

[0054] When the number of sub-message queues corresponding to the first sub-queue configuration needs to be adjusted from 3 to 5, the effective flag of the configuration identifier corresponding to the first sub-queue configuration must first be set to the inactive state. Then, a third sub-queue configuration identifier and the number of sub-message queues corresponding to the third sub-queue configuration are added to the dynamic configuration table. The configuration identifier corresponding to the third sub-queue configuration is set to the active state. The first sub-queue then becomes the predecessor sub-queue of the third sub-queue. In the dynamic configuration table, the configuration identifier in the active state is the third sub-queue configuration identifier, and the predecessor configuration identifier in the inactive state is the first sub-queue configuration identifier. Specifically, the first sub-queue configuration identifier is A3, the third sub-queue configuration identifier is A5, the effective flag of the active configuration identifier is active, and the number of active sub-queues is 5. The current dynamic configuration table can be found in Table 4.

[0055] Table 4 Dynamic Configuration Table

[0056] For another example, if the total message queue receives fewer ordered messages from the producer than the second threshold, the number of sub-message queues in the message processing system needs to be reduced, and all messages in the sub-message queues to be closed should be consumed before closure. If the current number of sub-message queues is 5, it needs to be changed to 3. Specifically, the current sub-queue configuration is the first sub-queue configuration, the preceding sub-queue configuration is the second sub-queue configuration, and the number of sub-message queues corresponding to the first sub-queue configuration is 5. In the dynamic configuration table, the configuration identifier in the active state is the first sub-queue configuration identifier, and the preceding configuration identifier in the inactive state is the second sub-queue configuration identifier. The first sub-queue configuration identifier is A3, the second sub-queue configuration identifier is A4, and the active configuration identifier is active. The number of effective sub-queues is 5. The current dynamic configuration table can be found in Table 5.

[0057] Table 5 Dynamic Configuration Table

[0058] When the number of sub-message queues corresponding to the first sub-queue configuration needs to be adjusted from 5 to 3, the effective flag of the configuration identifier corresponding to the first sub-queue configuration must first be set to the inactive state. Then, a third sub-queue configuration identifier and the number of sub-message queues corresponding to the third sub-queue configuration are added to the dynamic configuration table. The configuration identifier corresponding to the third sub-queue configuration is set to the active state. The first sub-queue then becomes the predecessor sub-queue of the third sub-queue. In the dynamic configuration table, the configuration identifier in the active state is the third sub-queue configuration identifier, and the predecessor configuration identifier in the inactive state is the first sub-queue configuration identifier. Specifically, the first sub-queue configuration identifier is A3, the third sub-queue configuration identifier is A5, the effective flag of the active configuration identifier is active, and the number of active sub-queues is 3. The current dynamic configuration table can be found in Table 6.

[0059] Table 6 Dynamic Configuration Table

[0060] Based on the same technical concept, embodiments of the present invention provide a schematic diagram of the structure of a message processing device, such as... Figure 5 As shown, the device 500, applicable to a message processing system including a main message queue, multiple sub-message queues, and a target database, includes: an acquisition unit 501, configured to acquire the allocation record of the first message from the target database based on the service identifier of the first message when it is determined that there is a first message exception in any sub-message queue; the target database records the allocation records when any message is taken from the main message queue and allocated to a sub-message queue; and a processing unit 502, configured to acquire a second sub-queue configuration according to the first sub-queue configuration indicated by the allocation record of the first message; the second sub-queue configuration is the preceding sub-queue configuration corresponding to the first sub-queue configuration; any sub-queue configuration is used to indicate the number of valid sub-queues in the message processing system during message allocation; and, based on the second sub-queue configuration and the service identifier of the first message, redetermine the sub-message queue corresponding to the first message and update the first sub-queue configuration in the allocation record of the first message to the second sub-queue configuration.

[0061] Optionally, the acquisition unit 501 is specifically used to: determine that there is an anomaly in the first message when a consumer of any sub-message queue acquires the first message but has not consumed the second message; the second message is the preceding message of the first message.

[0062] Optionally, the processing unit 502 is further configured to: for any third message in the total message queue, determine the sub-message queue corresponding to the third message based on the service identifier of the third message and the configuration of the third sub-queue in the message processing system that is in a valid state, and store the allocation record of the third message in the target database; the allocation record of any message includes a message identifier, a message content with a service identifier and a sub-queue configuration identifier corresponding to the message; and distribute the third message to the sub-message queue corresponding to the third message.

[0063] Optionally, the processing unit 502 is further configured to: dynamically adjust the sub-message queues in the message processing system based on the number of messages in the total message queue; update the adjusted sub-queue configuration to the dynamic configuration table; wherein, any sub-queue configuration in the dynamic configuration table includes a configuration identifier that is in effect, a preceding configuration identifier that is in failure, an effective identifier of the configuration identifier that is in effect, and the number of valid sub-queues.

[0064] Optionally, the processing unit 502 is specifically used to: determine the configuration of the first sub-queue corresponding to the first message from the dynamic configuration table according to the configuration identifier in the allocation record of the first message; and obtain the configuration of the second sub-queue from the dynamic configuration table according to the preceding configuration identifier in the configuration of the first sub-queue.

[0065] Optionally, the processing unit 502 is specifically used to: increase the number of sub-message queues in the message processing system when the number of messages in the total message queue is greater than a first threshold; and decrease the number of sub-message queues in the message processing system when the number of messages in the total message queue is less than a second threshold, and close the sub-message queues after all messages in the sub-message queues to be closed have been consumed; wherein the first threshold is greater than the second threshold.

[0066] Based on the same technical concept, embodiments of this application provide a computer device, such as... Figure 6 As shown, the computer device 600 includes at least one processor 601 and a memory 602 connected to the at least one processor. In this embodiment, the specific connection medium between the processor 601 and the memory 602 is not limited. Figure 6 Taking the connection between the processor 601 and the memory 602 via a bus as an example, the bus can be divided into address bus, data bus, control bus, etc.

[0067] In this embodiment of the application, the memory 602 stores instructions that can be executed by at least one processor 601. By executing the instructions stored in the memory 602, at least one processor 601 can perform the steps of the above-described message processing method.

[0068] The processor 601 is the control center of the computer device, capable of connecting to various parts of the computer device via various interfaces and lines. It processes syndicated online transactions by running or executing instructions stored in the memory 602 and accessing data stored in the memory 602. Optionally, the processor 601 may include one or more processing units. The processor 601 may integrate an application processor and a modem processor. The application processor primarily handles the operating system, user interface, and applications, while the modem processor primarily handles wireless communication. It is understood that the modem processor can also be integrated into the processor 601. In some embodiments, the processor 601 and the memory 602 can be implemented on the same chip; in other embodiments, they can be implemented on separate chips.

[0069] Processor 601 can be a general-purpose processor, such as a central processing unit (CPU), digital signal processor, application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component, capable of implementing or executing the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly manifested as being executed by a hardware processor, or executed by a combination of hardware and software modules within the processor.

[0070] Memory 602, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. Memory 602 may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (RAM), static random access memory (SRAM), programmable read-only memory (PROM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), magnetic memory, magnetic disk, optical disk, etc. Memory 602 can be any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer device, but is not limited thereto. In the embodiments of this application, memory 602 can also be a circuit or any other device capable of implementing storage functions for storing program instructions and / or data.

[0071] Based on the same inventive concept, embodiments of this application provide a computer-readable storage medium storing a computer program executable by a computer device, which, when run on the computer device, causes the computer device to perform the steps of the above-described message processing method.

[0072] Based on the same technical concept, embodiments of this application also provide a computer program product, including computer-readable instructions, which, when executed by a processor, enable the above-described data parsing method to be implemented.

[0073] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0074] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0075] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0076] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0077] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A message processing method, characterized in that, The method, applicable to message processing systems comprising a main message queue, multiple sub-message queues, and a target database, includes: When it is determined that there is a first message exception in any sub-message queue, the first message exception occurred when the number of any sub-message queue was adjusted; the allocation record of the first message is obtained from the target database based on the service identifier of the first message; the target database records the allocation record when any message is taken from the total message queue and allocated to the sub-message queue; Based on the first sub-queue configuration indicated by the allocation record of the first message, the second sub-queue configuration is obtained; the second sub-queue configuration is the preceding sub-queue configuration corresponding to the first sub-queue configuration; any sub-queue configuration is used to indicate the number of effective sub-queues in the message processing system during message allocation; Based on the second sub-queue configuration and the service identifier of the first message, the sub-message queue corresponding to the first message is re-determined and the first sub-queue configuration in the allocation record of the first message is updated to the second sub-queue configuration; The number of sub-message queues in the message processing system is dynamically adjusted based on the number of messages in the total message queue. Update the adjusted sub-queue configuration to the dynamic configuration table; wherein, any sub-queue configuration in the dynamic configuration table includes a configuration identifier that is in effect, a predecessor configuration identifier that is ineffective, an effective identifier of the configuration identifier that is in effect, and the number of valid sub-queues.

2. The method as described in claim 1, characterized in that, Determine if a first message exception exists in any sub-message queue, including: If a consumer in any sub-message queue receives the first message but has not consumed the second message, it is determined that there is an anomaly in the first message; the second message is the preceding message of the first message.

3. The method as described in claim 1, characterized in that, Also includes: For any third message in the total message queue, the sub-message queue corresponding to the third message is determined according to the service identifier of the third message and the third sub-queue configuration that is in a valid state in the message processing system, and the allocation record of the third message is stored in the target database; the allocation record of any message includes a message identifier, a message content with a service identifier, and a sub-queue configuration identifier corresponding to the message; The third message is distributed to the sub-message queue corresponding to the third message.

4. The method as described in claim 1, characterized in that, Based on the first sub-queue configuration indicated by the allocation record of the first message, obtain the second sub-queue configuration, including: Based on the configuration identifier in the allocation record of the first message, determine the configuration of the first sub-queue corresponding to the first message from the dynamic configuration table; The second sub-queue configuration is obtained from the dynamic configuration table based on the preceding configuration identifier in the first sub-queue configuration.

5. The method as described in claim 1, characterized in that, Based on the number of messages in the total message queue, the sub-message queues in the message processing system are dynamically adjusted, including: When the number of messages in the total message queue exceeds a first threshold, the number of sub-message queues in the message processing system is increased. When the number of messages in the total message queue is less than the second threshold, the number of sub-message queues in the message processing system is reduced, and the sub-message queues to be closed are closed after all messages in them have been consumed. Wherein, the first threshold is greater than the second threshold.

6. A message processing device, characterized in that, This applies to message processing systems that include a main message queue, multiple sub-message queues, and a target database, including: The acquisition unit is configured to, when it is determined that a first message exception exists in any sub-message queue, and the first message exception occurs when the number of any sub-message queue is adjusted, acquire the allocation record of the first message from the target database based on the service identifier of the first message; the target database records the allocation records when any message is taken from the total message queue and allocated to a sub-message queue; The processing unit is configured to obtain a second sub-queue configuration based on the first sub-queue configuration indicated by the allocation record of the first message; the second sub-queue configuration is the preceding sub-queue configuration corresponding to the first sub-queue configuration; any sub-queue configuration is used to indicate the number of valid sub-queues in the message processing system during message allocation; based on the second sub-queue configuration and the service identifier of the first message, the sub-message queue corresponding to the first message is re-determined and the first sub-queue configuration in the allocation record of the first message is updated to the second sub-queue configuration; The processing unit is further configured to dynamically adjust the number of sub-message queues in the message processing system based on the number of messages in the total message queue; and update the adjusted sub-queue configuration to the dynamic configuration table; wherein, any sub-queue configuration in the dynamic configuration table includes a configuration identifier in an effective state, a preceding configuration identifier in an ineffective state, an effective identifier of the configuration identifier in an effective state, and a number of valid sub-queues.

7. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the method according to any one of claims 1 to 5.

8. A computer-readable storage medium having a computer program / instructions stored thereon, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method of claim 1.

9. A computer program product, comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method of claim 1.

Citation Information

Patent Citations

  • Distributed message management system and method

    CN114253747A

  • Message processing method and device, equipment and storage medium

    CN115454671A