Disclosure of Invention
Based on the above-mentioned problems in the background art, the present disclosure provides a system, a method, a device and a medium for high-availability connection service between an application and a message queue, which can significantly improve system stability and message transmission timeliness. In order to solve the technical problems, the present disclosure provides the following technical solutions:
As an aspect of the embodiments of the present disclosure, there is provided an application and message queue high availability connection service system for enabling communication among a plurality of applications, including an application a, an application a message queue, an application C, and an application C message queue, the application a message queue including a first local queue and a first remote queue, the application C message queue including a second local queue and a second remote queue;
The system comprises a first local queue, a second local queue, a first remote queue, a first local queue, a second local queue, a first remote queue and a second local queue, wherein the first local queue is used for sending a message to an application A, the first remote queue is used for receiving the message of the application A and transmitting the message to an application C message queue;
the message queue of the application B comprises a third local queue and a third remote queue;
The information in the first local queue can be directly transmitted to the application B for consumption, and the information in the third local queue can also be directly transmitted to the application A for consumption.
Optionally, the application a or the application B can also transmit the message to the second local queue through the third remote queue and then to the application C for consumption;
The system also comprises an application D and a message queue of the application D, wherein the message queue of the application D comprises a fourth local queue and a fourth remote queue;
the information in the second local queue can be directly transmitted to the application D for consumption, and the information in the fourth local queue can also be directly transmitted to the application C for consumption.
Optionally, application B can also pass the message through the first remote queue to the second local queue and then to application C for consumption.
Optionally, the application C can transmit the message to the first local queue or the third local queue through the fourth remote queue, and then transmit the message to the application a or the application B for consumption.
Optionally, the application D can also transmit the message to the first local queue or the third local queue through the fourth remote queue, and then transmit the message to the application a or the application B for consumption.
As another aspect of the embodiments of the present disclosure, the method for implementing communication between a plurality of applications by using the high available connection service method for an application and a message queue, includes the following steps:
acquiring available lines, wherein the available lines are transmission lines which are marked as available for the transmission flow of the detection message periodically;
transmitting a message according to the available lines;
judging whether the message is successfully sent or not, if not, marking that the available line is unavailable and giving a short message alarm.
Optionally, the probing message sending process includes:
starting a thread daemon of a transmission line;
starting timing detection of fixed time;
acquiring a transmission line to be detected;
transmitting a detection message to a transmission line to be detected;
judging whether the detection message is successfully transmitted, if so, updating the transmission line into an available line, modifying a success time stamp, waiting for starting the next detection, and if not, marking that the detected transmission line is unavailable, closing the message queue connection of the transmission line, and after waiting for a fixed time, re-creating the detection flow of the next detection.
Optionally, acquiring the transmission line to be detected includes:
And obtaining the lower index value of the last transmission line, and then obtaining the next transmission line by adding one to the lower index value.
As another aspect of the embodiments of the present disclosure, there is provided an electronic device including a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the application and message queue high availability connection service method when executing the computer program.
As another aspect of the disclosed embodiments, a computer-readable storage medium is provided, on which a computer program is stored, which when executed by a processor, implements the steps of the application and message queue high availability connectivity service method.
Compared with the prior art, the method and the device realize direct and redundant communication links between each application and each Message Queue (MQ) through complex cross interconnection between a plurality of application programs (Apps) and a plurality of Message Queues (MQs), solve the problem that the Message Queues (MQ) are only used as connection points, simultaneously eliminate possible disconnection risks between the Message Queues (MQ) and the application, ensure that data transmission and processing capacity between the application and the Message Queues (MQ) can be seamlessly connected even when single-point faults occur, thereby remarkably improving the robustness and fault tolerance capacity of the whole system, strengthening the stability of the system, and ensuring that service continuity is not influenced by single fault points.
Detailed Description
Various exemplary embodiments, features and aspects of the disclosure will be described in detail below with reference to the drawings. In the drawings, like reference numbers indicate identical or functionally similar elements. Although various aspects of the embodiments are illustrated in the accompanying drawings, the drawings are not necessarily drawn to scale unless specifically indicated.
The word "exemplary" is used herein to mean "serving as an example, embodiment, or illustration. Any embodiment described herein as "exemplary" is not necessarily to be construed as preferred or advantageous over other embodiments.
Furthermore, numerous specific details are set forth in the following detailed description in order to provide a better understanding of the present disclosure. It will be understood by those skilled in the art that the present disclosure may be practiced without some of these specific details. In some embodiments, methods, means, elements and circuits well known to those skilled in the art have not been described in detail in order to not obscure the present disclosure.
It will be appreciated that the above-mentioned method embodiments of the present disclosure may be combined with each other to form a combined embodiment without departing from the principle logic, and are limited to the description of the present disclosure.
Example 1
The embodiment of the disclosure further provides a high-availability connection service system for application and message queues, which is used for communication among a plurality of applications, as shown in fig. 1, and comprises an application A and an application C, wherein the message queue of the application A comprises a first local queue and a first remote queue, and the message queue of the application C comprises a second local queue and a second remote queue;
The system comprises a first local queue, a second local queue, a first remote queue, a first local queue, a second local queue, a first remote queue and a second local queue, wherein the first local queue is used for sending a message to an application A, the first remote queue is used for receiving the message of the application A and transmitting the message to an application C message queue;
the message queue of the application B also comprises a third local queue and a third remote queue;
the information in the first local queue can be directly transmitted to the application B for consumption, and the information in the third local queue can also be directly transmitted to the application A for consumption;
the message queue of the application D also comprises a fourth local queue and a fourth remote queue;
the information in the second local queue can be directly transmitted to the application D for consumption, and the information in the fourth local queue can also be directly transmitted to the application C for consumption.
Based on the configuration of the high-availability connection service system for the application and the message queues in the embodiment of the disclosure, because no tight dependency relationship exists between the application and the message queues, even if a problem occurs in a certain message queue, the application cannot be restarted or the system fails, a direct and redundant communication link between each application and each Message Queue (MQ) is realized, the problem that the Message Queues (MQ) are only used as connection points is solved, meanwhile, the possible disconnection risk between the Message Queues (MQ) and the application is eliminated, and the seamless connection of data transmission and processing capacity between the application and the Message Queues (MQ) is ensured even when a single-point fault occurs.
In order to realize loose coupling of the system, the application needs to contain response identification, node information of a receiver and a sender, and a Message Queue (MQ) is responsible for managing IP addresses, port numbers, names of multiparty queue managers, setting of local queues and remote queues, configuration of a sending channel and the like.
As a preferred embodiment, application a or application B is also able to pass messages through the third remote queue to the second local queue and then to application C for consumption.
As a preferred embodiment, application B is also able to pass messages through the first remote queue to the second local queue and then to application C for consumption.
As a preferred embodiment, application C is able to pass messages through the fourth remote queue to either the first local queue or the third local queue and then to application a or application B for consumption.
As a preferred embodiment, application D is also able to pass messages through the fourth remote queue to the first local queue or the third local queue and then to application a or application B for consumption.
The implementation mode realizes loose coupling through complex cross interconnection between a plurality of application programs (Apps) and a plurality of Message Queues (MQs), and remarkably improves the robustness and fault tolerance of the whole system. By implementing such an architecture, the stability of the system is enhanced.
Example 2
The embodiment of the present disclosure also provides a method for implementing communication between a plurality of applications by using the high available connection service system for application and message queue in embodiment 1, as shown in fig. 2, including the following steps:
acquiring available lines, wherein the available lines are transmission lines which are marked as available for the transmission flow of the detection message periodically;
transmitting a message according to the available lines;
judging whether the message is successfully sent or not, if not, marking that the available line is unavailable and giving a short message alarm.
The method comprises the steps of judging the health condition of an available line again, sending the available line according to the current line, if the available line is unavailable, circularly selecting the next available line, sending the transaction according to the remote queues corresponding to the available line and the remote queues of different types, wherein the transaction belongs to real-time or batch type services. If all queues are not available, triggering a short message alarm related person, and throwing out an abnormality to indicate that the message transmission fails. Wherein the health condition is determined by sending a probe message, and expecting a probe response within 1-3 seconds, otherwise, the available line is determined to be unavailable.
As a preferred embodiment, the probe message sending process, as shown in fig. 3, includes:
starting a thread daemon of a transmission line, judging whether the thread daemon is notified of interruption, if not, continuing the next step, and if so, ending the flow of the detection message;
and starting timing detection of fixed time, wherein the fixed time is generally set to about 8-15 seconds, preferably 10 seconds, and proper timing detection time can be selected according to the software and hardware resources of the system.
Acquiring a transmission line to be detected;
transmitting a detection message to a transmission line to be detected;
Judging whether the detection message is successfully transmitted, if so, updating the transmission line into an available line, modifying a success time stamp, waiting for starting the next detection, if so, marking the unavailable transmission line of the detection in a cache, alarming by a short message, closing the message queue connection of the transmission line, and after waiting for fixed time, re-creating the detection flow of the next round. The method for judging the failure of sending the detection message is that the detection message is not received after overtime.
The mechanism of the probe message is a periodic detection mechanism, which can fully check the availability of all channels. By timely identifying and solving the channel availability problem, the process effectively avoids message sending failure caused by the fact that channel state change is not timely perceived. This active monitoring strategy significantly improves the usability and stability of the system.
In the process of transmitting the probe message, whether there is a problem of response timeout can be determined by measuring the time of receiving the response. If there are several response messages, it is not necessary to make them correspond to specific detection messages one by one, and it is enough to prove that the channel is in normal working state as long as the response is received.
The composition of the probe message includes key information, a message originating server name, a queue manager name, and a send channel name. Accordingly, the response message also contains these information to ensure that the correspondence is clear. When any server receives the probe response message, it will update the timestamp and status of the received message according to the configuration of the transmitted message.
As a preferred embodiment, acquiring a transmission line to be detected includes:
And obtaining the lower index value of the last transmission line, and then obtaining the next transmission line by adding one to the lower index value. Wherein the transmission line is defined for the advance mark.
The message sending flow is a circulation traversing mechanism, so that the channels selected each time are ensured to be different, and the flow is distributed to all channels which normally run in an equalizing way. This strategy not only ensures the availability of the selected channels, but also significantly improves the stability of messaging.
Example 3
The disclosed embodiments also provide an electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, which when executed implements the application and message queue high availability connectivity service method of embodiment 2.
The electronic device in the embodiment of the present disclosure is only an example, and may be used to implement the functions of a host computer or the functions of a light curtain controller, and should not impose any limitation on the functions and the scope of use of the embodiment of the present disclosure.
The electronic device may be in the form of a general purpose computing device, which may be a server device, for example. Components of the electronic device may include, but are not limited to, at least one processor, at least one memory, a bus connecting the different system components, including the memory and the processor.
The buses include a data bus, an address bus, and a control bus.
The memory may include volatile memory such as Random Access Memory (RAM) and/or cache memory, and may further include Read Only Memory (ROM).
The memory may also include program means having a set (at least one) of program modules including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each or some combination of which may include an implementation of a network environment.
The processor executes various functional applications and data processing by running computer programs stored in the memory.
The electronic device may also communicate with one or more external devices (e.g., keyboard, pointing device, etc.). Such communication may be through an input/output (I/O) interface. And, the electronic device may also communicate with one or more networks such as a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the Internet, through a network adapter. The network adapter communicates with other modules of the electronic device via a bus. It should be appreciated that although not shown, other hardware and/or software modules may be used in connection with the electronic device, including, but not limited to, microcode, device drivers, redundant processors, external disk drive arrays, RAID (disk array) systems, tape drives, data backup storage systems, and the like.
It should be noted that although several units/modules or sub-units/modules of an electronic device are mentioned in the above detailed description, such a division is merely exemplary and not mandatory. Indeed, the features and functionality of two or more units/modules described above may be embodied in one unit/module in accordance with embodiments of the present application. Conversely, the features and functions of one unit/module described above may be further divided into ones that are embodied by a plurality of units/modules.
Example 4
The present disclosure provides a computer-readable storage medium storing a computer program which, when executed by a processor, implements the steps of the application and message queue high availability connection service method in embodiment 2 described above.
More specifically, a readable storage medium may include, but is not limited to, a portable disk, hard disk, random access memory, read only memory, erasable programmable read only memory, optical storage device, magnetic storage device, or any suitable combination of the foregoing.
In a possible embodiment, the disclosure may also be implemented in the form of a program product comprising program code for causing a terminal device to carry out the steps of implementing the application and message queue high availability connectivity service method described in example 2, when said program product is run on the terminal device.
Wherein the program code for carrying out the present disclosure may be written in any combination of one or more programming languages, which program code may execute entirely on the user device, partly on the user device, as a stand-alone software package, partly on the user device, partly on the remote device or entirely on the remote device.
While the invention has been described with respect to the preferred embodiments, it will be apparent to those skilled in the art that various changes and substitutions can be made herein without departing from the scope of the invention. Therefore, the protection scope of the present disclosure should be subject to the protection scope of the claims.