A method and device for sending MQ multi-instance messages

By configuring multiple MQ queue manager groups and exception handling mechanisms, the unavailability problem of MQ single instance architecture in the event of failure is solved, the high availability of MQ multi-instance and the reliability of message sending is realized, and the hard requirements of the production environment are met. And reduce development costs.

CN113961372BActive Publication Date: 2024-11-19BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111247686.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-26
Publication Date
2024-11-19
Estimated Expiration
2041-10-26

AI Technical Summary

Technical Problem

The traditional MQ single instance architecture is unavailable when a failure occurs, resulting in unreliable message sending and lack of high availability solutions.

Method used

By configuring multiple MQ queue managers to join the manager group, select the list of available queue managers and cache them, monitor the message sending results, and replace the new queue manager with resend messages in abnormal situations to achieve high availability of MQ multiple instances.

Benefits of technology

It realizes high availability management for multiple MQ instances, reduces development intrusion, meets the hard high availability requirements in the production environment, and has low application transformation costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113961372B_ABST
    Figure CN113961372B_ABST
Patent Text Reader

Abstract

The present invention provides an MQ multi-instance message sending method and device, which belongs to big data. The method includes: configuring multiple MQ queue managers to join an MQ queue manager group; when an application system sends a message, selecting an MQ queue manager through the MQ queue manager group, determining an available MQ queue manager list and caching it; receiving a message sent by the application system through an MQ queue, selecting an MQ queue manager from the cache using the MQ queue manager group, and sending the message to a corresponding channel through the selected MQ queue manager; monitoring the message sending result, and when the message sending is abnormal, replacing a new MQ queue manager according to an exception handling mechanism to resend the message. The present invention manages multiple MQ instances uniformly from an application perspective, provides a high-availability solution for MQ multi-instances, and implements the configuration and message sending of multiple MQ queue managers.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer data processing, and in particular to a MQ multi-instance message sending method and device. Background Art

[0002] This section is intended to provide a background or context to embodiments of the invention that are recited in the claims. No description herein is admitted to be prior art by inclusion in this section.

[0003] MQ (IBM Message Queue) is an existing commercial message middleware product suitable for distributed computing environments or heterogeneous systems. Message queue technology is a technology for exchanging information between distributed applications. Message queues can reside in memory or on disk, and queues store messages until they are read by applications. With message queues, applications can execute independently - they do not need to know each other's location or wait for the receiving program to receive the message before continuing to execute.

[0004] In the traditional application architecture, MQ adopts single-point deployment, such as Figure 2 As shown in the MQ single instance architecture diagram in the prior art, when an application system sends a message, it needs to go through a queue. The queue sends the message to a specified channel according to the configured single queue manager, which has the risk of being unavailable after a failure.

[0005] Therefore, how to provide a new solution that can solve the above technical problems is a technical problem that needs to be solved urgently in this field. Summary of the invention

[0006] An embodiment of the present invention provides an MQ multi-instance message sending method. The present invention manages multiple MQ instances in a unified manner from an application perspective, provides a high-availability solution for MQ multi-instances, and implements the configuration and message sending of multiple MQ queue managers. The method includes:

[0007] Configure multiple MQ queue managers to join the MQ queue manager group;

[0008] When the application system sends a message, the MQ queue manager is selected through the MQ queue manager group, and the list of available MQ queue managers is determined and cached;

[0009] Receive messages from the application system through the MQ queue, select an MQ queue manager from the cache using the MQ queue manager group, and send the message to the corresponding channel through the selected MQ queue manager;

[0010] Monitor the message sending results. When message sending is abnormal, replace the new MQ queue manager according to the exception handling mechanism and resend the message.

[0011] The embodiment of the present invention further provides an MQ multi-instance message sending device, comprising:

[0012] MQ queue manager configuration module, used to configure multiple MQ queue managers to join the MQ queue manager group;

[0013] The module for determining the list of available MQ queue managers is used to select an MQ queue manager through the MQ queue manager group when a message is sent from the application system, determine the list of available MQ queue managers and cache it;

[0014] MQ multi-instance scheduling module, used to receive messages from the application system through the MQ queue, select an MQ queue manager from the cache using the MQ queue manager group, and send the message to the corresponding channel through the selected MQ queue manager;

[0015] The abnormal message processing and resending module is used to monitor the message sending results. When the message sending is abnormal, a new MQ queue manager is replaced according to the abnormal processing mechanism to resend the message.

[0016] An embodiment of the present invention further provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned MQ multi-instance message sending method when executing the computer program.

[0017] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program for executing the above-mentioned MQ multi-instance message sending method.

[0018] An MQ multi-instance message sending method and device provided by an embodiment of the present invention comprises: first configuring multiple MQ queue managers to join an MQ queue manager group; then when an application system sends a message, selecting an MQ queue manager through the MQ queue manager group, determining an available MQ queue manager list and caching it; next, receiving a message sent by the application system through an MQ queue, selecting an MQ queue manager from the cache using the MQ queue manager group, and sending the message to a corresponding channel through the selected MQ queue manager; finally monitoring the message sending result, and when the message sending is abnormal, replacing a new MQ queue manager according to an exception handling mechanism to resend the message. The present invention manages multiple MQ instances uniformly from an application perspective, provides a high-availability solution for MQ multi-instances, and implements the configuration and message sending of multiple MQ queue managers. By joining the MQ queue manager group, multiple MQ queue managers are scheduled and managed, and an exception handling mechanism is introduced under abnormal circumstances; a high-availability mechanism for multiple MQ instances is implemented, and an exception handling mechanism is designed for exceptions in the message sending process; the rigid requirements for MQ high availability in the production environment are met, and the intrusion to development is relatively low. Development only needs to configure the MQ queue management group, which is implemented through the underlying framework, and the application transformation cost is low. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0020] Figure 1 The present invention is a schematic diagram of an MQ multi-instance message sending method according to an embodiment of the present invention.

[0021] Figure 2 This is a diagram of the MQ single instance architecture in the prior art.

[0022] Figure 3 The present invention provides an MQ multi-instance architecture diagram of an MQ multi-instance message sending method according to an embodiment of the present invention.

[0023] Figure 4 The present invention provides a flowchart of a scheduling mechanism of a queue manager group in a method for sending MQ multi-instance messages according to an embodiment of the present invention.

[0024] Figure 5 The present invention is a schematic diagram of an abnormal message processing and resending process of an MQ multi-instance message sending method according to an embodiment of the present invention.

[0025] Figure 6The present invention is a flowchart of an abnormal rotation mechanism of an MQ multi-instance message sending method according to an embodiment of the present invention.

[0026] Figure 7 A schematic diagram of a computer device for running an MQ multi-instance message sending method implemented by the present invention.

[0027] Figure 8 The present invention is a schematic diagram of an MQ multi-instance message sending device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0028] To make the purpose, technical solution and advantages of the embodiments of the present invention more clear, the embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings. Here, the exemplary embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.

[0029] The present invention relates to big data technology. Figure 1 FIG. 1 is a schematic diagram of a method for sending a multi-instance MQ message according to an embodiment of the present invention. Figure 1 As shown, an embodiment of the present invention provides an MQ multi-instance message sending method. The present invention manages multiple MQ instances in a unified manner from an application perspective, provides a high-availability solution for MQ multi-instances, and implements the configuration and message sending of multiple MQ queue managers. The method includes:

[0030] Step 101: Configure multiple MQ queue managers to join the MQ queue manager group;

[0031] Step 102: When the application system sends a message, an MQ queue manager is selected through the MQ queue manager group, and a list of available MQ queue managers is determined and cached;

[0032] Step 103: Receive the message sent by the application system through the MQ queue, select an MQ queue manager from the cache using the MQ queue manager group, and send the message to the corresponding channel through the selected MQ queue manager;

[0033] Step 104: Monitor the message sending result. When the message sending is abnormal, replace the new MQ queue manager according to the exception handling mechanism to resend the message.

[0034] An MQ multi-instance message sending method provided by an embodiment of the present invention comprises: first configuring multiple MQ queue managers to join an MQ queue manager group; then when an application system sends a message, selecting an MQ queue manager through the MQ queue manager group, determining an available MQ queue manager list and caching it; next, receiving the message sent by the application system through the MQ queue, selecting an MQ queue manager from the cache using the MQ queue manager group, and sending the message to the corresponding channel through the selected MQ queue manager; finally monitoring the message sending result, and when the message sending is abnormal, replacing a new MQ queue manager according to the exception handling mechanism to resend the message. The present invention manages multiple MQ instances uniformly from the application perspective, provides a high-availability solution for MQ multi-instances, and implements the configuration and message sending of multiple MQ queue managers. By joining the MQ queue manager group, multiple MQ queue managers are scheduled and managed, and an exception handling mechanism is introduced under abnormal circumstances; a high-availability mechanism for multiple MQ instances is implemented, and an exception handling mechanism is designed for exceptions in the message sending process; the rigid requirements for MQ high availability in the production environment are met, and the intrusion to development is relatively low. Development only needs to configure the MQ queue management group, which is implemented by the underlying framework, and the application transformation cost is low.

[0035] In the embodiments of the present invention, the professional terms involved are as follows:

[0036] Message: In MQ, the data that the application sends to MQ for transmission is defined as a message. The content of the message can be defined and the message can be understood in a broad sense. For example, various types of user data files, processing requests sent by an application to other applications, etc. can all be used as messages. A message consists of two parts: a message descriptor, which describes the characteristics of the message, such as the priority, life cycle, message ID, etc. of the message; and a message body, which is the user data part. In MQ, messages are divided into two types, non-permanent messages and permanent messages. Non-permanent messages are stored in memory and are designed to improve performance. When the system loses power or the MQ queue manager is restarted, they will not be recoverable. Permanent messages are stored on the hard disk. They are highly reliable and can ensure that messages are not lost or duplicated in the event of network and system failures.

[0037] Queue: A queue is a container for storing messages.

[0038] Queue manager: Queue manager is the top-level concept in the MQ system, which provides queue-based message services.

[0039] Figure 3 FIG. 1 is an MQ multi-instance architecture diagram of an MQ multi-instance message sending method according to an embodiment of the present invention, such as Figure 3As shown, when the application system connects to multiple MQ instances, it needs to configure a queue, and multiple corresponding queue managers need to be configured in the queue. The queue manager configures the IP address, port, channel and other information of the MQ instance. When the application system sends a message, it needs to go through the queue, use the MQ queue manager group to manage the configured multiple MQ queue managers, and send the message to the specified channel. When implementing a method for sending a message of multiple MQ instances provided by an embodiment of the present invention, in one embodiment, it may include:

[0040] Configure multiple MQ queue managers to join the MQ queue manager group;

[0041] When the application system sends a message, the MQ queue manager is selected through the MQ queue manager group, and the list of available MQ queue managers is determined and cached;

[0042] Receive messages from the application system through the MQ queue, select an MQ queue manager from the cache using the MQ queue manager group, and send the message to the corresponding channel through the selected MQ queue manager;

[0043] Monitor the message sending results. When message sending is abnormal, replace the new MQ queue manager according to the exception handling mechanism and resend the message.

[0044] The present invention realizes the configuration of multiple queue managers and message sending through applications. After adopting the solution of the embodiment of the present invention, the application system still uses the configured queue to send messages, but multiple MQ queue managers are configured internally. The queue can judge whether the currently connected queue manager is valid according to the sending status of the message. If it is in an invalid state, the queue will select another queue manager to resend the message. It meets the rigid requirements for high availability of MQ in the production environment, and is relatively less invasive to development. Development only needs to configure the MQ queue management group, which is implemented through the underlying framework, and the application transformation cost is low.

[0045] When implementing a MQ multi-instance message sending method provided by an embodiment of the present invention, in one embodiment, multiple MQ queue managers are configured to join an MQ queue manager group, including: to ensure the high availability of MQ multi-instances, the original MQ queue is transformed and an MQ queue manager group is added, and each queue manager is managed by the queue manager group. By configuring multiple MQ queue managers to join the MQ queue manager group, multiple MQ queue managers are first configured as a basis for subsequent selection of MQ queue managers.

[0046] When implementing an MQ multi-instance message sending method provided by an embodiment of the present invention, in one embodiment, when an application system sends a message, an MQ queue manager is selected through an MQ queue manager group, and a list of available MQ queue managers is determined and cached, including:

[0047] When the application system sends a message, the selection action is triggered, and the MQ queue manager is selected through the MQ queue manager group according to the message, and the list of available MQ queue managers is determined and cached; in the cache, the list of available MQ queue managers is stored; among them, the MQ queue managers in the list of available MQ queue managers can be increased or decreased, and their number control is achieved through the MQ queue manager group.

[0048] Figure 4 The flowchart of the scheduling mechanism of the queue manager group of the MQ multi-instance message sending method according to the embodiment of the present invention is as follows: Figure 4 As shown, when a method for sending a MQ multi-instance message provided by an embodiment of the present invention is specifically implemented, in one embodiment, an MQ queue manager group is used to select an MQ queue manager from a cache, and the message is sent to a corresponding channel through the selected MQ queue manager, including:

[0049] Use the MQ queue manager group to find the list of available MQ queue managers from the cache;

[0050] When there is an available MQ queue manager list in the cache, an MQ queue manager is selected from the available MQ queue manager list, and the message is sent to the corresponding channel through the selected MQ queue manager.

[0051] In the embodiment, firstly, a message sent by the application system is received through the MQ queue, and the MQ queue manager group is used to search the available MQ queue manager list from the cache.

[0052] When a MQ queue manager is randomly selected from the list of available MQ queue managers, the message is sent to the selected MQ queue manager.

[0053] The MQ queue manager is sent to the corresponding channel. The present invention schedules and manages the MQ multi-queue manager by adding a queue manager group.

[0054] Further, such as Figure 4 As shown, when a method for sending a MQ multi-instance message provided by an embodiment of the present invention is specifically implemented, in one embodiment, the method further includes:

[0055] When there is no available MQ queue manager list in the cache, select an MQ queue manager from multiple MQ queue managers configured in the MQ queue manager group, and send the message to the corresponding channel through the selected MQ queue manager;

[0056] When the message is sent successfully, the selected MQ queue manager is added to the list of available MQ queue managers and cached.

[0057] In an embodiment, when the MQ queue manager group is used to search for the available MQ queue manager list from the cache, if the available MQ queue manager list does not exist in the cache, it is necessary to randomly select an MQ queue manager from multiple MQ queue managers configured in the MQ queue manager group, and send the message to the corresponding channel through the selected MQ queue manager; monitor the message sending result, and when the message is sent successfully, add the selected MQ queue manager to the available MQ queue manager list and cache it, so as to realize dynamic changes of the available MQ queue manager list and ensure that the MQ queue managers in the available MQ queue manager list are available at any time.

[0058] From a development perspective, technicians need to configure multiple MQ queue managers and add them to the MQ queue manager group. The MQ queue selects the MQ queue manager through the MQ queue manager group when sending messages.

[0059] After adopting this solution, the application system still uses the configured queue to send messages, but multiple MQ queue managers are configured internally. The queue can determine whether the currently connected queue manager is valid based on the message sending status. If it is in an invalid state, the queue will select another queue manager to resend the message, thereby solving the high availability of MQ multiple instances.

[0060] Figure 5 FIG. 1 is a schematic diagram of an abnormal message processing and resending process of an MQ multi-instance message sending method according to an embodiment of the present invention. Figure 5 As shown, when a method for sending a message using multiple MQ instances is specifically implemented according to an embodiment of the present invention, in one embodiment, the message sending result is monitored, and when the message sending is abnormal, a new MQ queue manager is replaced according to the exception handling mechanism to resend the message, including:

[0061] Step 501: monitoring message sending results;

[0062] Step 502: When the message is sent successfully, mark the selected MQ queue manager as available;

[0063] Step 503: When the message sending is abnormal, determine the type of the abnormal message;

[0064] Step 504: If the type of the abnormal message is a system abnormality, the abnormal rotation mechanism is triggered, and a new MQ queue manager is replaced to resend the message;

[0065] Step 505: If the type of the abnormal message is a non-system abnormality, the message is resent according to the message resending mechanism.

[0066] In the embodiment, if an exception occurs when a queue manager is acquired and a message is sent, it is necessary to handle it separately according to the type of the exception. When the abnormal message is processed and resent, the main process includes:

[0067] First, monitor the message sending results; the message sending results are divided into success or exception; then, when the message is sent successfully, mark the selected MQ queue manager as available; then, when the message is sent abnormally, determine the type of abnormal message; next, if the type of the abnormal message is a system-type exception, trigger the exception rotation mechanism, replace the new MQ queue manager to resend the message; finally, if the type of the abnormal message is a non-system-type exception, resend the message according to the message resending mechanism.

[0068] The focus of the embodiment of the present invention is to implement a high-availability mechanism for multiple MQ instances through applications, and to design exception handling for exceptions in the message sending process. The design and development of the exception rotation mechanism and the message retransmission mechanism are the most difficult for the present invention. To implement the high-availability characteristics of MQ multiple instances through applications, it is necessary to schedule and manage multiple instances through an MQ queue manager group, and to achieve high availability through exception handling and message retransmission. This is the core process of the embodiment of the present invention. The high-availability characteristics of MQ multiple instances implemented through applications in the embodiment of the present invention, among which the scheduling management of MQ multiple instances, the mechanism and collaboration of the exception message processing and message retransmission modules, are the key points of the embodiment of the present invention.

[0069] Figure 6 FIG. 1 is a flow chart of an abnormal rotation mechanism of an MQ multi-instance message sending method according to an embodiment of the present invention, as shown in FIG. Figure 6 As shown, when a method for sending a multi-instance MQ message provided by an embodiment of the present invention is specifically implemented, in one embodiment, if the type of the abnormal message is a system abnormality, an abnormal rotation mechanism is triggered, and a new MQ queue manager is replaced to resend the message, including:

[0070] If the type of the exception message is a system exception including connection rejection and connection timeout, the exception rotation mechanism is triggered to determine whether there is an available MQ queue manager in the cache;

[0071] When there is an available MQ queue manager in the cache, select an MQ queue manager as the new MQ queue manager and delete the MQ queue manager where the exception occurs;

[0072] Use the new MQ queue manager to resend the message to the corresponding channel;

[0073] When there is no available MQ queue manager in the cache, select an MQ queue manager from multiple MQ queue managers configured in the MQ queue manager group as the new MQ queue manager.

[0074] Use the new MQ queue manager to try to resend the message to the corresponding channel until the message is sent successfully. Add the new MQ queue manager to the list of available MQ queue managers and cache it.

[0075] In the embodiment, if the exception is a system exception such as connection rejection, connection timeout, etc., the exception rotation mechanism is triggered to determine whether there is an available MQ queue manager in the cache; when there is an available MQ queue manager in the cache, a MQ queue manager is randomly selected as the new MQ queue manager, and the MQ queue manager group is used to delete the MQ queue manager where the exception occurs, to ensure that the MQ queue manager in the cache is in an available state, and the unavailable MQ queue manager is removed, thereby improving the efficiency of message sending and reducing the waste of system resources; the new MQ queue manager is used to resend the message to the corresponding channel; when there is no available MQ queue manager in the cache, a MQ queue manager is randomly selected from multiple MQ queue managers configured in the MQ queue manager group as the new MQ queue manager, and the new MQ queue manager is used to try to resend the message to the corresponding channel until the message is successfully sent, and the MQ queue manager group is used to add the new MQ queue manager to the list of available MQ queue managers and cache it, thereby realizing dynamic increase and decrease of the list of available MQ queue managers.

[0076] If the exception is a system exception such as connection rejection or connection timeout, the rotation mechanism is triggered, that is, it is determined whether there is an available queue manager in the cache. If so, the next queue manager is randomly selected and the problematic manager is deleted; if there is no available queue manager in the cache, a queue manager is randomly selected from the configuration and tries to send again until the queue manager is cached after the sending is successful.

[0077] If the exception is not a system exception, the message resending mechanism will be activated.

[0078] When implementing an MQ multi-instance message sending method provided by an embodiment of the present invention, in one embodiment, if the type of the abnormal message is a non-system abnormality, resending the message according to the message resending mechanism includes:

[0079] If the type of the exception message is a non-system exception, the message will be placed in the message resending queue;

[0080] Resend the message to the corresponding channel according to the resend strategy configured by the message resend mechanism.

[0081] In the embodiment, for non-system exceptions that occur when sending a message, the message enters the message retransmission queue, and the application will handle it according to the configured retransmission strategy. General strategies include maximum number of retransmissions and unlimited retransmissions.

[0082] When implementing a method for sending a multi-instance MQ message provided by an embodiment of the present invention, in one embodiment, when the retransmission strategy is the maximum number of retransmissions,

[0083] Set the message resending threshold. The interval between each resending increases gradually according to the set ratio. If the number of message sending times reaches the message resending threshold and each time is a non-system exception, an exception will be thrown and the next message will be processed.

[0084] In the embodiment, the maximum number of retransmissions is to try to send a specified number of times, and the retransmission interval gradually increases each time. If the maximum number of retransmissions is reached and each time is a non-system exception, an exception is thrown externally and the next message is processed.

[0085] When implementing a method for sending a multi-instance MQ message provided by an embodiment of the present invention, in one embodiment, when the retransmission strategy is infinite retransmission,

[0086] Repeatedly send the message until the message is successfully sent to the corresponding channel or a system exception occurs.

[0087] Infinite resending means repeatedly sending the message until it succeeds or a system exception occurs.

[0088] After adopting this solution, the application system still uses the configured queue to send messages, but multiple MQ queue managers are configured internally. The queue can determine whether the currently connected queue manager is valid based on the message sending status. If it is in an invalid state, the queue will select another queue manager to resend the message, thereby solving the high availability of MQ multiple instances. By joining the MQ queue manager group, multiple MQ queue managers are scheduled and managed, and queue manager rotation and message resending mechanisms are introduced under abnormal circumstances. A high availability mechanism for multiple MQ instances is implemented, and exception handling and message resending mechanisms are designed for exceptions in the message sending process. The rigid requirements for MQ high availability in the production environment are met, and the intrusion to development is relatively low. Development only needs to configure the MQ queue management group, which is implemented through the underlying framework, and the cost of application transformation is low.

[0089] The following briefly describes an MQ multi-instance message sending method provided by an embodiment of the present invention in conjunction with a specific scenario:

[0090] The present invention manages multiple MQ instances in a unified manner from an application perspective, and provides a high-availability solution for multiple MQ instances. The present invention implements configuration of multiple queue managers and message sending through applications.

[0091] After adopting this solution, the application system still uses the configured queue to send messages, but multiple MQ queue managers are configured internally. The queue can determine whether the currently connected queue manager is valid based on the message sending status. If it is in an invalid state, the queue will select another queue manager to resend the message.

[0092] The present invention schedules and manages MQ multiple queue managers by adding queue manager groups, and introduces queue manager rotation and message retransmission mechanisms in abnormal situations, mainly including the following mechanisms:

[0093] 1. MQ multi-instance scheduling mechanism:

[0094] To ensure the high availability of MQ multi-instances, the original MQ queue is transformed and an MQ queue manager group is added. The queue manager group manages each queue manager. When the application sends a message, if a list of available MQ queue managers has been stored in the cache, a MQ queue manager is randomly selected from the buffer. If it does not exist in the cache, a configured queue manager is randomly selected. Based on the result of sending the message, the queue manager in the available state is cached, and the exception handling mechanism is entered for failure to send the message.

[0095] 2. Rotation mechanism under abnormal circumstances:

[0096] If an exception occurs when acquiring a queue manager and sending a message, it needs to be handled separately according to the type of exception:

[0097] If the exception is a system exception such as connection rejection or connection timeout, the rotation mechanism is triggered, that is, it is determined whether there is an available queue manager in the cache. If so, the next queue manager is randomly selected and the problematic manager is deleted; if there is no available queue manager in the cache, a queue manager is randomly selected from the configuration and tries to send again until the queue manager is cached after the sending is successful.

[0098] If the exception is not a system exception, the message resending mechanism will be activated.

[0099] 3. Message resending mechanism:

[0100] For non-system exceptions that occur when sending messages, the message will enter the message resending queue, and the application will handle it according to the configured resending strategy. General strategies include maximum resending and unlimited resending. Maximum resending means trying to send a specified number of times, and the resending interval gradually increases each time. If the maximum number of resending times is reached and each time it is a non-system exception, an exception will be thrown to the outside and the next message will be processed; unlimited resending means repeatedly sending messages until success or a system exception occurs.

[0101] From a development perspective, technicians only need to configure multiple MQ queue managers and add them to the MQ queue manager group. The MQ queue selects the MQ queue manager through the MQ queue manager group when sending messages.

[0102] The essence of the embodiments of the present invention is to implement a high availability mechanism for multiple MQ instances through application, and to design an exception handling and message retransmission mechanism for exceptions in the message sending process. The design and development of these mechanisms are the most difficult for the present invention.

[0103] The embodiment of the present invention also provides a modular instance of an MQ multi-instance message sending method, which comprises an MQ multi-instance scheduling module, a message exception processing module and a message retransmission module.

[0104] The MQ multi-instance scheduling module completes the selection and caching of multiple MQ queue managers. For exception handling after sending messages through the selected queue manager, it enters the message exception handling module. The exception handling module handles different exceptions separately. Non-system exceptions enter the message retransmission module, which retransmits the message according to the retransmission strategy; system exceptions enter the round-robin mechanism, that is, the next MQ queue manager is selected through the cache or configured MQ queue manager group and the message is sent.

[0105] The embodiment of the present invention realizes the high availability characteristics of MQ multi-instances through application, which is specifically achieved through the cooperation of the MQ multi-instance scheduling module, the message exception processing module and the message retransmission module.

[0106] 1. The MQ multi-instance scheduling module receives messages from the application, selects an MQ queue manager to send messages, and caches a list of available MQ queue managers;

[0107] 2. After receiving the message and exception information, the message exception processing module selects the next available MQ queue manager to send the message according to the exception information category for system exceptions and caches it after success; for non-system exceptions, it enters the message resending module;

[0108] 3. The message resending module receives the message to be resent and resends the message according to the resending strategy;

[0109] To realize the high availability of MQ multi-instances through applications, it is necessary to schedule and manage the multi-instances through the MQ queue manager group, and to achieve high availability through exception handling and message retransmission, which is the core process of the present invention.

[0110] The high availability characteristics of MQ multi-instances implemented by applications in the embodiments of the present invention, wherein the scheduling management, abnormal message processing and message retransmission module mechanisms and collaboration of MQ multi-instances are the key points of the present invention.

[0111] The embodiment of the present invention realizes a new MQ multi-instance architecture through a series of mechanisms and modules in series. The advantages are as follows: it meets the rigid requirements for MQ high availability in the production environment; it is relatively less invasive to development, and development only needs to configure the MQ queue management group; it is implemented through the underlying framework, and the application transformation cost is low.

[0112] Figure 7 A schematic diagram of a computer device for running an MQ multi-instance message sending method implemented by the present invention, such as Figure 7 As shown, an embodiment of the present invention further provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned MQ multi-instance message sending method when executing the computer program.

[0113] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program for executing and implementing the above-mentioned MQ multi-instance message sending method.

[0114] The present invention also provides an MQ multi-instance message sending device, as described in the following embodiments. Since the principle of solving the problem by the device is similar to that of an MQ multi-instance message sending method, the implementation of the device can refer to the implementation of an MQ multi-instance message sending method, and the repeated parts will not be repeated.

[0115] Figure 8 FIG. 1 is a schematic diagram of an MQ multi-instance message sending device according to an embodiment of the present invention. Figure 8 As shown, the embodiment of the present invention further provides an MQ multi-instance message sending device, which may include:

[0116] The MQ queue manager configuration module 801 is used to configure multiple MQ queue managers to join an MQ queue manager group;

[0117] An available MQ queue manager list determination module 802 is used to select an MQ queue manager through the MQ queue manager group when a message is sent from the application system, determine the available MQ queue manager list and cache it;

[0118] The MQ multi-instance scheduling module 803 is used to receive messages sent by the application system through the MQ queue, select an MQ queue manager from the cache using the MQ queue manager group, and send the message to the corresponding channel through the selected MQ queue manager;

[0119] The abnormal message processing and resending module 804 is used to monitor the message sending result, and when the message sending is abnormal, replace the new MQ queue manager according to the abnormal processing mechanism to resend the message.

[0120] When implementing an MQ multi-instance message sending device provided by an embodiment of the present invention, in one embodiment, the aforementioned MQ multi-instance scheduling module is specifically used to:

[0121] Use the MQ queue manager group to find the list of available MQ queue managers from the cache;

[0122] When there is an available MQ queue manager list in the cache, an MQ queue manager is selected from the available MQ queue manager list, and the message is sent to the corresponding channel through the selected MQ queue manager.

[0123] When implementing an MQ multi-instance message sending device provided by an embodiment of the present invention, in one embodiment, the aforementioned MQ multi-instance scheduling module is further used to:

[0124] When there is no available MQ queue manager list in the cache, select an MQ queue manager from multiple MQ queue managers configured in the MQ queue manager group, and send the message to the corresponding channel through the selected MQ queue manager;

[0125] When the message is sent successfully, the selected MQ queue manager is added to the list of available MQ queue managers and cached.

[0126] When implementing an MQ multi-instance message sending device provided by an embodiment of the present invention, in one embodiment, the aforementioned abnormal message processing and resending module is specifically used to:

[0127] Monitor message sending results;

[0128] When the message is sent successfully, the selected MQ queue manager is marked as available;

[0129] When a message is sent abnormally, determine the type of the abnormal message;

[0130] If the type of the exception message is a system exception, the exception rotation mechanism is triggered, and a new MQ queue manager is replaced to resend the message;

[0131] If the type of the exception message is a non-system exception, the message will be resent according to the message resending mechanism.

[0132] When implementing an MQ multi-instance message sending device provided by an embodiment of the present invention, in one embodiment, the aforementioned abnormal message processing and resending module is further used to:

[0133] If the type of the exception message is a system exception including connection rejection and connection timeout, the exception rotation mechanism is triggered to determine whether there is an available MQ queue manager in the cache;

[0134] When there is an available MQ queue manager in the cache, select an MQ queue manager as the new MQ queue manager and delete the MQ queue manager where the exception occurs;

[0135] Use the new MQ queue manager to resend the message to the corresponding channel;

[0136] When there is no available MQ queue manager in the cache, select an MQ queue manager from multiple MQ queue managers configured in the MQ queue manager group as the new MQ queue manager.

[0137] Use the new MQ queue manager to try to resend the message to the corresponding channel until the message is sent successfully. Add the new MQ queue manager to the list of available MQ queue managers and cache it.

[0138] When implementing an MQ multi-instance message sending device provided by an embodiment of the present invention, in one embodiment, the aforementioned abnormal message processing and resending module is further used to:

[0139] If the type of the exception message is a non-system exception, the message will be placed in the message resending queue;

[0140] Resend the message to the corresponding channel according to the resend strategy configured by the message resend mechanism.

[0141] When implementing an MQ multi-instance message sending device provided by an embodiment of the present invention, in one embodiment, the aforementioned abnormal message processing and resending module is further used to: when the resending strategy is the maximum number of resending,

[0142] Set the message resending threshold. The interval between each resending increases gradually according to the set ratio. If the number of message sending times reaches the message resending threshold and each time is a non-system exception, an exception will be thrown and the next message will be processed.

[0143] When implementing an MQ multi-instance message sending device provided by an embodiment of the present invention, in one embodiment, the aforementioned abnormal message processing and resending module is further used to: when the resending strategy is infinite resending,

[0144] Repeatedly send the message until the message is successfully sent to the corresponding channel or a system exception occurs.

[0145] In summary, an MQ multi-instance message sending method and device provided by an embodiment of the present invention includes: first configuring multiple MQ queue managers to join an MQ queue manager group; then when an application system sends a message, selecting an MQ queue manager through the MQ queue manager group, determining an available MQ queue manager list and caching it; next, receiving a message sent by the application system through an MQ queue, selecting an MQ queue manager from the cache using the MQ queue manager group, and sending the message to the corresponding channel through the selected MQ queue manager; finally monitoring the message sending result, and when the message sending is abnormal, replacing a new MQ queue manager according to the exception handling mechanism to resend the message. The present invention manages multiple MQ instances uniformly from an application perspective, provides a high-availability solution for MQ multi-instances, and implements the configuration and message sending of multiple MQ queue managers. By joining the MQ queue manager group, multiple MQ queue managers are scheduled and managed, and an exception handling mechanism is introduced under abnormal circumstances; a high-availability mechanism for multiple MQ instances is implemented, and an exception handling mechanism is designed for exceptions in the message sending process; the rigid requirements for MQ high availability in the production environment are met, and the intrusion to development is relatively low. Development only needs to configure the MQ queue management group, which is implemented through the underlying framework, and the application transformation cost is low.

[0146] After adopting the solution of the embodiment of the present invention, the application system still uses the configured queue to send messages, but multiple MQ queue managers are configured internally. The queue can determine whether the currently connected queue manager is valid based on the message sending status. If it is in an invalid state, the queue will select another queue manager to resend the message, thereby solving the high availability of MQ multiple instances; by joining the MQ queue manager group, multiple MQ queue managers are scheduled and managed, and queue manager rotation and message resending mechanisms are introduced under abnormal circumstances; a high availability mechanism for multiple MQ instances is implemented, and exception handling and message resending mechanisms are designed for exceptions in the message sending process; the rigid requirements for MQ high availability in the production environment are met, and the invasiveness to development is relatively low. Development only needs to configure the MQ queue management group, which is implemented through the underlying framework, and the cost of application transformation is low.

[0147] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0148] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0149] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0150] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0151] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A method for sending MQ multi-instance messages, characterized in that: include: Configure multiple MQ queue managers to join the MQ queue manager group; When the application system sends a message, the MQ queue manager is selected through the MQ queue manager group, and the list of available MQ queue managers is determined and cached; Receive messages from the application system through the MQ queue, select an MQ queue manager from the cache using the MQ queue manager group, and send the message to the corresponding channel through the selected MQ queue manager; Monitor the message sending results. When the message sending is abnormal, replace the new MQ queue manager according to the exception handling mechanism to resend the message. The monitoring of message sending results, when the message sending is abnormal, replacing a new MQ queue manager to resend the message according to the exception handling mechanism, includes: monitoring the message sending results; when the message is sent successfully, marking the selected MQ queue manager as available; when the message is sent abnormally, judging the type of the abnormal message; if the type of the abnormal message is a system-type exception, triggering the abnormal rotation mechanism, replacing a new MQ queue manager to resend the message; if the type of the abnormal message is a non-system-type exception, resending the message according to the message resending mechanism; wherein the abnormal rotation mechanism is: replacing a new MQ queue manager to resend the message; the message resending mechanism is: not replacing a new MQ queue manager, and the selected MQ queue manager still resends the message.

2. The method according to claim 1, characterized in that Use the MQ queue manager group to select an MQ queue manager from the cache and send the message to the corresponding channel through the selected MQ queue manager, including: Use the MQ queue manager group to find the list of available MQ queue managers from the cache; When there is an available MQ queue manager list in the cache, an MQ queue manager is selected from the available MQ queue manager list, and the message is sent to the corresponding channel through the selected MQ queue manager.

3. The method according to claim 2, characterized in that Also includes: When there is no available MQ queue manager list in the cache, select an MQ queue manager from multiple MQ queue managers configured in the MQ queue manager group, and send the message to the corresponding channel through the selected MQ queue manager; When the message is sent successfully, the selected MQ queue manager is added to the list of available MQ queue managers and cached.

4. The method according to claim 1, characterized in that If the type of the exception message is a system exception, the exception rotation mechanism is triggered, and a new MQ queue manager is replaced to resend the message, including: If the type of the exception message is a system exception including connection rejection and connection timeout, the exception rotation mechanism is triggered to determine whether there is an available MQ queue manager in the cache; When there is an available MQ queue manager in the cache, select an MQ queue manager as the new MQ queue manager and delete the MQ queue manager where the exception occurs; Use the new MQ queue manager to resend the message to the corresponding channel; When there is no available MQ queue manager in the cache, select an MQ queue manager from multiple MQ queue managers configured in the MQ queue manager group as the new MQ queue manager. Use the new MQ queue manager to try to resend the message to the corresponding channel until the message is sent successfully. Add the new MQ queue manager to the list of available MQ queue managers and cache it.

5. The method according to claim 1, characterized in that If the type of the exception message is a non-system exception, the message is resent according to the message resending mechanism, including: If the type of the exception message is a non-system exception, the message will be placed in the message resending queue; Resend the message to the corresponding channel according to the resend strategy configured by the message resend mechanism.

6. The method according to claim 5, characterized in that When the retransmission strategy is the maximum number of retransmissions, Set the message resending threshold. The interval between each resending increases gradually according to the set ratio. If the number of message sending times reaches the message resending threshold and each time is a non-system exception, an exception will be thrown and the next message will be processed.

7. The method according to claim 5, characterized in that When the retransmission strategy is infinite retransmission, Repeatedly send the message until the message is successfully sent to the corresponding channel or a system exception occurs.

8. An MQ multi-instance message sending device, characterized in that: include: MQ queue manager configuration module, used to configure multiple MQ queue managers to join the MQ queue manager group; The module for determining the list of available MQ queue managers is used to select an MQ queue manager through the MQ queue manager group when a message is sent from the application system, determine the list of available MQ queue managers and cache it; MQ multi-instance scheduling module, used to receive messages from the application system through the MQ queue, select an MQ queue manager from the cache using the MQ queue manager group, and send the message to the corresponding channel through the selected MQ queue manager; The abnormal message processing and resending module is used to monitor the message sending results. When the message sending is abnormal, a new MQ queue manager is replaced according to the abnormal processing mechanism to resend the message; The abnormal message processing and resending module is specifically used to: monitor the message sending results; when the message is sent successfully, mark the selected MQ queue manager as available; when the message is sent abnormally, determine the type of abnormal message; if the type of the abnormal message is a system-type abnormality, trigger the abnormal rotation mechanism, replace the new MQ queue manager to resend the message; if the type of the abnormal message is a non-system-type abnormality, resend the message according to the message resending mechanism; wherein, the abnormal rotation mechanism is: replace the new MQ queue manager to resend the message; the message resending mechanism is: do not replace the new MQ queue manager, and the selected MQ queue manager will still resend the message.

9. The device according to claim 8, characterized in that MQ multi-instance scheduling module, specifically used for: Use the MQ queue manager group to find the list of available MQ queue managers from the cache; When there is an available MQ queue manager list in the cache, an MQ queue manager is selected from the available MQ queue manager list, and the message is sent to the corresponding channel through the selected MQ queue manager.

10. The device according to claim 9, characterized in that The MQ multi-instance scheduling module is also used for: When there is no available MQ queue manager list in the cache, select an MQ queue manager from multiple MQ queue managers configured in the MQ queue manager group, and send the message to the corresponding channel through the selected MQ queue manager; When the message is sent successfully, the selected MQ queue manager is added to the list of available MQ queue managers and cached.

11. The device according to claim 8, characterized in that The abnormal message processing and resending module is also used to: If the type of the exception message is a system exception including connection rejection and connection timeout, the exception rotation mechanism is triggered to determine whether there is an available MQ queue manager in the cache; When there is an available MQ queue manager in the cache, select an MQ queue manager as the new MQ queue manager and delete the MQ queue manager where the exception occurs; Use the new MQ queue manager to resend the message to the corresponding channel; When there is no available MQ queue manager in the cache, select an MQ queue manager from multiple MQ queue managers configured in the MQ queue manager group as the new MQ queue manager. Use the new MQ queue manager to try to resend the message to the corresponding channel until the message is sent successfully. Add the new MQ queue manager to the list of available MQ queue managers and cache it.

12. The device according to claim 8, characterized in that The abnormal message processing and resending module is also used to: If the type of the exception message is a non-system exception, the message will be placed in the message resending queue; Resend the message to the corresponding channel according to the resend strategy configured by the message resend mechanism.

13. The device according to claim 12, characterized in that The abnormal message processing resending module is also used to: when the resending strategy is the maximum number of resending, Set the message resending threshold. The interval between each resending increases gradually according to the set ratio. If the number of message sending times reaches the message resending threshold and each time is a non-system exception, an exception will be thrown and the next message will be processed.

14. The device according to claim 12, characterized in that The abnormal message processing resend module is also used to: when the resend strategy is infinite resend, Repeatedly send the message until the message is successfully sent to the corresponding channel or a system exception occurs.

15. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.

16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of claims 1 to 7.