Message queue processing method, thread pool parameter adjustment method, device and equipment

By adjusting thread pool parameters and introducing backup and failed message queues, the problem of low complexity and reliability of message queue functions in the prior art is solved, and efficient and reliable processing of message queues is achieved, avoiding message loss and data inconsistency.

CN113722117BActive Publication Date: 2025-01-14BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202011248590.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-10
Publication Date
2025-01-14
Estimated Expiration
2040-11-10

AI Technical Summary

Technical Problem

The existing technology has problems such as complex design, difficult maintenance, and inconsistent message loss and data when implementing the message queue function. Especially under high load conditions, it may cause server downtime and affect normal business execution.

Method used

By adjusting thread pool parameters and introducing backup message queues and failure message queues, the thread pool parameters are dynamically adjusted to cope with the success and failure of task messages, ensuring that messages are not lost and improving the reliability of message queues.

Benefits of technology

It effectively avoids message loss, ensures data consistency and message queue reliability, improves the server's message processing capabilities, and prevents the business impact caused by server downtime.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113722117B_ABST
    Figure CN113722117B_ABST
Patent Text Reader

Abstract

The embodiments of the present disclosure disclose a message queue processing method, a thread pool parameter adjustment method, an apparatus and a device. A specific implementation of the method includes: in response to determining that the thread pool parameters of the local cache have changed, adjusting the thread pool parameters of the thread pool corresponding to the target task message queue; in response to determining that the task message in the target task message queue has been consumed successfully, deleting the backup message that matches the successfully consumed task message from the backup message queue used to back up the task message in the target task message queue; in response to determining that the task message in the target task message queue has failed to be consumed, adding the failed task message as a failed message to the failed message queue. This implementation achieves the effect of simply and effectively avoiding message loss, ensuring data consistency and message queue reliability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present disclosure relate to the field of computer technology, and in particular to a message queue processing method, a thread pool parameter adjustment method, a device, and a device. Background Art

[0002] When there are too many messages, the message queue can be used to reduce the traffic peak, decouple and asynchronously process the messages, thereby improving the server processing performance. The commonly used method is to implement the message queue function through message middleware (for example, ActiveMQ, RabbitMQ, etc.) or arrays.

[0003] However, when the above method is used to implement the message queue function, the following technical problems often occur:

[0004] First, implementing the message queue function through message middleware will result in complex design, high technical requirements, and difficulty in deployment and maintenance. Implementing the message queue function through arrays, when messages are lost, there is no data backup or it is difficult to trace and restore the lost data, resulting in data inconsistency and reduced reliability of the message queue.

[0005] Second, when there are a large number of message requests, it is difficult to adjust the message processing volume in real time and dynamically. In the case of low server performance, it is very likely to cause server downtime, which in turn seriously affects the normal execution of the business. Summary of the invention

[0006] The content of this disclosure is used to introduce concepts in a brief form, which will be described in detail in the detailed implementation section below. The content of this disclosure is not intended to identify the key features or essential features of the technical solution claimed for protection, nor is it intended to limit the scope of the technical solution claimed for protection.

[0007] Some embodiments of the present disclosure propose a message queue processing method, a thread pool parameter adjustment method, an apparatus and a device to solve one or more of the technical problems mentioned in the above background technology section.

[0008] In a first aspect, some embodiments of the present disclosure provide a message queue processing method, the method comprising: in response to determining that a thread pool parameter of a local cache has changed, adjusting the thread pool parameter of a thread pool corresponding to a target task message queue, wherein the thread pool is used to create and start a target task message queue processing thread. In response to determining that a task message in the target task message queue has been consumed successfully, deleting a backup message that matches a successfully consumed task message from a backup message queue used to back up the task message in the target task message queue. In response to determining that a task message in the target task message queue has failed to be consumed, adding the failed task message to a failed message queue as a failed message.

[0009] Optionally, the method also includes: in response to determining that the target task message queue does not include a task message matching the received message, adding the received message as a task message to the target task message queue and adding the received message as a backup message to a backup message queue.

[0010] Optionally, the above method also includes: calling a backup message queue processing thread to process the backup messages in the above backup message queue, wherein the above backup message queue processing thread is used to obtain backup messages from the above backup message queue at a first preset frequency and in response to obtaining backup messages from the above backup message queue, adding the obtained backup messages as task messages to the above target task message queue.

[0011] Optionally, the above method also includes: calling a failure message queue processing thread to process the failure messages in the above failure message queue, wherein the above failure message queue processing thread is used to obtain failure messages from the above failure message queue at a second preset frequency and in response to obtaining failure messages from the above failure message queue, adding the obtained failure messages as task messages to the above target task message queue.

[0012] Optionally, the above method also includes: calling the target task message queue processing thread in the thread pool corresponding to the above target task message queue to process the task message in the above target task message queue, wherein the above target task message queue processing thread is used to call the business interface to consume the task message obtained from the above target task message queue.

[0013] In a second aspect, some embodiments of the present disclosure provide a thread pool parameter adjustment method, the method comprising: in response to determining that the rejection frequency of the thread pool for the received task message is greater than or equal to a preset rejection frequency, generating a first thread pool parameter based on the thread pool parameter of the thread pool, wherein the thread pool parameter of the thread pool comprises: the number of core threads, the maximum number of threads, and the blocking queue capacity. The thread pool parameter stored in the local cache is replaced with the first thread pool parameter.

[0014] Optionally, the method further includes: in response to determining that the difference between the maximum number of threads included in the thread pool parameters of the thread pool and the total number of target task message queue processing threads in the thread pool meets a preset condition, generating a second thread pool parameter based on the thread pool parameters of the thread pool, and replacing the thread pool parameters stored in the local cache with the second thread pool parameters.

[0015] Optionally, generating the first thread pool parameter based on the thread pool parameter of the thread pool includes: determining the first maximum number of threads based on a preset maximum number of threads, a first preset adjustment ratio, and the maximum number of threads included in the thread pool parameter of the thread pool.

[0016] Optionally, generating the first thread pool parameter based on the thread pool parameter of the thread pool further includes: determining the first core thread number based on the second preset adjustment ratio and the first maximum thread number.

[0017] Optionally, generating the second thread pool parameters based on the thread pool parameters of the above thread pool includes: determining the second blocking queue capacity based on a third preset adjustment ratio, a preset blocking queue capacity and the blocking queue capacity included in the thread pool parameters of the above thread pool.

[0018] Optionally, generating the second thread pool parameters based on the thread pool parameters of the thread pool also includes: determining the second maximum number of threads based on the first preset adjustment ratio, the preset maximum number of threads and the maximum number of threads included in the thread pool parameters of the thread pool.

[0019] Optionally, generating the second thread pool parameter based on the thread pool parameter of the thread pool further includes: determining the second core thread number based on the second preset adjustment ratio and the second maximum thread number.

[0020] In a third aspect, some embodiments of the present disclosure provide a message queue processing device, the device comprising: an adjustment unit, configured to adjust the thread pool parameters of the thread pool corresponding to the target task message queue in response to determining that the thread pool parameters of the local cache have changed, wherein the thread pool is used to create and start the target task message queue processing thread. A deletion unit, configured to delete the backup message that matches the successfully consumed task message from the backup message queue used to back up the task message in the target task message queue in response to determining that the task message in the target task message queue has been consumed successfully. A joining unit, configured to add the failed task message as a failed message to the failed message queue in response to determining that the task message in the target task message queue has failed to be consumed.

[0021] Optionally, the device also includes: a adding unit, configured to, in response to determining that the target task message queue does not include a task message matching the received message, add the received message as a task message to the target task message queue and add the received message as a backup message to the backup message queue.

[0022] Optionally, the device also includes: a first calling unit, configured to call a backup message queue processing thread to process the backup messages in the above-mentioned backup message queue, wherein the above-mentioned backup message queue processing thread is used to obtain backup messages from the above-mentioned backup message queue at a first preset frequency and in response to obtaining the backup messages from the above-mentioned backup message queue, add the above-mentioned backup messages as task messages to the above-mentioned target task message queue.

[0023] Optionally, the device also includes: a second calling unit, configured to call a failure message queue processing thread to process the failure messages in the above-mentioned failure message queue, wherein the above-mentioned failure message queue processing thread is used to obtain failure messages from the above-mentioned failure message queue at a second preset frequency and in response to obtaining the failure messages from the above-mentioned failure message queue, add the above-mentioned failure messages as task messages to the above-mentioned target task message queue.

[0024] Optionally, the device also includes: a third calling unit, configured to call the thread pool corresponding to the target task message queue to process the task messages in the target task message queue, wherein the target task message queue processing thread is used to call the business interface to consume the task messages obtained from the target task message queue.

[0025] In a fourth aspect, some embodiments of the present disclosure provide a thread pool parameter adjustment device, the device comprising: a generation unit, configured to generate a first thread pool parameter based on the thread pool parameters of the thread pool in response to determining that the rejection frequency of the thread pool for the received task message is greater than or equal to a preset rejection frequency, wherein the thread pool parameters of the thread pool include: the number of core threads, the maximum number of threads, and the blocking queue capacity. A replacement unit, configured to replace the thread pool parameters stored in the local cache with the first thread pool parameters.

[0026] Optionally, the device further includes: a second thread pool parameter generating unit and a second thread pool parameter replacing unit. The second thread pool parameter generating unit is configured to generate the second thread pool parameter based on the thread pool parameter of the thread pool in response to determining that the frequency at which the difference between the maximum number of threads included in the thread pool parameter of the thread pool and the total number of target task message queue processing threads in the thread pool is greater than or equal to the preset difference is greater than or equal to the preset approach frequency; and the second thread pool parameter replacing unit is configured to replace the thread pool parameter stored in the local cache with the second thread pool parameter.

[0027] Optionally, the second thread pool parameter generating unit is further configured to: determine the first maximum number of threads based on a preset maximum number of threads, a first preset adjustment ratio, and the maximum number of threads included in the thread pool parameters of the thread pool.

[0028] Optionally, the second thread pool parameter generating unit is further configured to: determine the first core thread number based on the second preset adjustment ratio and the first maximum thread number.

[0029] Optionally, the second thread pool parameter replacement unit is further configured to: determine the second blocking queue capacity based on a third preset adjustment ratio, a preset blocking queue capacity and the blocking queue capacity included in the thread pool parameters of the above thread pool.

[0030] Optionally, the second thread pool parameter replacement unit is further configured to: determine a second maximum number of threads based on the first preset adjustment ratio, the preset maximum number of threads and the maximum number of threads included in the thread pool parameters of the thread pool.

[0031] Optionally, the second thread pool parameter replacement unit is further configured to: determine the second core thread number based on the second preset adjustment ratio and the second maximum number of threads. In a fifth aspect, some embodiments of the present disclosure provide an electronic device, comprising: one or more processors; a storage device having one or more programs stored thereon, and when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any implementation of the first and second aspects above.

[0032] In a sixth aspect, some embodiments of the present disclosure provide a computer-readable medium having a computer program stored thereon, wherein when the program is executed by a processor, the method described in any one of the implementation modes of the first and second aspects above is implemented.

[0033] The above-mentioned embodiments of the present disclosure have the following beneficial effects: through the message queue processing method of some embodiments of the present disclosure, it is relatively easy to avoid message loss, ensure data consistency and improve the reliability of the message queue. Specifically, the reason for data inconsistency and reduced reliability of the message queue is that the existing methods rarely consider message backup and message retry. Based on this, the message queue processing method of some embodiments of the present disclosure can effectively avoid the loss of task messages dequeued from the target task message queue when the server is down, the server is restarted, etc., by backing up the task messages in the target task message queue and adding the backed-up messages as backup messages to the backup message queue, thereby ensuring the reliability of the message queue to a certain extent. At the same time, the task messages that failed to be consumed are stored in the failed message queue, and then the failed messages in the failed message queue are added to the target task message queue again to realize the re-consumption of the task messages that failed to be consumed. Thereby, the successful consumption of the task message is ensured to the greatest extent. Only through the target task message queue, the backup message queue and the failed message queue can the effect of effectively avoiding message loss, ensuring data consistency and improving the reliability of the message queue be easily achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that components and elements are not necessarily drawn to scale.

[0035] Figure 1 is a schematic diagram of an application scenario of a message queue processing method according to some embodiments of the present disclosure;

[0036] Figure 2 is a schematic diagram of an application scenario of a thread pool parameter adjustment method according to some embodiments of the present disclosure;

[0037] Figure 3 is a flowchart of some embodiments of the message queue processing method according to the present disclosure;

[0038] Figure 4 are flowcharts of other embodiments of the message queue processing method according to the present disclosure;

[0039] Figure 5 is a flowchart of some embodiments of the thread pool parameter adjustment method according to the present disclosure;

[0040] Figure 6 are flowcharts of other embodiments of the thread pool parameter adjustment method according to the present disclosure;

[0041] Figure 7 is a schematic diagram of the structure of some embodiments of the message queue processing device according to the present disclosure;

[0042] Figure 8 It is a structural schematic diagram of some embodiments of the thread pool parameter adjustment device according to the present disclosure;

[0043] Fig. 9 It is a schematic diagram of the structure of an electronic device suitable for implementing some embodiments of the present disclosure. DETAILED DESCRIPTION

[0044] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein. On the contrary, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0045] It should also be noted that, for ease of description, only the parts related to the invention are shown in the drawings. In the absence of conflict, the embodiments and features in the embodiments of the present disclosure can be combined with each other.

[0046] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0047] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0048] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0049] The present disclosure will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.

[0050] Figure 1 It is a schematic diagram of an application scenario of the message queue processing method according to some embodiments of the present disclosure.

[0051] like Figure 1 As shown, first, in response to determining that the thread pool parameters of the local cache have changed, the computing device 101 can adjust the thread pool parameters 1031 of the thread pool 103 corresponding to the target task message queue 102, wherein the thread pool 103 is used to create and start the target task message queue processing thread 1032. Then, in response to determining that the task message 1021 in the target task message queue 102 has been consumed successfully, the computing device 101 can delete the backup message 1041 that matches the successfully consumed task message 1021 from the backup message queue 104 used to back up the task messages in the target task message queue 102. Finally, in response to determining that the task message 1021 in the target task message queue 102 has failed to be consumed, the computing device 101 can add the failed task message 1021 as a failed message 1051 to the failed message queue 105.

[0052] It should be noted that the message queue processing method can be executed by the computing device 101. The computing device 101 can be hardware or software. When the computing device is hardware, it can be implemented as a distributed cluster consisting of multiple servers or terminal devices, or it can be implemented as a single server or a single terminal device. When the computing device is embodied as software, it can be installed in the hardware devices listed above. It can be implemented as multiple software or software modules for providing distributed services, for example, or it can be implemented as a single software or software module. No specific limitation is made here.

[0053] It should be understood that Figure 1 The number of computing devices in the embodiment is only illustrative. Any number of computing devices may be provided according to implementation requirements.

[0054] Figure 2 It is a schematic diagram of an application scenario of a thread pool parameter adjustment method according to some embodiments of the present disclosure.

[0055] like Figure 2 As shown, first, in response to determining that the rejection frequency of the thread pool 202 for the received task message is greater than or equal to the preset rejection frequency, the computing device 201 can generate the first thread pool parameter 203 based on the thread pool parameter 2021 of the thread pool 202, wherein the thread pool parameter 2021 of the thread pool 202 includes: the number of core threads 20211, the maximum number of threads 20212, and the blocking queue capacity 20213. Then, the computing device 201 can use the first thread pool parameter 203 to replace the thread pool parameter 204 stored in the local cache.

[0056] It should be noted that the thread pool parameter adjustment method can be executed by a computing device 201. The computing device 201 can be hardware or software. When the computing device is hardware, it can be implemented as a distributed cluster consisting of multiple servers or terminal devices, or it can be implemented as a single server or a single terminal device. When the computing device 201 is embodied as software, it can be implemented as multiple software or software modules for providing distributed services, for example, or it can be implemented as a single software or software module. No specific limitation is made here.

[0057] It should be understood that Figure 2 The number of computing devices in the embodiment is only illustrative. Any number of computing devices may be provided according to implementation requirements.

[0058] Continue to refer Figure 3 , shows a process 300 of some embodiments of the message queue processing method according to the present disclosure. The message queue processing method comprises the following steps:

[0059] Step 301 , in response to determining that a thread pool parameter of a local cache has changed, adjusting the thread pool parameter of a thread pool corresponding to a target task message queue.

[0060] In some embodiments, the execution body of the message queue processing method (such as Figure 1 The computing device 101 shown in the figure can adjust the thread pool parameters of the thread pool corresponding to the target task message queue in response to determining that the thread pool parameters of the local cache have changed. Among them, the above-mentioned thread pool is used to create and start the target task message queue processing thread. The above-mentioned target task message queue can be a task message queue existing on the above-mentioned execution subject. The above-mentioned target task message queue can be used to store task messages of the target type. The task message of the above-mentioned target type can be a redemption code redemption request message, a user order request message, etc. The thread pool parameters of the above-mentioned thread pool may include but are not limited to: the number of core threads, the maximum number of threads, and the capacity of the blocking queue. The above-mentioned locally cached thread pool parameters can be used when initializing the above-mentioned thread pool, and can also be used when adjusting the thread pool parameters of the above-mentioned thread pool. Changes in the thread pool parameters of the local cache may refer to: the number of core threads included in the thread pool parameters of the local cache increases or decreases, the maximum number of threads included in the thread pool parameters of the local cache increases or decreases, and the capacity of the blocking queue included in the thread pool parameters of the local cache increases or decreases.

[0061] As an example, the original locally cached thread pool parameters may be [core threads: 4, maximum threads: 8, blocking queue capacity: 4]. The changed locally cached thread pool parameters may be [core threads: 6, maximum threads: 12, blocking queue capacity: 4]. The thread pool parameters of the thread pool corresponding to the original target task message queue may be: [core threads: 4, maximum threads: 8, blocking queue capacity: 4]. The core threads and maximum threads in the thread pool parameters of the original target task message queue may be adjusted to the core threads and maximum threads in the changed locally cached thread pool parameters. Then the adjusted thread pool parameters of the thread pool corresponding to the target task message queue may be: [core threads: 6, maximum threads: 12, blocking queue capacity: 4].

[0062] Step 302 : in response to determining that the task message in the target task message queue is consumed successfully, deleting a backup message matching the successfully consumed task message from a backup message queue used to back up the task messages in the target task message queue.

[0063] In some embodiments, the execution subject may delete the backup message that matches the successfully consumed task message from the backup message queue used to back up the task message in the target task message queue in response to determining that the task message in the target task message queue is consumed successfully. Among them, the successful consumption of the task message in the target task message queue may refer to the successful execution of the business logic of the task message in the target task message queue by the business interface after being dequeued. The backup message queue may be a backup message queue created and initialized together with the target task message queue. The backup message that matches the successfully consumed task message may be a backup message whose message content is the same as the message content of the successfully consumed task message, or a message whose message unique identification field value is the same as the message unique identification field value of the successfully consumed task message. It can be understood that in this way, the value of the mark bit in the task message and the backup message needs to be set in advance.

[0064] As an example, in response to determining that the task message in the above-mentioned target task message queue has been consumed successfully, a backup message that matches the successfully consumed task message can be deleted from a backup message queue used to back up the task message in the above-mentioned target task message queue. In these implementations, by backing up the task messages in the above-mentioned target task message queue through a backup message queue, it is possible to effectively avoid the loss of task messages that are dequeued from the above-mentioned target task message queue when situations such as server downtime and server restart occur, thereby ensuring the reliability of the message queue to a certain extent. In these implementations, after the task message in the above-mentioned target task message queue has been consumed successfully, by deleting the backup message that matches the successfully consumed task message in the backup message queue, it is possible to avoid the backup message that matches the successfully consumed task message in the backup message queue from being repeatedly consumed, thereby reducing the pressure of message processing and reducing the waste of computing resources.

[0065] Step 303: In response to determining that the task message in the target task message queue fails to be consumed, the task message that fails to be consumed is added to the failed message queue as a failed message.

[0066] In some embodiments, the execution subject may, in response to determining that the consumption of the task message in the target task message queue has failed, add the task message that has failed to be consumed as a failure message to a failure message queue. The failure to consume the task message in the target task message queue may refer to situations such as database access timeout and data anomaly when the business interface executes the business logic of the task message in the target task message queue after it is dequeued. The failure message queue may be a failure message queue created and initialized together with the target task message queue. The failure message queue may also be a failure message queue created and initialized when the first message in the target task message queue that fails to be consumed is generated. The failure message in the failure message queue may be added to the target task message queue again.

[0067] In these implementations, after the consumption of the task message in the above-mentioned target task message queue fails, the task message that failed to be consumed is added to the failure message queue as a failure message. The task message that failed to be consumed can be consumed again by adding the failure message in the failure message queue to the target task message queue again, thereby ensuring the successful consumption of the task message to the greatest extent.

[0068] In some optional implementations of some embodiments, the method further includes: in response to determining that the target task message queue does not include a task message matching the received message, adding the received message as a task message to the target task message queue and adding the received message as a backup message to a backup message queue. The message matching the received message in the target task message queue may be a task message having the same message content as the received message.

[0069] As an example, the Set data structure of Redis (Remote Dictionary Server) can be used to determine whether the target task message queue includes a task message that matches the received message. In these implementations, after determining that the target task message queue does not include a task message that matches the received message, the received message is added to the target task message queue as a task message and the received message is added to the backup message queue as a backup message, so that the task message can be backed up, thereby preventing the loss of task messages that are dequeued from the target task message queue. At the same time, the purpose of deduplication of the target task message queue can be achieved, preventing the same message from being added to the target task message queue, thereby reducing the processing pressure of the task message.

[0070] The above-mentioned embodiments of the present disclosure have the following beneficial effects: through the message queue processing method of some embodiments of the present disclosure, it is relatively easy to avoid message loss, ensure data consistency and improve the reliability of the message queue. Specifically, the reason for data inconsistency and reduced reliability of the message queue is that the existing methods rarely consider message backup and message retry. Based on this, the message queue processing method of some embodiments of the present disclosure can effectively avoid the loss of task messages dequeued from the target task message queue when the server is down, the server is restarted, etc., by backing up the task messages in the target task message queue and adding the backed-up messages as backup messages to the backup message queue, thereby ensuring the reliability of the message queue to a certain extent. At the same time, the task messages that failed to be consumed are stored through the failed message queue, and then the failed messages in the failed message queue are added to the target task message queue again to realize the re-consumption of the task messages that failed to be consumed. Thereby, the successful consumption of the task message is ensured to the greatest extent. Only through the target task message queue, the backup message queue and the failed message queue can the effect of effectively avoiding message loss, ensuring data consistency and improving the reliability of the message queue be easily achieved.

[0071] Further references Figure 4, which shows a process 400 of another embodiment of a message queue processing method. The process 400 of the message queue processing method includes the following steps:

[0072] Step 401 , in response to determining that the thread pool parameters of the local cache have changed, adjusting the thread pool parameters of the thread pool corresponding to the target task message queue.

[0073] Step 402 , in response to determining that the task message in the target task message queue is consumed successfully, deleting a backup message matching the successfully consumed task message from a backup message queue used to back up the task messages in the target task message queue.

[0074] Step 403: In response to determining that the task message in the target task message queue fails to be consumed, the task message that fails to be consumed is added to the failure message queue as a failure message.

[0075] In some embodiments, the specific implementation of steps 401-403 and the technical effects thereof can be referred to in Figure 3 The corresponding steps 301-303 in the embodiments are not described in detail here.

[0076] Step 404: call the backup message queue processing thread to process the backup message in the backup message queue.

[0077] In some embodiments, the execution body of the message queue processing method (such as Figure 1 The computing device 101 shown in the figure can call the backup message queue processing thread to process the backup messages in the backup message queue. The backup message queue processing thread can be used to obtain backup messages from the backup message queue at a first preset frequency and, in response to obtaining backup messages from the backup message queue, add the obtained backup messages as task messages to the target task message queue. The first preset frequency can be used to limit the frequency at which the backup message queue processing thread obtains backup messages from the backup message queue. When there are backup messages in the backup message queue, the backup message queue processing thread can obtain the backup messages from the backup message queue.

[0078] As an example, the first preset frequency may be 15 minutes / time. Then the backup message queue processing thread may obtain the backup message from the backup message queue every 15 minutes. If there is a backup message in the backup message queue, the backup message queue processing thread may obtain the backup message from the backup message queue. Then the backup message queue processing thread may add the obtained backup message to the target task message queue.

[0079] In these implementations, the frequency of processing the backup messages in the backup message queue by the backup message queue processing thread is reflected, so that the consumption of resources such as memory caused by frequent calling of the backup message queue processing thread can be avoided.

[0080] Step 405: calling the failed message queue processing thread to process the failed message in the failed message queue.

[0081] In some embodiments, the execution subject may call a failure message queue processing thread to process the failure messages in the failure message queue. The failure message queue processing thread is used to obtain failure messages from the failure message queue at a second preset frequency and, in response to obtaining a failure message from the failure message queue, add the obtained failure message to the target task message queue as a task message. The second preset frequency may be used to limit the frequency at which the failure message queue processing thread obtains failure messages from the failure message queue. When there is a failure message in the failure message queue, the failure message queue processing thread may obtain the failure message from the failure message queue.

[0082] As an example, the second preset frequency may be 10 minutes / time. Then the failure message queue processing thread may obtain a failure message from the failure message queue every 10 minutes. If there is a failure message in the failure message queue, the failure message queue processing thread may obtain the failure message from the failure message queue. Then the failure message queue processing thread may add the obtained failure message to the target task message queue.

[0083] In these implementations, the frequency with which the failed message queue processing thread processes the failed messages in the failed message queue is reflected, so that the consumption of resources such as memory caused by frequent calls to the failed message queue processing thread can be avoided.

[0084] Step 406: Call the target task message queue processing thread in the thread pool corresponding to the target task message queue to process the task message in the target task message queue.

[0085] In some embodiments, the above-mentioned execution subject can call the target task message queue processing thread in the thread pool corresponding to the above-mentioned target task message queue to process the task message in the above-mentioned target task message queue. Among them, the above-mentioned target task message queue processing thread is used to call the business interface to consume the task message obtained from the above-mentioned target task message queue. The above-mentioned thread pool can obtain the message dequeued from the above-mentioned target task message queue. The above-mentioned thread pool can also call the target task message queue processing thread to process the obtained task message according to the running status of each target task message queue processing thread in the thread pool. Each target task message queue processing thread in the above-mentioned thread pool can process task messages in parallel, thereby improving the server's ability to process messages.

[0086] from Figure 4 It can be seen that Figure 3 Compared with the description of some corresponding embodiments, Figure 4 The process 400 of the message queue processing method in some corresponding embodiments reflects the frequency of the backup message queue processing thread processing the backup message in the backup message queue and the frequency of the failure message queue processing thread processing the failure message in the failure message queue. Thus, the consumption of resources such as memory by frequently calling the backup message queue processing thread and the failure message queue processing thread can be avoided.

[0087] Continue to refer Figure 5 , shows a process 500 of some embodiments of the thread pool parameter adjustment method according to the present disclosure. The thread pool parameter adjustment method comprises the following steps:

[0088] Step 501 , in response to determining that a rejection frequency of a thread pool for received task messages is greater than or equal to a first rejection frequency, generating a first thread pool parameter based on a thread pool parameter of the thread pool.

[0089] In some embodiments, the execution body of the thread pool parameter adjustment method (such as Figure 2 The computing device 201 shown may adjust the maximum number of threads included in the thread pool parameters of the thread pool according to a preset adjustment gradient value in response to determining that the rejection frequency of the thread pool for the received task message is greater than or equal to the first rejection frequency, and generate the first thread pool parameter. Rejection may mean that when the number of threads running in the thread pool has reached the maximum number of threads and the blocking queue of the thread pool is full, the thread pool no longer receives or obtains the task message.

[0090] As an example, the first rejection frequency may be 10 times / minute. The preset adjustment gradient value may be 2. The thread pool parameters of the thread pool may be [core threads: 4, maximum threads: 8, blocking queue capacity: 4]. Then, when the thread pool rejects the received task message more than or equal to 10 times within 1 minute, the sum of the maximum number of threads 8 in the thread pool parameters of the thread pool and the preset adjustment gradient value 2 may be determined as the first core thread number, and thus, the obtained first core thread number may be 10. Then, the first thread pool parameters may be [core threads: 4, maximum number of threads: 10, blocking queue capacity: 4].

[0091] In some optional implementations of some embodiments, the execution subject generates the first thread pool parameter based on the thread pool parameter of the thread pool, which may include the following steps:

[0092] The first step is to determine the first maximum number of threads based on the preset maximum number of threads, the first preset adjustment ratio and the maximum number of threads included in the thread pool parameters of the thread pool. The first preset adjustment ratio can be manually set in advance. The preset maximum number of threads can also be manually set in advance to limit the upper limit of the maximum number of threads included in the thread pool parameters of the thread pool.

[0093] As an example, the thread pool parameters of the thread pool may be [core thread number: 4, maximum thread number: 8, blocking queue capacity: 4]. The preset maximum thread number may be 12. The first preset adjustment ratio may be 1.5. Then, the product value of the maximum thread number 8 included in the thread pool parameters of the thread pool and the first preset adjustment ratio 1.5 may be first determined to be 12. Then, in response to the product value 12 being less than or equal to the preset maximum thread number 12, the product value 12 may be determined as the first maximum thread number. In response to the product value being greater than the preset maximum thread number, the preset maximum thread number may be determined as the first maximum thread number.

[0094] The second step is to determine the first number of core threads based on the second preset adjustment ratio and the first maximum number of threads, wherein the second preset adjustment ratio may be manually set in advance or determined based on the ratio of the number of core threads to the maximum number of threads included in the thread pool parameters of the thread pool.

[0095] As an example, the ratio of the number of core threads 4 to the maximum number of threads 8 included in the thread pool parameters of the thread pool is 1:2. Then the second preset adjustment ratio may be 1:2. The first maximum number of threads may be 12. Then the integer digit value 6 of the product of the second preset adjustment ratio and the first maximum number of threads may be determined as the first number of core threads. Then the first thread pool parameters may be [number of core threads: 6, maximum number of threads: 12, blocking queue capacity: 4].

[0096] Step 502: Use the first thread pool parameters to replace the thread pool parameters stored in the local cache.

[0097] In some embodiments, the execution subject may use the first thread pool parameter to replace the thread pool parameter stored in the local cache, wherein the thread pool parameter stored in the local cache is used in Figure 3 , Figure 4 In some corresponding embodiments.

[0098] As an example, the thread pool parameters stored in the local cache may be [core threads: 4, maximum threads: 8, blocking queue capacity: 4]. The first thread pool parameters may be [core threads: 6, maximum threads: 12, blocking queue capacity: 4]. Then the thread pool parameters stored in the local cache may be replaced with [core threads: 6, maximum threads: 12, blocking queue capacity: 4].

[0099] The above-mentioned various embodiments of the present disclosure have the following beneficial effects: through the thread pool parameter adjustment method of some embodiments of the present disclosure, it is possible to adjust the message processing volume in real time and dynamically, and avoid server downtime to a certain extent. Specifically, part of the reason for the server downtime is that when the existing methods process a large number of message requests, it is difficult to adjust the message processing volume in real time and dynamically, and then when the server performance is low, it is very likely to cause the server to crash, seriously affecting the normal execution of the business. Based on this, the thread pool parameter adjustment method of some embodiments of the present disclosure realizes real-time adjustment of the thread pool parameters by monitoring the rejection frequency of the received task messages by the thread pool. Thereby, the message processing performance of the server is improved to a certain extent.

[0100] Further references Figure 6 , shows a process 600 of some other embodiments of the thread pool parameter adjustment method according to the present disclosure. The thread pool parameter adjustment method comprises the following steps:

[0101] Step 601 , in response to determining that a rejection frequency of a thread pool for received task messages is greater than or equal to a first rejection frequency, generating a first thread pool parameter based on a thread pool parameter of the thread pool.

[0102] Step 602: Use the first thread pool parameters to replace the thread pool parameters stored in the local cache.

[0103] In some embodiments, the specific implementation of steps 601-602 and the technical effects thereof can be referred to in Figure 3 The corresponding steps 501-502 in the embodiments are not described in detail here.

[0104] Step 603, in response to determining that the difference between the maximum number of threads included in the thread pool parameters of the thread pool and the total number of target task message queue processing threads in the thread pool meets a preset condition, generate a second thread pool parameter based on the thread pool parameters of the thread pool.

[0105] In some embodiments, the execution body of the thread pool parameter adjustment method (such as Figure 2 The computing device 201 shown can adjust the number of core threads, the maximum number of threads and the blocking queue capacity included in the thread pool parameters of the thread pool according to a preset adjustment gradient value in response to determining that the difference between the maximum number of threads included in the thread pool parameters of the thread pool and the total number of target task message queue processing threads in the thread pool meets the preset condition, and generate a second thread pool parameter. The preset condition can be that the number of times the difference is less than the preset difference within a preset unit time is not less than a preset number of times.

[0106] As an example, the thread pool parameters of the thread pool may be [core thread number: 4, maximum thread number: 8, blocking queue capacity: 4]. The preset difference may be 2. The unit time may be 1 minute. The preset number of times may be 10 times. The preset adjustment gradient value may be 2. Then, the sum of the core thread number, maximum thread number and blocking queue capacity included in the thread pool parameters of the thread pool and the preset adjustment gradient value may be respectively determined as the second core thread number, the second maximum thread number and the second blocking queue capacity, and the second thread pool parameters [core thread number: 6, maximum thread number: 10, blocking queue capacity: 6] may be obtained.

[0107] In some optional implementations of some embodiments, the execution subject generates the second thread pool parameters based on the thread pool parameters of the thread pool, which may include the following steps:

[0108] The first step is to determine the second blocking queue capacity based on the third preset adjustment ratio, the preset blocking queue capacity and the blocking queue capacity included in the thread pool parameters of the thread pool. The third preset adjustment ratio can be manually set in advance. The preset blocking queue capacity can be used to limit the upper limit value of the blocking queue capacity included in the thread pool parameters of the thread pool.

[0109] As an example, the thread pool parameters of the thread pool may be [number of core threads: 4, maximum number of threads: 8, blocking queue capacity: 4]. The third preset adjustment ratio may be 1:1.5. The preset blocking queue capacity may be 8. When the product value of the third preset adjustment ratio and the blocking queue capacity included in the thread pool parameters of the thread pool is less than or equal to the preset blocking queue capacity, the product value may be determined as the second blocking queue capacity. When the product value of the third preset adjustment ratio and the blocking queue capacity included in the thread pool parameters of the thread pool is greater than the preset blocking queue capacity, the preset blocking queue capacity may be determined as the second blocking queue capacity.

[0110] The second step is to determine the second maximum number of threads based on the first preset adjustment ratio, the preset maximum number of threads and the maximum number of threads included in the thread pool parameters of the thread pool. The first preset adjustment ratio may be manually set in advance. The preset maximum number of threads may also be manually set in advance to limit the upper limit of the maximum number of threads included in the thread pool parameters of the thread pool.

[0111] The third step is to determine the second core thread number based on the second preset adjustment ratio and the second maximum thread number.

[0112] Step 604: Use the second thread pool parameters to replace the thread pool parameters stored in the local cache.

[0113] In some embodiments, the execution entity may use the second thread pool parameters to replace the thread pool parameters stored in the local cache.

[0114] from Figure 6 It can be seen that Figure 5 Compared with the description of some corresponding embodiments, Figure 6 The process 600 of the thread pool parameter adjustment method in some corresponding embodiments reflects the monitoring of the difference between the maximum number of threads included in the thread pool parameter of the thread pool and the total number of target task message queue processing threads in the thread pool, and then adjusts the thread pool parameter in real time to generate the second thread pool parameter. Thus, the processing capability of the thread pool for task messages can be further improved. Furthermore, the processing capability of the server is improved.

[0115] Continue to refer Figure 7 As an implementation of the methods shown in the above figures, the present disclosure provides some embodiments of a message queue processing device, and these device embodiments are Figure 3 Corresponding to the method embodiments shown, the device can be specifically applied to various electronic devices.

[0116] like Figure 7As shown, the message queue processing device 700 of some embodiments includes: an adjustment unit 701, an adjustment unit 702 and a joining unit 703. The adjustment unit 701 is configured to adjust the thread pool parameters of the thread pool corresponding to the target task message queue in response to determining that the thread pool parameters of the local cache have changed, wherein the thread pool is used to create and start the target task message queue processing thread; the deletion unit 702 is configured to delete the backup message matching the successfully consumed task message from the backup message queue used to back up the task message in the target task message queue in response to determining that the task message in the target task message queue has been consumed successfully; the joining unit 703 is configured to add the failed task message as a failed message to the failed message queue in response to determining that the task message in the target task message queue has failed to be consumed.

[0117] In an optional implementation of some embodiments, the device 700 also includes: a adding unit, which is configured to add the received message as a task message to the target task message queue and add the received message as a backup message to the backup message queue in response to determining that the target task message queue does not include a task message matching the received message.

[0118] In an optional implementation of some embodiments, the device 700 also includes: a first calling unit, configured to call a backup message queue processing thread to process the backup messages in the above-mentioned backup message queue, wherein the above-mentioned backup message queue processing thread is used to obtain backup messages from the above-mentioned backup message queue at a first preset frequency and in response to obtaining the backup messages from the above-mentioned backup message queue, add the above-mentioned backup messages as task messages to the above-mentioned target task message queue.

[0119] In an optional implementation of some embodiments, the device 700 also includes: a second calling unit, configured to call a failure message queue processing thread to process the failure message in the above-mentioned failure message queue, wherein the above-mentioned failure message queue processing thread is used to obtain failure messages from the above-mentioned failure message queue at a second preset frequency and in response to obtaining the failure message from the above-mentioned failure message queue, add the above-mentioned failure message as a task message to the above-mentioned target task message queue.

[0120] In an optional implementation of some embodiments, the device 700 also includes: a third calling unit, configured to call a target task message queue processing thread in a thread pool corresponding to the target task message queue to process the task message in the target task message queue, wherein the target task message queue processing thread is used to call a business interface to consume the task message obtained from the target task message queue.

[0121] It is understood that the units described in the device 700 are similar to those described in the reference Figure 3 Therefore, the operations, features and beneficial effects described above for the method are also applicable to the device 700 and the units included therein, and will not be described in detail here.

[0122] Continue to refer Figure 8 As an implementation of the methods shown in the above figures, the present disclosure provides some embodiments of a thread pool parameter adjustment device. These device embodiments are similar to Figure 5 Corresponding to the method embodiments shown, the device can be specifically applied to various electronic devices.

[0123] like Figure 8 As shown, the thread pool parameter adjustment device 800 of some embodiments includes: a generation unit 801 and a replacement unit 802. The generation unit 801 is configured to generate a first thread pool parameter based on the thread pool parameters of the thread pool in response to determining that the rejection frequency of the thread pool for the received task message is greater than or equal to the preset rejection frequency, wherein the thread pool parameters of the thread pool include: the number of core threads, the maximum number of threads, and the blocking queue capacity; the replacement unit 802 is configured to replace the thread pool parameters stored in the local cache with the first thread pool parameters, wherein the thread pool parameters stored in the local cache are used in Figure 3 In some corresponding embodiments.

[0124] In an optional implementation of some embodiments, the device 800 further includes: a second thread pool parameter generating unit and a second thread pool parameter replacing unit. The second generating unit is configured to generate the second thread pool parameter based on the thread pool parameter of the thread pool in response to determining that the difference between the maximum number of threads included in the thread pool parameter of the thread pool and the total number of target task message queue processing threads in the thread pool satisfies a preset condition; and the second replacing unit replaces the thread pool parameter stored in the local cache with the second thread pool parameter.

[0125] In an optional implementation of some embodiments, the second thread pool parameter generation unit is further configured to determine the first maximum number of threads based on the preset maximum number of threads, the first preset adjustment ratio and the maximum number of threads included in the thread pool parameters of the above thread pool.

[0126] In an optional implementation of some embodiments, the second thread pool parameter generation unit is further configured to determine the first core thread number based on the second preset adjustment ratio and the first maximum number of threads.

[0127] In an optional implementation of some embodiments, the second thread pool parameter replacement unit is further configured to determine the second blocking queue capacity based on a third preset adjustment ratio, a preset blocking queue capacity and the blocking queue capacity included in the thread pool parameters of the above thread pool.

[0128] In an optional implementation of some embodiments, the second thread pool parameter replacement unit is further configured to determine a second maximum number of threads based on the first preset adjustment ratio, the preset maximum number of threads and the maximum number of threads included in the thread pool parameters of the thread pool.

[0129] In an optional implementation of some embodiments, the second thread pool parameter replacement unit is further configured to determine the second core thread number based on the second preset adjustment ratio and the second maximum thread number.

[0130] It is understood that the units described in the device 800 are similar to those described in the reference Figure 5 Therefore, the operations, features and beneficial effects described above for the method are also applicable to the device 800 and the units included therein, and will not be described in detail here.

[0131] Reference below Fig. 9 , which shows a structural schematic diagram of an electronic device 900 suitable for implementing some embodiments of the present disclosure. Fig. 9 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0132] like Fig. 9 As shown, the electronic device 900 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage device 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the electronic device 900 are also stored. The processing device 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.

[0133] Typically, the following devices may be connected to the I / O interface 905: an input device 906 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 907 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 909 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 909. The communication device 909 may allow the electronic device 900 to communicate with other devices wirelessly or by wire to exchange data. Although Fig. 9The electronic device 900 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead. Fig. 9 Each block shown in the figure may represent one device, or may represent multiple devices as required.

[0134] In particular, according to some embodiments of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, some embodiments of the present disclosure include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In some such embodiments, the computer program can be downloaded and installed from the network through the communication device 909, or installed from the storage device 908, or installed from the ROM 902. When the computer program is executed by the processing device 901, the above-mentioned functions defined in the method of some embodiments of the present disclosure are executed.

[0135] It should be noted that the computer-readable medium recorded in some embodiments of the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In some embodiments of the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In some embodiments of the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0136] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0137] The computer-readable medium may be included in the electronic device; or it may exist independently without being assembled into the electronic device. The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: in response to determining that the thread pool parameters of the local cache have changed, adjust the thread pool parameters of the thread pool corresponding to the target task message queue, wherein the thread pool is used to create and start the target task message queue processing thread; in response to determining that the task message in the target task message queue has been consumed successfully, delete the backup message that matches the successfully consumed task message from the backup message queue used to back up the task message in the target task message queue; in response to determining that the task message in the target task message queue has failed to be consumed, add the failed task message to the failed message queue as a failed message.

[0138] Computer program code for performing the operations of some embodiments of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0139] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0140] The units described in some embodiments of the present disclosure may be implemented by software or by hardware. The described units may also be provided in a processor, for example, may be described as: a processor including an adjustment unit, a deletion unit, a joining unit, and a pruning unit. Among them, the names of these units do not constitute a limitation on the unit itself in certain cases, for example, the joining unit may also be described as "a unit that, in response to determining that the consumption of a task message in the above-mentioned target task message queue has failed, adds the task message that has failed to be consumed as a failure message to the failure message queue".

[0141] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0142] The above descriptions are only some preferred embodiments of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the embodiments of the present disclosure is not limited to the technical solutions formed by a specific combination of the above-mentioned technical features, but should also cover other technical solutions formed by any combination of the above-mentioned technical features or their equivalent features without departing from the above-mentioned inventive concept. For example, the above-mentioned features are replaced with the technical features with similar functions disclosed in the embodiments of the present disclosure (but not limited to) and the technical solutions formed.

Claims

1. A message queue processing method, comprising: In response to determining that the thread pool parameters of the local cache have changed, adjusting the thread pool parameters of the thread pool corresponding to the target task message queue, wherein the thread pool is used to create and start the target task message queue processing thread; In response to determining that the target task message queue does not include a task message matching the received message, adding the received message as a task message to the target task message queue and adding the received message as a backup message to a backup message queue to prevent the task message dequeued from the target task message queue from being lost; In response to determining that the task message in the target task message queue is consumed successfully, deleting a backup message matching the successfully consumed task message from a backup message queue used to back up the task messages in the target task message queue; In response to determining that the task message in the target task message queue fails to be consumed, adding the task message that fails to be consumed as a failure message to the failure message queue; The backup message queue processing thread is called to add the backup message in the backup message queue as a task message to the target task message queue for processing.

2. The method according to claim 1, wherein: The method further comprises: The backup message queue processing thread is used to obtain backup messages from the backup message queue at a first preset frequency and, in response to obtaining backup messages from the backup message queue, add the obtained backup messages as task messages to the target task message queue.

3. The method according to claim 1, wherein: The method further comprises: The failure message queue processing thread is called to process the failure messages in the failure message queue, wherein the failure message queue processing thread is used to obtain failure messages from the failure message queue at a second preset frequency and in response to obtaining failure messages from the failure message queue, add the obtained failure messages as task messages to the target task message queue.

4. The method according to any one of claims 1 to 3, wherein: The method further comprises: The target task message queue processing thread in the thread pool corresponding to the target task message queue is called to process the task message in the target task message queue, wherein the target task message queue processing thread is used to call the business interface to consume the task message obtained from the target task message queue.

5. A thread pool parameter adjustment method, comprising: In response to determining that the rejection frequency of the thread pool for the received task message is greater than or equal to the preset rejection frequency, generating a first thread pool parameter based on the thread pool parameter of the thread pool, including: determining a first maximum number of threads based on a preset maximum number of threads, a first preset adjustment ratio, and the maximum number of threads included in the thread pool parameter of the thread pool, and determining a first core number of threads based on a second preset adjustment ratio and the first maximum number of threads, wherein the thread pool parameter of the thread pool includes: the number of core threads, the maximum number of threads, and the blocking queue capacity; Replacing the thread pool parameters stored in the local cache with the first thread pool parameters, wherein the thread pool parameters stored in the local cache are used in the method as claimed in claim 1; In response to determining that a difference between a maximum number of threads included in the thread pool parameters of the thread pool and a total number of target task message queue processing threads in the thread pool meets a preset condition, generating a second thread pool parameter based on the thread pool parameters of the thread pool; The thread pool parameters stored in the local cache are replaced by the second thread pool parameters.

6. The method according to claim 5, wherein: The generating of the second thread pool parameter based on the thread pool parameter of the thread pool comprises: The second blocking queue capacity is determined based on the third preset adjustment ratio, the preset blocking queue capacity, and the blocking queue capacity included in the thread pool parameters of the thread pool.

7. The method according to claim 6, wherein: The generating of the second thread pool parameter based on the thread pool parameter of the thread pool further includes: A second maximum number of threads is determined based on the first preset adjustment ratio, the preset maximum number of threads, and the maximum number of threads included in the thread pool parameters of the thread pool.

8. The method according to claim 7, wherein: The generating of the second thread pool parameter based on the thread pool parameter of the thread pool further includes: Based on the second preset adjustment ratio and the second maximum number of threads, a second number of core threads is determined.

9. A message queue processing device, comprising: An adjustment unit is configured to adjust the thread pool parameters of the thread pool corresponding to the target task message queue in response to determining that the thread pool parameters of the local cache have changed, wherein the thread pool is used to create and start the target task message queue processing thread; an execution unit, configured to, in response to determining that the target task message queue does not include a task message matching the received message, add the received message as a task message to the target task message queue and add the received message as a backup message to a backup message queue to prevent the task message dequeued from the target task message queue from being lost; a deleting unit configured to, in response to determining that the task message in the target task message queue is consumed successfully, delete a backup message matching the successfully consumed task message from a backup message queue used to back up the task messages in the target task message queue; An adding unit is configured to, in response to determining that the task message in the target task message queue fails to be consumed, add the task message that fails to be consumed as a failure message to the failure message queue; The calling unit is configured to call the backup message queue processing thread to add the backup message in the backup message queue as a task message to the target task message queue for processing.

10. A thread pool parameter adjustment device, comprising: A generating unit is configured to generate a first thread pool parameter based on the thread pool parameters of the thread pool in response to determining that the rejection frequency of the thread pool for the received task message is greater than or equal to a preset rejection frequency, including: determining a first maximum number of threads based on a preset maximum number of threads, a first preset adjustment ratio and the maximum number of threads included in the thread pool parameters of the thread pool, and determining a first core number of threads based on a second preset adjustment ratio and the first maximum number of threads, wherein the thread pool parameters of the thread pool include: the number of core threads, the maximum number of threads, and the capacity of a blocking queue; a first replacement unit, configured to replace the thread pool parameters stored in the local cache with the first thread pool parameters, wherein the thread pool parameters stored in the local cache are used in the method according to claim 1; A determining unit configured to generate a second thread pool parameter based on the thread pool parameter of the thread pool in response to determining that a difference between a maximum number of threads included in the thread pool parameter of the thread pool and a total number of target task message queue processing threads in the thread pool meets a preset condition; The second replacement unit is configured to replace the thread pool parameters stored in the local cache with the second thread pool parameters.

11. An electronic device, comprising: one or more processors; a storage device having one or more programs stored thereon, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 8.

12. A computer readable medium having a computer program stored thereon, wherein: When the program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Message processing method and device, electronic equipment and medium

    CN111381987A