Message queue flow switching method based on multiple servers

By setting up a message queue manager and listener in the software system and using curl tool to manage message queue traffic, the problem of message queue packet failure and loss when the server is stopped is solved, and the system stability and data integrity are achieved.

CN119883684APending Publication Date: 2025-04-25重庆富民银行股份有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510023796.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-07
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

When using message queues for communication in the software system, if the receiver's server stops running, some message messages may fail or be lost.

Method used

Using the multi-server-based message queue traffic switching method, by setting the message queue manager in the publish message queue system and the message queue listener in the server, using the curl tool to send request commands to turn off or enable message queue listening, ensuring that the message queue traffic is turned off before the server is stopped, and the message queue listening is restarted when the server is restored.

Benefits of technology

It effectively avoids consumption failure and loss of message queues, ensuring system stability and data integrity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883684A_ABST
    Figure CN119883684A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of new-generation information, and discloses a multi-server-based message queue flow switching method, which comprises the following steps that: a message queue manager is arranged in a message queue publishing system, and a message queue monitor is arranged in a server; when a server stop request command is received; the message queue manager sends a post request command to the server through a command line tool curl of the shell; the post requests the command to call the servlet service in the server which receives the message queue; after the servlet service receives the post request command, the message queue monitoring is closed, the server does not read the task from the message queue manager any more, the server is closed and the server is managed after the server is ensured not to process the message queue any more, the flow is closed before the service is stopped, and the problem that the queue message fails to consume and even is lost can be avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of new generation information technology, and in particular to a message queue flow switching method based on multiple servers. Background Art

[0002] The software systems used by enterprises now use MQ for communication. MQ stands for Message Queue, which is a communication method between a software system and a processing terminal server. It communicates by reading and writing messages in and out of the queue without the need for a dedicated connection to link them. Communication between each other can be completed through direct calls.

[0003] In software system projects, some time-consuming operations that do not require immediate returns are often extracted for asynchronous processing. This greatly saves the server's request response time. Its characteristic is that it does not reply to user requests immediately, thereby improving the system's throughput.

[0004] However, when the receiving system interacts through the message queue, the receiver will preemptively read the message. When rolling release is performed, if the server used to receive the message queue stops, it is likely that some of the messages being processed will fail or even be lost. Summary of the invention

[0005] The present invention aims to provide a message queue traffic switching method based on multiple servers, so as to solve the problem that when a server stops during the current message queue transmission process, received message packets fail and are lost.

[0006] In order to solve the above problem, the technical solution adopted by the present invention is: a message queue traffic switching method based on multiple servers, comprising the following steps:

[0007] Step 1: Set up a message queue manager in the message queue publishing system. The message queue manager is used to temporarily store the message queue. Set up a message queue listener in the server. The message queue listener is used to open or close the server to read the message queue.

[0008] Step 2: Use the shell command line curl tool to send a request command to close the message queue monitoring;

[0009] Step 3: The message queue listener executes to close the message queue listening, and the server no longer reads the message queue from the message queue manager;

[0010] Step 4: After waiting for the preset time, stop the server and perform offline operation on the server;

[0011] Step 5: After the server completes the offline operation, when you need to restart the server, send the command to start the message queue monitoring again through the shell command line curl tool, and the server resumes reading the message queue function from the message queue manager;

[0012] Repeat steps 2 to 5 to complete the offline operation of multiple servers.

[0013] The advantage of this solution is that before stopping the server, first shut down the traffic of the server to receive the message queue, wait for the message queue in the server to be processed, and then stop the server, so as to avoid the consumption failure and loss of the message queue.

[0014] This solution sets up a message queue manager between the system and the server, and sends a request command to close or open the server message queue monitoring through the curl tool in the message queue manager. The curl tool is an open source command line tool. Curl supports multiple operating systems and has high permissions. The message queue manager can be used as a subsystem in the system that publishes the message queue to facilitate function integration.

[0015] Preferably, the curl sends a request command for closing or opening the message queue listener by sending a post request command, and the post request command includes logical parameters for executing closing or opening the message queue listener.

[0016] Preferably, the post request command includes checking the server message queue. When it is necessary to check the execution status of the message queue, the post command is sent through curl, so that the post command parameter is a request command for checking the server message queue monitoring;

[0017] Preferably, the server receives the post request command through the servlet service function, and parses the logical parameters represented by the request command, thereby obtaining the command executed by the message queue listener.

[0018] Preferably, the message queue manager sends the post request command by writing a CommandServlet.java file, adding parameter configuration in the web.xml of the project, and implementing the setting of the post request command parameters through the CommandServlet.java file.

[0019] Preferably, two parameters "when" and "flg" are proposed in the writing of CommandServlet.java: when the value of "when" is "status", it means checking the current message queue status, and there is no need to determine the value of "flg" at this time; when the value of "when" is "ibmmq", it is necessary to obtain the value of "flg". When the value of "flg" is "offline", it means closing the message queue listener; when the value of "flg" is "online", the message queue listener is turned on.

[0020] By adding parameter configuration in web.xml, the parameters of three states are configured at one time. When the server is restarted, only the parameter value needs to be changed to restore the monitoring of the message queue and realize the traffic transmission between the system and the server. This process does not require manual opening and closing of the server, reducing the risk of human operation. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 A flowchart of a method for switching message queue traffic based on multiple servers in an embodiment;

[0022] Figure 2 It is a signal communication structure diagram of multiple servers and publishing message queue system in the embodiment. DETAILED DESCRIPTION

[0023] The following is further described in detail by specific implementations, but the implementations of the present invention are not limited thereto. Unless otherwise specified, the technical means used in the following implementations are conventional means well known to those skilled in the art.

[0024] like Figure 1 A message queue traffic switching method based on multiple servers is shown, comprising the following steps:

[0025] Step 1 S01: a message queue manager is set in the message queue publishing system. The message queue manager is used for temporary storage of message queues. A message queue listener is set in the server. The message queue listener is used to open or close the server reading message queue.

[0026] Step 2 S02: Send a request command to close the message queue monitoring through the shell command line curl tool;

[0027] Step 3 S03: the message queue listener executes to close the message queue monitoring, and the server no longer reads the message queue from the message queue manager;

[0028] Step 4 S04: After waiting for a preset time, stop the server and perform an offline operation on the server;

[0029] Step 5 S05: After the server completes the offline operation, when the server needs to be started again, the command to start the message queue monitoring is sent again through the shell command line curl tool, and the server resumes the function of reading the message queue from the message queue manager;

[0030] Repeat steps 2 to 5 to complete the offline operation of multiple servers.

[0031] The request command for curl to close or open the message queue listener is implemented by sending a post request command, and the post request command includes the logical parameters for executing closing and opening the message queue listener; the post request command includes checking the server message queue. When it is necessary to check the execution status of the message queue, the post command is sent through curl, so that the post command parameter is the request command for checking the server message queue listener; the server receives the post request command through the servlet service function, and parses the logical parameters represented by the request command to obtain the command executed by the message queue listener.

[0032] The shell command line tool curl sends a post request as follows: create an execution script in the message queue manager, and create a project pom file in the script. The pom file introduces the jms dependency configuration spring-jms:

[0033]

[0034] Write a CommandServlet.java file and add the configuration to the project's web.xml:

[0035]

[0036] Among them, two parameters "when" and "flg" are proposed in the writing of CommandServlet.java: when the value of "when" is "status", it means checking the current message queue status, and there is no need to judge the value of "flg" at this time.

[0037] When the value of "when" is "ibmmq", you need to obtain the value of "flg". When the value of "flg" is "offline", it means that the message queue listener is turned off; when the value of "flg" is "online", the message queue listener is turned on.

[0038] like Figure 2As shown in the figure, the signal communication mode between multiple servers and the publishing message queue system is that a message queue manager is set in the publishing message queue system, a message queue listener is set in the server, a servlet service is built in the server, and the message queue manager sends a post request command to the server through the shell command line tool curl; the post request command includes parameters for executing logic, which are displayed as "status": it means only viewing the current mq status, when "offline" is displayed, it means closing the message queue listener; when "online" is displayed, it means turning on the message queue listener.

[0039] The above is only an embodiment of the present invention, and the common knowledge such as the known specific technical solutions and / or characteristics in the solution is not described in detail here. It should be pointed out that for those skilled in the art, without departing from the technical solution of the present invention, several modifications and improvements can be made, which should also be regarded as the protection scope of the present invention, and these will not affect the effect of the implementation of the present invention and the practicality of the patent. The scope of protection required by this application shall be based on the content of its claims, and the specific implementation methods and other records in the specification can be used to interpret the content of the claims.

Claims

1. A message queue traffic switching method based on multiple servers, characterized in that: The following steps are included: Step 1: Set up a message queue manager in the message queue publishing system. The message queue manager is used to temporarily store the message queue. Set up a message queue listener in the server. The message queue listener is used to open or close the server to read the message queue. Step 2: Use the shell command line curl tool to send a request command to close the message queue monitoring; Step 3: The message queue listener executes to close the message queue listening, and the server no longer reads the message queue from the message queue manager; Step 4: After waiting for the preset time, stop the server and perform offline operation on the server; Step 5: After the server completes the offline operation, when you need to restart the server, send the command to start the message queue monitoring again through the shell command line curl tool, and the server resumes reading the message queue function from the message queue manager; Repeat steps 2 to 5 to complete the offline operation of multiple servers.

2. The method for switching message queue traffic based on multiple servers according to claim 1 is characterized in that: The curl sends a request command for closing or opening the message queue listener by sending a post request command, and the post request command includes logical parameters for executing closing or opening the message queue listener.

3. The method for switching message queue traffic based on multiple servers according to claim 2 is characterized in that: The post request command includes checking the server message queue. When it is necessary to check the execution status of the message queue, the post command is sent through curl, so that the post command parameter is a request command for checking the server message queue monitoring.

4. The method for switching message queue traffic based on multiple servers according to claim 3 is characterized in that: The server receives the post request command through the servlet service function, and parses the logical parameters represented by the request command, thereby obtaining the command executed by the message queue listener.

5. The message queue traffic switching method based on multiple servers according to claim 4 is characterized in that ,The message queue manager sends a post request command by writing a CommandServlet.java file and adding parameter configuration in the project's web.xml.

6. The method for switching message queue traffic based on multiple servers according to claim 5 is characterized in that: When writing CommandServlet.java, two parameters "when" and "flg" are defined: when the value of "when" is "status", it means checking the current message queue status, and there is no need to determine the value of "flg"; when the value of "when" is "ibmmq", it is necessary to obtain the value of "flg". When the value of "flg" is "offline", it means closing the message queue listener; when the value of "flg" is "online", the message queue listener is turned on.