Message queue management methods, management systems, and electronic devices

By setting up listening devices in the listening server and storage server, the system automatically switches from the slave message queue to the master message queue, solving the problem of low message queue read/write efficiency, achieving high availability and timeliness, reducing the difficulty of operation and maintenance, and making it suitable for short message service application scenarios.

CN114265753BActive Publication Date: 2025-10-28AGRICULTURAL BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111620821.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-27
Publication Date
2025-10-28
Estimated Expiration
2041-12-27

AI Technical Summary

Technical Problem

In existing technologies, message queues have low read and write efficiency, especially in distributed cluster deployment mode, where it is necessary to calculate and determine the message queues to be read and written, which leads to reduced efficiency. Furthermore, master-slave replication mode requires human intervention in fault recovery, which makes operation and maintenance difficult.

Method used

By setting up a listening server and multiple storage servers, the listening server includes multiple listening devices, and the storage servers store message queues for multiple business types. When the listening devices detect an anomaly in the main message queue, they automatically switch from the secondary message queue to the primary message queue, achieving high availability and timeliness, and automatically completing fault recovery.

Benefits of technology

It achieves high availability and timeliness in short message service application scenarios, reduces operation and maintenance costs, improves the efficiency of message queue management system, and supports message queue management with large transaction throughput and high timeliness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114265753B_ABST
    Figure CN114265753B_ABST
Patent Text Reader

Abstract

This application provides a message queue management method, management system, and electronic device. The message queue management system includes a listening server and multiple storage servers. The listening server includes multiple listening devices, and the storage servers store message queues of multiple business types. One business type corresponds to multiple message queues, and the multiple message queues are stored in different storage servers. The multiple message queues include a master message queue and multiple slave message queues. The message queue management method includes: when a first number of target listening devices among the multiple listening devices determine that a first master message queue is in an abnormal state, the listening server determines a target slave message queue from among the multiple slave message queues belonging to the same business type as the first master message queue; the listening server switches the target slave message queue to the target master message queue. This application can achieve high availability and timeliness of asynchronous communication services in short message service application scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a message queue management method, management system, and electronic device. Background Technology

[0002] With the rapid development of internet technology, the scale of messaging services has also expanded rapidly. As a system that directly faces users, SMS services have extremely high requirements for timeliness and accuracy, especially for transaction-related and verification code-related services, which directly affect user experience and various transaction processes. Message queues, as in-memory databases, have the characteristics of fast read and write speeds and support for persistence, which can effectively solve the problem of asynchronous communication in SMS services and ensure the timeliness, consistency, and integrity of data sent by the system.

[0003] Currently, message queues for SMS services mainly adopt a distributed cluster deployment mode. However, due to its scalability, distributed cluster deployment requires a series of calculations on the read and write requests of application clients to determine the message queues to be read and written, which leads to low read and write efficiency of message queues. Summary of the Invention

[0004] This application provides a message queue management method, management system, and electronic device to solve the problem of low read / write efficiency of message queues.

[0005] The first aspect of this application provides a message queue management method, applied to a message queue management system. The message queue management system includes: a listening server and multiple storage servers; the listening server includes multiple listening devices, and the storage servers store message queues of multiple business types, wherein one business type corresponds to multiple message queues, and the multiple message queues are stored in different storage servers. The multiple message queues include: a master message queue and multiple slave message queues. The message queue management method includes:

[0006] When a first number of target listening devices among multiple listening devices determine that the first main message queue is in an abnormal state, the listening server determines the target secondary message queue among multiple secondary message queues that belong to the same business type as the first main message queue, and the first number is greater than the first number threshold.

[0007] The listening server switches the target from the message queue to the target master message queue, which is used to respond to read and write operations from application clients.

[0008] In one embodiment of this application, the listening server determines a target slave message queue from among multiple slave message queues belonging to the same business type as the first master message queue, including:

[0009] The listening server determines the preset priority of multiple slave message queues that belong to the same business type as the first master queue;

[0010] The listening server determines the message queue with the highest preset priority as the target message queue.

[0011] In one embodiment of this application, the listening server determines a target slave message queue from among multiple slave message queues belonging to the same business type as the first master message queue, including:

[0012] The listening server determines the replication offsets of multiple slave message queues that belong to the same business type as the first master queue;

[0013] The listening server determines the message queue with the highest replication offset as the target message queue.

[0014] In one embodiment of this application, when a first number of target listening devices among a plurality of listening devices determine that the first master message queue is in an abnormal state, before the listening server determines the target slave message queue among a plurality of slave message queues belonging to the same service type as the first master message queue, the method further includes:

[0015] The listening device sends the first listening information to the first main message queue;

[0016] If the monitoring device does not receive a response from the first main message queue for the first monitoring information, the monitoring device determines that the first main message queue is in an abnormal state.

[0017] In one embodiment of this application, the plurality of listening devices include: a primary listening device and a secondary listening device. After the listening device determines that the first primary message queue has failed, it further includes:

[0018] The main listening device receives abnormal information from the first main message queue sent by each secondary listening device. The secondary listening devices are used to send abnormal information to the main listening device when they determine that the first main message queue is in an abnormal state.

[0019] The main monitoring device determines the first number of target monitoring devices based on the abnormal information, wherein the target monitoring devices are the monitoring devices that determine that the first main message queue is in an abnormal state.

[0020] In one embodiment of this application, the message queue management method further includes:

[0021] The secondary monitoring device sends a second monitoring message to the primary monitoring device;

[0022] If the secondary monitoring device does not receive a response from the primary monitoring device for the second monitoring information, the secondary monitoring device sends a switching request to other secondary monitoring devices. The switching request is used to switch the secondary monitoring device to the primary monitoring device.

[0023] If a secondary monitoring device receives a second number of response messages from other secondary monitoring devices, it will switch the secondary monitoring device to the primary monitoring device, provided that the second number is greater than a second threshold.

[0024] In one embodiment of this application, the message queue management method further includes:

[0025] The main listening device receives read / write requests for target messages sent by application clients;

[0026] The main listening device obtains the port address corresponding to the target main message queue, as well as the identification information of the storage server to which the target message queue belongs;

[0027] The master listening device sends the port address and identification information to the application client, so that the application client can perform corresponding read and write operations in the target message queue.

[0028] The second aspect of this application provides a message queue management system, including: a listening server and multiple storage servers; the listening server includes multiple listening devices, and the storage servers store message queues of multiple business types, wherein one business type corresponds to multiple message queues, the multiple message queues are stored in different storage servers, and the multiple message queues include: a master message queue and multiple slave message queues.

[0029] A listening server is used to determine a target secondary message queue from among multiple secondary message queues belonging to the same business type as the first primary message queue when a first number of target listening devices among multiple listening devices determine that the first primary message queue is in an abnormal state, and the first number is greater than a first number threshold; the target secondary message queue is switched to the target primary message queue, and the target primary message queue is used to respond to read and write operations of the application client.

[0030] In one embodiment of this application, the listening server is specifically used to: determine the preset priority of multiple slave message queues that belong to the same business type as the first master queue; and determine the slave message queue with the highest preset priority as the target slave message queue.

[0031] In one embodiment of this application, the listening server is specifically used to: determine the replication offset of multiple slave message queues that belong to the same business type as the first master queue; and determine the slave message queue with the highest replication offset as the target slave message queue.

[0032] In one embodiment of this application, the monitoring device is configured to send first monitoring information to a first main message queue; if the monitoring device does not receive a response from the first main message queue for the first monitoring information, it determines that the first main message queue is in an abnormal state.

[0033] In one embodiment of this application, the multiple listening devices include: a main listening device and a secondary listening device. The main listening device is used to receive abnormal information of a first main message queue sent by each secondary listening device. The secondary listening devices are used to send abnormal information to the main listening device when they determine that the first main message queue is in an abnormal state.

[0034] The main listening device is also used to determine a first number of target listening devices based on the abnormal information, wherein the target listening devices are the listening devices that determine that the first main message queue is in an abnormal state.

[0035] In one embodiment of this application, the secondary monitoring device is used to send second monitoring information to the primary monitoring device; if the secondary monitoring device does not receive a response from the primary monitoring device for the second monitoring information, it sends a switching request to other secondary monitoring devices, the switching request being used to switch the secondary monitoring device to the primary monitoring device; if the secondary monitoring device receives a second number of response messages from other secondary monitoring devices, it switches the secondary monitoring device to the primary monitoring device, the second number being greater than a second threshold.

[0036] In one embodiment of this application, the main listening device is further configured to: receive read / write requests for target messages sent by the application client; obtain the port address corresponding to the target main message queue and the identification information of the storage server to which the target message queue belongs; and send the port address and identification information to the application client so that the application client can perform corresponding read / write operations in the target message queue.

[0037] A third aspect of this application provides an electronic device, including a memory and a processor; wherein,

[0038] The memory is used to store program code;

[0039] The processor is used to call program code to implement the message queue management method of any of the above.

[0040] A fourth aspect of this application provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, an electronic device performs a message queue management method as described above.

[0041] The fifth aspect of this application provides a computer program product having a computer program stored thereon, wherein when the computer program is executed by a processor, an electronic device performs a message queue management method as described above.

[0042] As can be seen from the above technical solution, this application embodiment sets up a listening server and multiple storage servers. The listening server includes multiple listening devices, and the storage servers store message queues of multiple business types. One business type corresponds to multiple message queues, which are stored in different storage servers. The multiple message queues include a master message queue and multiple slave message queues. Furthermore, when a first number of target listening devices among the multiple listening devices determine that the first master message queue is in an abnormal state, the listening server determines a target slave message queue among the multiple slave message queues belonging to the same business type as the first master message queue, where the first number is greater than a first threshold. The listening server switches the target slave message queue to the target master message queue. The target master message queue is used to respond to read and write operations of the application client, achieving high availability and timeliness of asynchronous communication services in short message service application scenarios, and providing a management system for message queues that support high transaction throughput and high timeliness. Attached Figure Description

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

[0044] Figure 1 This is a schematic diagram illustrating an application scenario of the message queue management method provided in this application;

[0045] Figure 2 This is a structural block diagram of a message queue management system provided in an embodiment of this application;

[0046] Figure 3 This is a flowchart of the steps of a message queue management method provided in an embodiment of this application;

[0047] Figure 4 This is a flowchart of the steps of a message queue management method provided in another embodiment of this application;

[0048] Figure 5 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0049] To enable those skilled in the art to better understand the solutions of this application, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0050] In related technologies, message queue deployment modes are divided into single-instance mode, master-slave replication mode, and distributed cluster deployment mode. Single-instance mode is simple to deploy, but because only a single node provides data read / write (access) services and does not support data persistence and synchronous backup, it lacks automatic fault tolerance and recovery capabilities, making it suitable for caching scenarios with low data reliability requirements. Master-slave replication mode uses a multi-instance master-slave separation deployment model, which supports data persistence and read / write separation strategies compared to single-instance mode, enabling simultaneous data read / write services to application clients. However, although master-slave replication mode uses a multi-instance master-slave architecture, it requires manual switching of slave queue nodes to master queue nodes for message queue cluster fault recovery. The entire fault recovery process requires human intervention, is complex, and poses significant challenges for later maintenance.

[0051] Finally, while distributed cluster deployment offers horizontal scaling capabilities, the limited number of message queues and minimal scaling requirements in SMS applications render this feature ineffective. Furthermore, the computational process required to determine the message queues for read / write operations actually reduces overall message queue read / write efficiency. In contrast, distributed cluster deployment employs server sharding, treating the entire message cluster as a single entity. Application clients can connect to any message queue for operation, effectively addressing horizontal scaling and ensuring efficient and stable data read / write services under high concurrency. Distributed cluster deployment primarily addresses the expansion of distributed message queue clusters, utilizing consistent hashing algorithms to partition and map data in high-concurrency scenarios. It is suitable for applications with numerous message queue types and no strict distribution requirements, effectively achieving load balancing and reducing operational costs.

[0052] Furthermore, while the aforementioned technologies address potential performance issues related to message queue data backup, they also introduce new problems. For instance, the master-slave replication message queue deployment method requires specifying the IP address and port address of the master message queue. If the message queue connected to the application client fails to read or write normally, the user needs to manually modify the application client configuration to complete the master-slave message queue switchover. This manual intervention in message queue failure recovery significantly increases maintenance complexity. As for distributed cluster deployment solutions for SMS services, since SMS services involve fewer message queue categories and a centralized, fixed distribution, using a distributed cluster deployment method may result in multiple message queue categories being simultaneously distributed across the same server, reducing message queue read / write speeds.

[0053] To address the aforementioned issues, this application provides a message queue management method. This method involves setting up a listening server and multiple storage servers. The listening server includes multiple listening devices, and the storage servers store message queues for multiple business types. Each business type corresponds to multiple message queues, which are stored on different storage servers. The message queues include a master message queue and multiple slave message queues. When a first number of target listening devices determine that a first master message queue is in an abnormal state, the listening server identifies a target slave message queue from among the slave message queues belonging to the same business type as the first master message queue. The first number of target slave message queues exceeds a first threshold. The listening server then switches the target slave message queue to the target master message queue. The target master message queue is used to respond to read / write operations from application clients and to synchronize with other slave message queues. This achieves high availability and timeliness of asynchronous communication services in short message service application scenarios and provides a management system for message queues that support high transaction throughput and high timeliness.

[0054] Figure 1 This is a schematic diagram illustrating an application scenario of the message queue management method provided in this application. For example... Figure 1 As shown, this application scenario may include a user client 11 and a business platform 12. The business platform 12 is used to send short messages to the client 11. The message queue management method of this application is applied to the short message service scenario, enabling the business platform to send short messages to the user client 11 in real time and efficiently.

[0055] For example, business platform 12 is a financial platform. When a user transfers money on user client 11, they need to enter an SMS verification code to complete the transfer, so business platform 12 needs to send the SMS verification code to user client 11. Or, for example, if the user's balance changes after a successful transfer on user client 11, business platform 12 needs to send balance change information to the user client.

[0056] The technical solution of this application will now be described in detail through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.

[0057] Reference Figure 2 This is a schematic diagram of a message queue management system 22 provided in this application. The message queue management system includes: a listening server 221 and multiple storage servers 222; the listening server 221 includes multiple listening devices (listening device A to listening device E), and the storage servers (each of storage servers 1 to storage servers 4) store message queues of multiple business types, wherein one business type corresponds to multiple message queues, and the multiple message queues are stored in different storage servers. The multiple message queues include: a master message queue and multiple slave message queues.

[0058] For example, in Figure 2 In this context, the main message queue A and multiple slave message queues A correspond to the same business type, such as transaction activity. Transaction activity refers to situations where, after a user's current account balance changes, the application client 21 retrieves the corresponding change information from the main message queue A and sends it to the main message queue A. Figure 1 The user client 11. The main message queue B and multiple slave message queues B correspond to the same business type, such as SMS verification. In the SMS verification type, when a user needs to transfer money or make a purchase, the application client 21 retrieves the corresponding verification code from the main message queue B and sends it to the user. Figure 1 The user client 11. The main message queue C and multiple slave message queues C correspond to the same business type, such as a business query class. The business query class is as follows: Figure 1 The user client 11 shown Figure 2 The application client 21, as shown, sends a query request, and then the application client 21 retrieves the corresponding business information from the main message queue C and sends it to the client. Figure 1 The user client 11. The main message queue D and multiple slave message queues D correspond to the same business type, such as a business push class. The business push class refers to the application client periodically retrieving business information from the main message queue D and pushing that information to... Figure 1 User client 11 is shown.

[0059] Furthermore, different message queues of the same business type are stored on different storage servers, as shown in the reference. Figure 2For example, a primary message queue A of the same business type resides on storage server 1. A secondary message queue A resides on storage server 2, and another secondary message queue A resides on storage server 3. Furthermore, message queues within the same storage server may correspond to different business types. For instance, storage server 1 may have a primary message queue A, a secondary message queue C, and a secondary message queue D, where the primary message queue A, secondary message queue C, and secondary message queue D correspond to different business types.

[0060] In the embodiments of this application, reference is made to Figure 2 The business platform 12, such as a financial platform, includes an application client 21 and a message queue management system 22. The application client 21 is a server running the application, used to obtain corresponding information from the message queue management system 22 and send it to the application. Figure 1 The application client 11 shown.

[0061] Reference Figure 3 This is a flowchart illustrating the steps of a message queue management method provided in an embodiment of this application. The message queue management method is applied to... Figure 2 The message queue management system shown includes the following steps:

[0062] S301, when a first number of target listening devices among multiple listening devices determine that the first main message queue is in an abnormal state, the listening server determines the target secondary message queue among multiple secondary message queues that belong to the same business type as the first main message queue.

[0063] Wherein, the first quantity is greater than a first quantity threshold. The target is a message queue that is in a normal state. The first quantity threshold can be half of the total number of listening devices. For example, in Figure 2 If there are 5 listening devices, then the first quantity threshold is 2.5. Alternatively, the first quantity threshold can be set to other values, which are not limited here.

[0064] Furthermore, the total number of listening devices in the listening server is an odd number, for example, five.

[0065] In this embodiment of the application, each listening device can monitor the working status of each message queue, thereby determining whether each message queue is in an abnormal state. For example, refer to... Figure 2 If three of the listening devices A through E detect that the main message queue A is in an abnormal state, and none of the listening devices A through E detect that the two slave message queues A are in an abnormal state, then one of the two slave message queues A can be determined as the target slave message queue (the new main message queue).

[0066] S302, the listening server switches the target from the message queue to the target's main message queue.

[0067] The target main message queue is used to respond to read and write operations of application client 21.

[0068] Furthermore, the target primary message queue is the new primary message queue. The primary message queue is used for data read and write operations and for synchronizing data with the secondary message queues. The secondary message queues are used for data read operations and also serve as backup queues for backing up the data in the primary message queue.

[0069] The message queue management system provided in this application embodiment separates and alternately deploys the main message queue and slave message queues, which can support short message application scenarios with high throughput and high timeliness. It can ensure the timeliness, consistency, and integrity of data sent in the short message service. Furthermore, by setting up a monitoring device, it can monitor the faulty main message queue in real time and switch the fault-free slave message queue to become the new main message queue, ensuring the high availability and high reliability of the short message service.

[0070] Based on the above embodiments, this application provides another message queue management method, which can be found in the following details. Figure 4 This message queue management method is applied to Figure 2 The message queue management system shown includes the following steps:

[0071] S401, the listening device sends the first listening information to the first main message queue.

[0072] In this embodiment, any listening device can send a first listening message to any message queue (master message queue or slave message queue) to monitor whether the message queue is in an abnormal state. This first listening message can be TCP (Transmission Control Protocol).

[0073] Furthermore, the first main message queue can be any main message queue, see reference. Figure 2 It can be main message queue A, main message queue B, main message queue C, or main message queue D.

[0074] S402, if the monitoring device does not receive a response from the first main message queue for the first monitoring information, the monitoring device determines that the first main message queue is in an abnormal state.

[0075] For example, refer to Figure 2Listening device A sends a first listening message to main message queue A. If main message queue A does not respond to the first listening message, listening device A can determine that main message queue A is in an abnormal state. Furthermore, if main message queue A responds to the first listening message, listening device A can determine that main message queue A is in a normal state.

[0076] For example, using the above method, each listening device can monitor the status of the main message queue. If listening device A detects that the main message queue A is in an abnormal state, listening device B detects that the main message queue A is in an abnormal state, listening device C detects that the main message queue A is in a normal state, listening device D detects that the main message queue A is in an abnormal state, and listening device E detects that the main message queue A is in an abnormal state.

[0077] S403, the main monitoring device receives abnormal information from the first main message queue sent by each secondary monitoring device.

[0078] The multiple listening devices include a primary listening device and secondary listening devices. The secondary listening devices are used to send exception information to the primary listening device when the first primary message queue is determined to be in an abnormal state. Of the multiple listening devices, one is the primary listening device, and the others are secondary listening devices.

[0079] For example, refer to Figure 2 Listening device A is the main listening device, and listening devices B through E are secondary listening devices.

[0080] In this embodiment of the application, the master listening device is used to communicate with the application client 21 and to switch between master and slave message queues.

[0081] In addition, if the secondary listening device detects that the corresponding main message queue is in an abnormal state, it can send the abnormal information of the main message object to the main listening device. The abnormal information is used to indicate that the corresponding secondary listening device has detected that the main message queue is in an abnormal state.

[0082] For example, if the monitoring device B detects that the main message queue A is in an abnormal state, the monitoring device B sends an abnormal message to the main monitoring device (monitoring device A), which indicates that the monitoring device B has detected an abnormality in the main message queue A.

[0083] S404, the main monitoring device determines the first number of target monitoring devices based on the abnormal information.

[0084] The target listening device is the listening device that determines that the first main message queue is in an abnormal state.

[0085] For example, in Figure 2In the scenario where monitoring device A detects an abnormal state in main message queue A, monitoring device B detects an abnormal state in main message queue A, monitoring device C detects a normal state in main message queue A, and monitoring device D and E detect an abnormal state in main message queue A, then monitoring devices B, D, and E send abnormal information to monitoring device A (the main monitoring device). The main monitoring device (monitoring device A) itself also detects an abnormal state in main message queue A. Therefore, the target monitoring devices are: monitoring device A, monitoring device B, monitoring device D, and monitoring device E. Based on receiving 3 abnormal messages and detecting an abnormal state in the main message queue, the main monitoring device (monitoring device A) determines the first quantity to be 4.

[0086] It can be understood that the first quantity is determined by the second quantity of abnormal information received by the main listening device and the state (abnormal state or normal state) of the first main message queue detected by the main listening device. If the state of the first main message queue detected by the main listening device is abnormal, then the first quantity is the second quantity plus 1; if the state of the first main message queue detected by the main listening device is normal, then the first quantity is equal to the second quantity.

[0087] S405, when a first number of target listening devices among multiple listening devices determine that the first main message queue is in an abnormal state, the listening server determines the target secondary message queue among multiple secondary message queues that belong to the same business type as the first main message queue.

[0088] In this embodiment, the primary monitoring device specifically determines the target secondary message queue from multiple secondary message queues. The target secondary message queue is a secondary message queue in a normal state among the multiple secondary message queues. That is, in this embodiment, secondary message queues in an abnormal state can be filtered out first, and a target secondary message queue can be determined from the secondary message queues in a normal state.

[0089] For example, refer to Figure 2 For two message queues A, if more than a first quantity threshold number of listening devices from listening device A to listening device E determines that message queue A in storage server 2 is in an abnormal state, then message queue A in storage server 3 can be determined as the target message queue.

[0090] In one alternative approach, the listening server determines the target slave message queue from among multiple slave message queues belonging to the same business type as the first master message queue. This includes: the listening server determining the preset priority of the multiple slave message queues belonging to the same business type as the first master message queue; and the listening server determining the slave message queue with the highest preset priority as the target slave message queue.

[0091] For example, refer to Figure 2If the listening server 221 determines that both message queues A are in a normal state, then the preset priority of the two message queues A can be determined. If the preset priority of message queue A in storage server 2 is greater than the preset priority of message queue A in storage server 3, then message queue A in storage server 3 is determined as the target message queue.

[0092] In this embodiment, a higher-priority secondary message queue is used for data read operations and data persistence operations. This allows for better preservation of data in the message queue in the event of a power outage or other disruption to the message queue management system, facilitating subsequent recovery operations. Therefore, when the primary message queue fails, the higher-priority secondary message queue can be used as the new primary message queue.

[0093] In another alternative approach, the listening server determines the target slave message queue from among multiple slave message queues belonging to the same business type as the first master message queue. This includes: the listening server determining the replication offset of multiple slave message queues belonging to the same business type as the first master message queue; and the listening server determining the slave message queue with the highest replication offset as the target slave message queue.

[0094] In this embodiment, the target slave message queue can be determined based on its replication offset, even without pre-setting a preset priority for each slave message queue, or when multiple slave message queues have the same preset priority. A larger replication offset indicates newer data being synchronized in the slave message queue, and a greater likelihood that the slave message queue will be switched to the master message queue.

[0095] Furthermore, if the replication offsets of each slave message queue are the same, the replication offset can be determined based on the ID (identity number) of the storage server to which each slave message queue belongs. The larger the ID, the newer the storage server to which the corresponding slave message queue belongs, and therefore the greater the possibility of switching the slave message queue to the master message queue.

[0096] In this embodiment, the above method can be a progressive process. First, a slave message queue in a normal state is determined from multiple slave message queues. Then, a slave message queue with a higher preset priority is determined from the slave message queues in a normal state. If there are multiple slave message queues with higher preset priorities, and these multiple slave message queues have the same preset priority, then a slave message queue with a larger replication offset is determined from these multiple slave message queues. If there are multiple slave message queues with larger replication offsets, and these multiple slave message queues with larger replication offsets have the same replication offset, then the slave message queue corresponding to the one with the larger storage server ID is determined as the target slave message queue. This process ultimately determines an optimal target slave message queue.

[0097] S406, the listening server switches the target from the message queue to the target's main message queue.

[0098] The specific implementation process of this step is the same as step S302, and is not limited here. It should be noted that the execution entity that switches the target from the message queue to the target's main message queue can be the main listening device.

[0099] S407, the secondary listening device sends a second listening message to the primary listening device.

[0100] For example, each of the secondary listening devices (listening device B to listening device E) sends a second listening message to listening device A (the primary listening device).

[0101] S408, if the secondary monitoring device does not receive a response from the primary monitoring device for the second monitoring information, the secondary monitoring device sends a switching request to other secondary monitoring devices. The switching request is used to switch the secondary monitoring device to the primary monitoring device.

[0102] For example, if monitoring device B does not receive a response from monitoring device A, monitoring device B can send handover request messages to monitoring devices C, D, and E respectively. Monitoring devices C, D, and E, if they do not receive a response from monitoring device A, will also send handover request messages to other secondary monitoring devices besides themselves.

[0103] S409, if the secondary monitoring device receives response information from a second number of other secondary monitoring devices, then the secondary monitoring device is switched to the primary monitoring device.

[0104] The second quantity is greater than the second quantity threshold. Furthermore, the response information sent by other secondary monitoring devices to this secondary monitoring device may be sent even if the primary monitoring device has not received any response regarding the second monitoring information.

[0105] For example, if monitoring device B does not receive a response from monitoring device A, monitoring device B can send a switching request to monitoring devices C, D and E respectively. Monitoring device C also does not receive a response from monitoring device A, and after receiving the switching request from monitoring device B, it sends a response to the switching request to monitoring device B.

[0106] Furthermore, if monitoring device C sends a switch request to other monitoring devices after not receiving a response from monitoring device A, and only then receives a switch request from monitoring device B, then monitoring device C may choose not to send a response to monitoring device B.

[0107] The purpose of this step is to identify the secondary listening device that first detected the anomaly of the primary listening device, and then designate that secondary listening device as the new primary listening device to perform the functions corresponding to the primary listening device.

[0108] In this embodiment of the application, the second quantity threshold can be half of the total number of listening devices minus 1.

[0109] S410, the main listening device receives read / write requests for target messages sent by the application client.

[0110] In this embodiment of the application, the main monitoring device is responsible for switching the corresponding message queue to the main message queue when the main message queue is in an abnormal state, such as when it crashes, thereby realizing the automatic recovery of message queue failure. This can effectively reduce the operating cost of short message service and improve the efficiency of the overall message queue management system.

[0111] S411, the main listening device obtains the port address corresponding to the target main message queue, as well as the identification information of the storage server to which the target message queue belongs.

[0112] In this embodiment, the identification information of the storage server refers to its IP address (Internet Protocol address). Each message queue corresponds to a port address. The main listening device can obtain the port address and storage server identification information of any message queue, and can locate the corresponding message queue based on the port address and identification information.

[0113] S412, the master listening device sends the port address and identification information to the application client so that the application client can perform corresponding read and write operations in the target message queue.

[0114] In this embodiment of the application, sending the port address and identification information to the application client enables the application client to connect to the correct main message queue, thereby ensuring the stability of the data read and write service.

[0115] In this embodiment, the application client can connect to any listening device on the listening server to obtain the status (abnormal or normal) of the master and slave message queues on the storage server. The application client can also connect to the master listening device to obtain the status of the master and slave message queues on the storage server. When the master message queue fails and goes offline, the application client can promptly obtain the abnormal status of the problematic master message queue on the storage server, thereby completing the automatic failover operation of the master and slave message queues. It then sends the port address of the new master message queue after the failure is resolved, along with the IP address of its storage server, to the client application, ensuring that the client application can always connect to the normal master message queue. The clustered listening devices not only enable timely monitoring of the status of the master and slave message queues but also ensure the high availability of the listening server. When one listening device on the listening server fails and goes offline, the other listening devices can still operate normally, thus ensuring the stable operation of the message queue management system.

[0116] Furthermore, the message queue management system in this embodiment can support short message sending scenarios with high transaction throughput and high peak values ​​for short message services with a relatively fixed and concentrated number of service types, thereby improving the overall efficiency of the message queue management system.

[0117] Reference Figure 2 This is a schematic diagram of a message queue management system 22 provided in an embodiment of this application. The message queue management system 22 includes:

[0118] The system includes a listening server 221 and multiple storage servers 222. The listening server 221 includes multiple listening devices, and the storage servers (any one of storage servers 1 to 4) store message queues of multiple business types. Each business type corresponds to multiple message queues, and the multiple message queues are stored on different storage servers. The multiple message queues include a master message queue and multiple slave message queues.

[0119] Listening server 221: When a first number of target listening devices among multiple listening devices determine that the first main message queue is in an abnormal state, it determines a target secondary message queue among multiple secondary message queues belonging to the same business type as the first main message queue, and the first number is greater than a first number threshold; the listening server switches the target secondary message queue to the target main message queue, and the target main message queue is used to respond to the read and write operations of the application client.

[0120] In one embodiment of this application, the listening server 221 is specifically used to: determine the preset priority of multiple slave message queues that belong to the same business type as the first master queue; and determine the slave message queue with the highest preset priority as the target slave message queue.

[0121] In one embodiment of this application, the listening server 221 is specifically configured to: determine the replication offset of multiple slave message queues that belong to the same business type as the first master queue; and determine the slave message queue with the highest replication offset as the target slave message queue.

[0122] In one embodiment of this application, the monitoring device is configured to send first monitoring information to a first main message queue; if the monitoring device does not receive a response from the first main message queue for the first monitoring information, it determines that the first main message queue is in an abnormal state.

[0123] In one embodiment of this application, the multiple listening devices include: a main listening device and a secondary listening device. The main listening device is used to receive abnormal information of a first main message queue sent by each secondary listening device. The secondary listening devices are used to send abnormal information to the main listening device when they determine that the first main message queue is in an abnormal state.

[0124] The main listening device is also used to determine a first number of target listening devices based on the abnormal information, wherein the target listening devices are the listening devices that determine that the first main message queue is in an abnormal state.

[0125] In one embodiment of this application, the secondary monitoring device is used to send second monitoring information to the primary monitoring device; if the secondary monitoring device does not receive a response from the primary monitoring device for the second monitoring information, it sends a switching request to other secondary monitoring devices, the switching request being used to switch the secondary monitoring device to the primary monitoring device; if the secondary monitoring device receives a second number of response messages from other secondary monitoring devices, it switches the secondary monitoring device to the primary monitoring device, the second number being greater than a second threshold.

[0126] In one embodiment of this application, the main listening device is further configured to: receive read / write requests for target messages sent by the application client; obtain the port address corresponding to the target main message queue and the identification information of the storage server to which the target message queue belongs; and send the port address and identification information to the application client so that the application client can perform corresponding read / write operations in the target message queue.

[0127] For details on the specific workings of each module in the message queue management system, please refer to the implementation details of the message queue management method described above; these details will not be repeated here.

[0128] It should be noted that the division of the various modules in the above device is merely a logical functional division. In actual implementation, they can be fully or partially integrated into a single physical entity, or they can be physically separated. Furthermore, these modules can be implemented entirely in software via processing element calls; they can be fully implemented in hardware; or some modules can be implemented by processing element calls to software, while others are implemented in hardware. For example, a processing module can be a separate processing element, or it can be integrated into a chip within the device. Alternatively, it can be stored as program code in the device's memory, and its functions can be called and executed by a processing element. The implementation of other modules is similar. Moreover, these modules can be fully or partially integrated together, or they can be implemented independently. The processing element here can be an integrated circuit with signal processing capabilities. During implementation, each step of the above method or each of the above modules can be completed through integrated logic circuits in the hardware of the processor element or through software instructions.

[0129] For example, these modules can be one or more integrated circuits configured to implement the above methods, such as one or more application-specific integrated circuits (ASICs), one or more digital signal processors (DSPs), or one or more field-programmable gate arrays (FPGAs). As another example, when a module is implemented using processing element scheduler code, the processing element can be a general-purpose processor, such as a central processing unit (CPU) or other processor capable of calling program code. Furthermore, these modules can be integrated together to implement a system-on-a-chip (SOC).

[0130] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the flow or function according to the embodiments of this application is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., a solid-state disk (SSD)).

[0131] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Specifically, this electronic device can be a bank server or a blockchain platform. Figure 5 As shown, the electronic device may include: a processor 51, a memory 52, a communication interface 53, and a system bus 54. The memory 52 and the communication interface 53 are connected to the processor 51 via the system bus 54 and communicate with each other. The memory 52 stores computer-executed instructions, and the communication interface 53 communicates with other devices. When the processor 51 executes the aforementioned computer-executed instructions, it implements the scheme described in the above embodiment.

[0132] Should Figure 5The system bus mentioned can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This system bus can be divided into address bus, data bus, control bus, etc. For ease of representation, only one thick line is used in the diagram, but this does not indicate that there is only one bus or one type of bus. The communication interface is used to enable communication between the database access device and other devices (e.g., clients, read-write libraries, and read-only libraries). Memory may include random access memory (RAM) and may also include non-volatile memory, such as at least one disk storage device.

[0133] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0134] Optionally, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, causes the electronic device to perform the above-described actions. Figures 2 to 3 The method of the illustrated embodiment.

[0135] Optionally, embodiments of this application also provide a computer program product, on which a computer program is stored. When the computer program is executed by a processor, it causes the electronic device to perform the above-mentioned functions. Figures 2 to 3 The method of the illustrated embodiment.

[0136] In this application, "at least one" means one or more, and "more than one" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates an "or" relationship between the preceding and following related objects; in formulas, the character " / " indicates a "division" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.

[0137] It is understood that the various numerical designations used in the embodiments of this application are merely for descriptive convenience and are not intended to limit the scope of the embodiments of this application. In the embodiments of this application, the order of the above-mentioned process numbers does not imply the order of execution; the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0138] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

Claims

1. A message queue management method, characterized in that, An application is made to a message queue management system, which includes a listening server and multiple storage servers. The listening server includes multiple listening devices, and the storage servers store message queues of multiple business types, wherein one business type corresponds to multiple message queues. These multiple message queues are stored on different storage servers, and each message queue includes a master message queue and multiple slave message queues. The message queue management method includes: When a first number of target listening devices among the plurality of listening devices determine that the first main message queue is in an abnormal state, the listening server determines a target secondary message queue among a plurality of secondary message queues that belong to the same business type as the first main message queue, wherein the first number is greater than a first number threshold. The listening server switches the target from the message queue to the target main message queue, which is used to respond to read and write operations of the application client. The listening server determines the target slave message queue from among multiple slave message queues belonging to the same business type as the first master message queue, including: The listening server determines the preset priority of multiple slave message queues that belong to the same business type as the first master queue; The listening server determines the message queue with the highest preset priority as the target message queue; The listening server determines the target slave message queue from among multiple slave message queues belonging to the same business type as the first master message queue, including: The listening server determines the replication offsets of multiple slave message queues that belong to the same business type as the first master queue; The listening server determines the slave message queue with the highest replication offset as the target slave message queue.

2. The message queue management method according to claim 1, characterized in that, When a first number of target listening devices among the plurality of listening devices determine that the first master message queue is in an abnormal state, before the listening server determines the target slave message queue among the plurality of slave message queues belonging to the same business type as the first master message queue, the method further includes: The monitoring device sends the first monitoring information to the first main message queue; If the monitoring device does not receive a response from the first main message queue for the first monitoring information, the monitoring device determines that the first main message queue is in an abnormal state.

3. The message queue management method according to claim 2, characterized in that, The plurality of listening devices includes: a primary listening device and a secondary listening device. After the listening device determines that the first primary message queue is faulty, it further includes: The main monitoring device receives exception information of the first main message queue sent by each of the secondary monitoring devices. The secondary monitoring devices are used to send the exception information to the main monitoring device when they determine that the first main message queue is in an abnormal state. The main monitoring device determines a first number of target monitoring devices based on the abnormal information, wherein the target monitoring devices are monitoring devices that determine that the first main message queue is in an abnormal state.

4. The message queue management method according to claim 3, characterized in that, Also includes: The secondary monitoring device sends a second monitoring message to the primary monitoring device; If the secondary monitoring device does not receive a response from the primary monitoring device for the second monitoring information, the secondary monitoring device sends a switching request to other secondary monitoring devices. The switching request is used to switch the secondary monitoring device to the primary monitoring device. If the secondary monitoring device receives response information from a second number of other secondary monitoring devices, then the secondary monitoring device is switched to the primary monitoring device, where the second number is greater than a second threshold number.

5. The message queue management method according to claim 4, characterized in that, Also includes: The main monitoring device receives read / write requests for target messages sent by the application client; The main listening device obtains the port address corresponding to the target main message queue, as well as the identification information of the storage server to which the target message queue belongs; The main listening device sends the port address and the identification information to the application client, so that the application client can perform corresponding read and write operations in the target message queue.

6. A message queue management system, characterized in that, include: The system includes a listening server and multiple storage servers. The listening server includes multiple listening devices, and the storage servers store message queues for multiple business types. Each business type corresponds to multiple message queues, and the multiple message queues are stored on different storage servers. The multiple message queues include a master message queue and multiple slave message queues. The monitoring server is configured to, when a first number of target monitoring devices among the plurality of monitoring devices determine that the first main message queue is in an abnormal state, identify a target secondary message queue among a plurality of secondary message queues belonging to the same business type as the first main message queue, wherein the first number is greater than a first number threshold; the monitoring server switches the target secondary message queue to the target main message queue, wherein the target main message queue is used to respond to read and write operations of the application client; The listening server is specifically used to determine the preset priority of multiple slave message queues that belong to the same business type as the first master queue; and to determine the slave message queue with the highest preset priority as the target slave message queue. The listening server is specifically used to determine the replication offset of multiple slave message queues that belong to the same business type as the first master queue; and to determine the slave message queue with the highest replication offset as the target slave message queue.

7. An electronic device, characterized in that, Includes memory and processor; among which, The memory is used to store program code; The processor is used to call the program code to implement the message queue management method as described in any one of claims 1 to 5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it causes the electronic device to perform the message queue management method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Monitoring fault processing method, monitoring fault processing device, storage medium and electronic equipment

    CN107896172A

  • Distributed data cache management method, device and equipment and storage medium

    CN112039979A