A system and method for implementing a long connection pipeline based on a spring container
By using a long-connection pipeline system based on the Spring container, combining short and long connections, the problems of resource waste and data leakage in existing technologies are solved, enabling real-time control and resource optimization of process computation, and improving the security and performance of the system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- AISINO CREDIT INFORMATION CO LTD
- Filing Date
- 2022-12-25
- Publication Date
- 2026-05-05
AI Technical Summary
In existing technologies, short connections based on the HTTP protocol consume network resources and time during data transmission, and user data is easily leaked, especially posing security risks in distributed cluster deployments.
A long-connection pipeline system based on the Spring container is adopted. By combining the process addition or update module, the short connection data receiving module, the node execution module, and the long connection data receiving module, the system can realize real-time control and data transmission of process information. The system optimizes resource utilization and avoids data leakage by combining long and short connections.
This enables the efficient use of server resources during process calculations, prevents user data leakage, and improves system security and performance.
Smart Images

Figure CN116089760B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of communication technology, and in particular relates to a system and method for implementing long-connection pipelines based on the Spring container. Background Technology
[0002] Currently, most websites deploy their servers based on distributed clusters. Users register accounts, log in to the front-end page, enter their data, and then transmit it to the server, which persists the data to its database. However, user data may contain private information, and storing it on other servers could easily lead to leaks and increase user security risks.
[0003] Furthermore, from a technical perspective, current communication based on the HTTP protocol, i.e. short connections, requires establishing and releasing connections when a node needs to push data after execution, which consumes network resources and time. Summary of the Invention
[0004] In view of this, the present invention aims to overcome the shortcomings of the above-mentioned problems in the prior art and proposes a system and method for implementing long-connection pipelines based on the Spring container.
[0005] To achieve the above objectives, the technical solution of the present invention is implemented as follows:
[0006] A system for implementing long-lived connection pipelines based on the Spring container includes:
[0007] The process addition or update module is used to save process information when a process is added or updated, and push the process information to the short connection data receiving module using a short connection.
[0008] The short-connection data receiving module is used to determine the process status and decide whether to drive the node execution module based on the process status.
[0009] The node execution module is used for pushing data over long-lived connections.
[0010] The long-connection data receiving module is used to receive push data from the node execution module and select the node execution module to call based on the process information, or decide whether to close long-connection management based on the process status.
[0011] This application also provides a method for implementing long-lived connection pipelines based on the Spring container, including the following steps:
[0012] S1. Save process information when adding or updating a process through the process addition or update module, and push the process information to other recipients through a short connection;
[0013] S2. Receive process information pushed from the short connection through the short connection data receiving module, and decide whether to drive the node execution module based on the process status;
[0014] S3. Push long-connection data through the node execution module;
[0015] S4. Receive long-connection data pushed by the node execution module through the long-connection data receiving module, and determine whether the process should continue to execute. If the process continues to execute, drive the node execution module to silently execute the entire process without changing the process state. If the process does not continue to execute, decide whether to save the current data or close the long-connection pipeline based on the process state.
[0016] Furthermore, in step S2, the operation process of the short connection data receiving module is as follows:
[0017] S21. Save process information;
[0018] S22. Determine if the process status is in the start state. If the process status is in the start state, then drive the node execution module to end the current short connection data receiving module service; if the status is in the paused or terminated state, then directly end the current short connection data receiving module service.
[0019] Furthermore, the operation process of the node execution module in step S3 is as follows:
[0020] S31. Determine if the current node can be executed. If the execution conditions are not met, save the data and end the current node's execution module business. If the execution conditions are met, execute the business processing, obtain the calculation result, and proceed to step S32.
[0021] S32. Determine whether the calculation result needs to be pushed. If data push is required, construct the bean by concatenating the IP address, port, and process ID, obtain the long connection pipeline from the Spring container, and proceed to step S33. If data push is not required, determine whether there is a next node. If there is, restart step S31. If there is no next node, end the process.
[0022] S33. Use the obtained long connection pipe to push data.
[0023] Furthermore, in step S32, when concatenating IP address, port number, and process ID to obtain the long-connection pipeline from the Spring container, if the long-connection pipeline does not exist, the long-connection client is first started and blocked based on the IP address and port number, and then the long-connection pipeline is obtained and registered in the Spring container.
[0024] Furthermore, in step S32, when there is no next node, the process execution is as follows:
[0025] S321. Change process status to "Completed";
[0026] S322. Use short connections for data push. At this time, the short connection data receiving module will be driven to control other participants to close the long connection pipeline and completely end the process calculation.
[0027] S323. Close the long-lived connection channel, unregister the bean, and terminate the current node's execution module business.
[0028] Furthermore, in step S4, the specific process of determining whether to save the current data or close the long-connection pipe based on the process status is as follows:
[0029] S41. If the process status is paused, retain the current data and terminate the current long-connection data receiving module service;
[0030] If the process status is not paused, close the long connection, unregister the bean, and end the current long connection data receiving module service.
[0031] Compared with the prior art, the present invention has the following advantages:
[0032] This invention describes a system and method for implementing long-connection pipelines based on the Spring container. Long-connection pipelines facilitate data interaction and process calculation between multiple service nodes, including the requester and receiver. The system design includes four modules: process addition or update, short-connection data reception, node execution, and long-connection data reception. Process calculation is completed through the node execution and long-connection data reception modules, while the process addition or update and short-connection data reception modules control whether the process starts or terminates. By combining long and short connections, the system enables users to control the process progress in real time, making efficient use of server resources and preventing user data leakage. Attached Figure Description
[0033] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an undue limitation of the invention. In the drawings:
[0034] Figure 1 This is a flowchart of the process for adding or updating modules as described in the embodiments of the present invention;
[0035] Figure 2 This is a flowchart of the short connection data receiving module according to an embodiment of the present invention;
[0036] Figure 3 This is a flowchart of the node execution module according to an embodiment of the present invention;
[0037] Figure 4 This is a flowchart of the long connection data receiving module according to an embodiment of the present invention. Detailed Implementation
[0038] It should be noted that, unless otherwise specified, the embodiments and features described in the present invention can be combined with each other.
[0039] The present invention will now be described in detail with reference to the accompanying drawings and embodiments.
[0040] A system for implementing long-lived connection pipelines based on the Spring container includes:
[0041] The process addition or update module is used to save process information when a process is added or updated, and push the process information to the short connection data receiving module using a short connection.
[0042] The short-connection data receiving module is used to determine the process status and decide whether to drive the node execution module based on the process status.
[0043] The node execution module is used for pushing data over long-lived connections.
[0044] The long-connection data receiving module is used to receive push data from the node execution module and select the node execution module to call based on the process information, or decide whether to close long-connection management based on the process status.
[0045] As shown in the figure, this application also provides a method for implementing long-connection pipelines based on the Spring container, including the following steps:
[0046] S1. When adding or updating a process, the process information is saved and pushed to other recipients via a short connection. This will drive the short connection data receiving module and end the process addition or update module business.
[0047] S2. Receive process information pushed from the short connection through the short connection data receiving module, and decide whether to drive the node execution module based on the process status;
[0048] S3. Push long-connection data through the node execution module;
[0049] S4. Receive long-connection data pushed by the node execution module through the long-connection data receiving module, and determine whether the process should continue. If the process continues, drive the node execution module to end the current long-connection data receiving module business and silently execute the entire process without changing the process status. If the process does not continue, decide whether to save the current data or close the long-connection pipeline based on the process status.
[0050] In step S2, the operation process of the short connection data receiving module is as follows:
[0051] S21. Save process information;
[0052] S22. Determine if the process status is in the start state. If the process status is in the start state, then drive the node execution module to end the current short connection data receiving module service; if the status is in the paused or terminated state, then directly end the current short connection data receiving module service.
[0053] The operation process of the node execution module in step S3 is as follows:
[0054] S31. Determine if the current node can be executed. If the execution conditions are not met, save the data and end the current node's execution module business. If the execution conditions are met, execute the business processing, obtain the calculation result, and proceed to step S32.
[0055] S32. Determine whether the calculation result needs to be pushed. If data push is required, construct the bean by concatenating the IP address, port, and process ID, obtain the long connection pipeline from the Spring container, and proceed to step S33. If data push is not required, determine whether there is a next node. If there is, restart step S31 to calculate the next process node. If there is no next node, end the process.
[0056] S33. Use the obtained long connection pipeline to push data, which will drive the long connection data receiving module to start executing business.
[0057] In step S32, when concatenating IP address, port number, and process ID to obtain the long-connection pipeline from the Spring container, if the long-connection pipeline does not exist, the long-connection client is first started and blocked based on the IP address and port number. Then, the long-connection pipeline is obtained and registered in the Spring container. The bean name is IP address, port number, and process ID.
[0058] In step S32, if there is no next node, the process execution is as follows:
[0059] S321. Change process status to "Completed";
[0060] S322. Use short connections for data push. At this time, the short connection data receiving module will be driven to control other participants to close the long connection pipeline and completely end the process calculation.
[0061] S323. Close the long-lived connection channel, unregister the bean, and terminate the current node's execution module business.
[0062] In step S4, the specific process of determining whether to save the current data or close the long-connection pipe based on the process status is as follows:
[0063] S41. If the process status is paused, retain the current data and terminate the current long-connection data receiving module service;
[0064] If the process status is not paused, i.e. terminated or ended, then close the long connection, unregister the bean, and end the current long connection data receiving module service.
[0065] In this embodiment, a Spring container is used to maintain persistent connection pipeline information. Currently, most methods use Maps to maintain persistent connections. The advantage of using a Spring container is that users can extend the functionality during the initialization or destruction of the persistent connection pipeline, enabling personalized customization. For example, if the Spring service is directly shut down or restarted, the pipeline will be destroyed. In this case, the `destroyMethod` method can be used to save the request data, making it convenient to re-execute next time, reducing loss and improving performance.
[0066] Meanwhile, Maps will directly overwrite existing keys. If users mishandle this, they might create duplicate socket clients and bind them to the socket server, rendering the old channels unusable and causing memory leaks. However, by using a Spring container for maintenance, the server will report an error if the annotated beanName already exists, allowing users to easily identify the problem and make timely adjustments.
[0067] By using short connections to change the process status in real time, the long-connection data receiving module decides whether to save the current data or close the long-connection pipeline based on the task status. This allows for control over the pause or termination of the process without affecting the execution of the current node, effectively reducing losses. Furthermore, it can autonomously determine whether to close the long-connection pipeline, reducing server load. By alternating between short and long connections, server resources are utilized efficiently, improving performance.
[0068] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for implementing long-lived connection pipelines based on the Spring container, characterized in that, Includes the following steps: S1. Save process information when adding or updating a process through the process addition or update module, and push the process information to other recipients through a short connection; S2. Receive process information pushed from the short connection through the short connection data receiving module, and decide whether to drive the node execution module based on the process status; S3. Long-connection data push is performed through the node execution module, and the operation process is as follows: S31. Determine if the current node can be executed. If the execution conditions are not met, save the data and end the current node's execution module business. If the execution conditions are met, execute the business processing, obtain the calculation result, and proceed to step S32. S32. Determine whether the calculation result needs to be pushed. If data needs to be pushed, construct the bean by concatenating the IP address, port, and process ID, obtain the long connection pipeline from the Spring container, and proceed to step S33. If data push is not required, determine whether there is a next node. If there is, restart step S31. If not, end the process. S33. Use the obtained long connection pipe to push data; S4. Receive long-connection data pushed by the node execution module through the long-connection data receiving module, and determine whether the process should continue to execute. If the process continues to execute, drive the node execution module to silently execute the entire process without changing the process state. If the process does not continue to execute, decide whether to save the current data or close the long-connection pipeline based on the process state.
2. The method for implementing long-connection pipelines based on the Spring container according to claim 1, characterized in that, In step S2, the operation process of the short connection data receiving module is as follows: S21. Save process information; S22. Determine if the process status is in the start state. If the process status is in the start state, then drive the node execution module to end the current short connection data receiving module service; if the status is in the paused or terminated state, then directly end the current short connection data receiving module service.
3. The method for implementing a long-connection pipeline based on a Spring container according to claim 1, characterized in that: In step S32, when concatenating IP address, port number, and process ID to obtain the long-connection pipeline from the Spring container, if the long-connection pipeline does not exist, the long-connection client is first started and blocked based on the IP address and port number, and then the long-connection pipeline is obtained and registered in the Spring container.
4. The method for implementing long-connection pipelines based on the Spring container according to claim 1, characterized in that, In step S32, if there is no next node, the process execution is as follows: S321. Change process status to "Completed"; S322. Use short connections for data push. At this time, the short connection data receiving module will be driven to control other participants to close the long connection pipeline and completely end the process calculation. S323. Close the long-lived connection channel, unregister the bean, and terminate the current node's execution module business.
5. The method for implementing a long-connection pipeline based on a Spring container according to claim 1, characterized in that, In step S4, the specific process of determining whether to save the current data or close the long-connection pipe based on the process status is as follows: S41. If the process status is paused, retain the current data and terminate the current long-connection data receiving module service; If the process status is not paused, close the long connection, unregister the bean, and end the current long connection data receiving module service.
Citation Information
Patent Citations
Equipment connection method and device
CN111726413A