Implementation method of short message TCP connection cluster cross-host communication
By introducing a control node and the Caffeine caching framework, the problems of message storms and resource waste in SMS TCP connection clusters were solved, achieving efficient cross-server communication and load balancing, and improving the system's stability and scalability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA YOUKE COMM TECH
- Filing Date
- 2024-01-03
- Publication Date
- 2026-06-26
AI Technical Summary
Existing technologies suffer from message storms and resource waste in SMS TCP connection clusters, especially when the SMS gateway randomly distributes receipt results, resulting in only one service node being able to successfully process receipts, while other nodes consume resources on irrelevant messages.
A control node and Caffeine caching framework are introduced to store cluster and connection configuration information. The control node enables TCP connection communication between different servers in the cluster, and Caffeine is used for high-speed memory lookup and message forwarding.
It achieves simple deployment, low modification costs, reduced system complexity, improved system reliability and carrying capacity, and enhanced horizontal scalability.
Smart Images

Figure CN118102240B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the technical fields of short message communication and TCP connection clustering, and particularly relates to a method for implementing cross-host communication of SMS TCP connection clusters. Background Technology
[0002] Existing methods for implementing SMS TCP connection clusters and their problems;
[0003] Introduce a message queue component for message broadcasting.
[0004] Currently, most implementations on the market are based on introducing a message queue component to achieve TCP communication between SMS clusters via broadcast. That is, all server nodes subscribe to the "SMS Sending Result Receipt Topic" to attempt to receive and process SMS receipts. When client A maintains a connection with server A, but the carrier's SMS gateway's receipt result might be sent to server B for reception, this solution sends the receipt message to the "SMS Sending Result Receipt Topic" to send the gateway receipt back to client A.
[0005] Then, each service node in the cluster will receive a broadcast receipt for that topic and attempt to send the receipt to its local client. Since the client's TCP connection is only on one service node, only one service node can successfully send the receipt; other nodes give up because they cannot find the corresponding connection. This leads to problems such as message storms and wasted server resources. When the message volume reaches a certain level, the resources of other service nodes are consumed in parsing messages unrelated to their own nodes. Summary of the Invention
[0006] This invention relates to a method and system for implementing cross-host communication of SMS TCP connection clusters. It innovatively introduces a control node and combines it with the high-performance Caffeine caching framework to store cluster and connection configuration information, thereby solving the problems of load balancing distribution of a large number of TCP connections in the cluster and communication between different TCP connection processes.
[0007] TCP communication, as a commonly used information communication and interaction protocol technology, is widely used in various industries such as industrial equipment, IoT device communication control, and mobile communication due to its flexible definition, low transmission latency, and high data transmission capacity.
[0008] However, as the number of service connections typically increases, SMS TCP connection requests are usually load-balanced to distribute the application's TCP connections relatively evenly across different servers in the cluster, thereby increasing the service's carrying capacity. This raises the question of how TCP connections between different servers can communicate and send messages, and the Java language does not provide an implementation scheme for communication between different TCP connections within a server cluster.
[0009] Therefore, this invention cleverly solves the problem of inter-cluster TCP connection communication by combining a control node and Caffeine caching, without introducing commonly used components such as message queues. To this end, this invention provides a method for enabling inter-server TCP connection communication in SMS service applications. It utilizes one node as a control and scheduling node, combined with Caffeine's high-speed memory to store messages from different service nodes, thereby achieving inter-server SMS TCP connection communication within the cluster.
[0010] The present invention specifically adopts the following technical solution:
[0011] A method for implementing cross-host communication of SMS TCP connection clusters is characterized by: using one node in the cluster as a control and scheduling node, and combining it with Caffeine's high-speed memory to store messages from different service nodes, so as to realize mutual communication of SMS TCP connections between different cross-servers within the cluster.
[0012] Furthermore, when sending a message, the system first attempts to determine if the bound TCP connection exists locally based on the user code. If not, it searches the local Caffeine cache for the host information of the connection based on the user code. Then, it sends a message packet containing the destination host and the receiving user information to a control node for processing and forwarding. The control node parses the protocol packet content and forwards the message to the destination host service node based on the destination host. After receiving the message, the destination host service node obtains the local TCP connection based on the user code and then sends the information, thus completing the message sending process.
[0013] Furthermore, in the SMS TCP connection cluster, each server node maintains a long TCP connection with the control node, saving the connection relationship between the client and the corresponding server IP in real time, and synchronizing it with each service node through the control node. When a node in the SMS cluster receives a receipt message from the operator, it first attempts to obtain whether the bound TCP session connection is local based on the user code. If not, it searches the local Caffeine memory information based on the user code to find the server node where the receiving user session is located. Then, it sends a message packet containing the destination host and the receiving user information to the central node for processing. The central node forwards the receipt message to the destination host service node based on the destination host. After receiving the message, the destination host service node parses the message type, obtains the corresponding client TCP connection based on the user code read from the message, and then sends the SMS receipt information, finally completing the message sending.
[0014] Compared with the prior art, the present invention and its preferred embodiments have the following beneficial effects:
[0015] 1. Simple deployment method and low transformation cost
[0016] This innovative approach simultaneously deploys control nodes and integrates with the high-performance Caffeine cache, making deployment simple and convenient. Compared to existing systems, it only requires defining the configuration file of one node as the central node, while other service nodes use default configurations without modification. It is simple, convenient, and requires minimal code modification.
[0017] 2. Reduce system complexity and improve system reliability.
[0018] By not introducing components such as message queues, the complexity of the system is reduced, the controllability of the system is enhanced, and the stability of the system is effectively improved.
[0019] 3. High load-bearing capacity and strong lateral expansion capability
[0020] After the service node comes online, it automatically registers and goes online by maintaining a connection with the central node, which greatly enhances the cluster's automatic horizontal scaling capability and effectively improves the carrying capacity of business connections. Attached Figure Description
[0021] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments:
[0022] Figure 1 This is a network deployment architecture diagram according to an embodiment of the present invention;
[0023] Figure 2 This is a flowchart illustrating the message sending implementation of an embodiment of the present invention.
[0024] Figure 3 This is a schematic diagram of the message protocol composition according to an embodiment of the present invention;
[0025] Figure 4 This is a timing diagram for message transmission in an embodiment of the present invention. Detailed Implementation
[0026] To make the features and advantages of this patent more apparent and understandable, specific embodiments are provided below for detailed explanation:
[0027] It should be noted that the following detailed descriptions are illustrative and intended to provide further explanation of this application. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains.
[0028] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments according to this application. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.
[0029] like Figures 1-4 As shown, to achieve the above objectives, the method provided in this embodiment of the invention is as follows: each server node maintains a long TCP connection with the control node, and the connection relationship between the client and the corresponding server IP is saved in real time and synchronized to each service node through the control node. When a node in the SMS cluster receives a receipt message from the operator, it first attempts to determine whether the bound TCP session connection exists locally based on the user code. If not, it searches the local Caffeine memory information based on the user code to find the server node where the receiving user session resides. Then, it sends a message packet containing the destination host and the receiving user information to the central node for processing. The central node forwards the receipt message to the destination host service node based on the destination host. After receiving the message, the destination host service node parses the message type, obtains the corresponding client TCP connection based on the user code read from the message, and then sends the SMS receipt information, finally completing the message sending.
[0030] The foundational work for this plan includes: agreeing on the following protocols and data formats.
[0031] 1. The message protocol consists of the following components: Figure 3 As shown.
[0032] Except for the "Message Content" field, all other fields are fixed-length hexadecimal content of 4 bytes.
[0033] Command type:
[0034] Command type illustrate 0x00000001 Login Request 0x80000001 Login Response 0x00000002 Submit message 0x80000002 Submit Response 0x00000003 Forward message 0x80000003 Forwarding Response 0x00000004 Heartbeat Message 0x80000004 Heartbeat response 0x00000005 Send message 0x80000005 Send response 0x00000006 Exit Request 0x80000006 Exit Response 0x00000007 Broadcast message 0x80000007 Broadcast response other reserve
[0035] 2. Memory routing table
[0036] The in-memory routing table is based on Caffeine cache; Caffeine is a very popular Java in-memory caching framework, with single-application read / write speeds reaching millions of QPS / second, which can well meet our business needs for query performance when looking up routes. Business data is stored in memory as key-value pairs.
[0037] Naming Conventions
[0038] Key Value illustrate Session User Code Host Number Code String
[0039] The purpose of this invention is to enable inter-application TCP connections for SMS applications on a cluster server, solving the problem that when multiple SMS application clusters concurrently connect to the operator's SMS gateway, the asynchronous SMS delivery receipts from the operator's gateway randomly fall into the application cluster, and the application cannot find the corresponding client TCP connection to forward the response locally. This is achieved by using one node as a control node to forward messages from different service nodes, enabling cross-host TCP connections for SMS applications within the cluster to communicate with each other.
[0040] To achieve the above objectives, the method of the present invention is as follows: When sending a message, first attempt to determine whether the bound TCP connection exists locally based on the user code. If not, search the local Caffeine cache for the host information of the connection based on the user code. Then, send a message packet containing the destination host and the receiving user information to a control node for processing and forwarding. The control node parses the protocol packet content and forwards the message to the destination host service node based on the destination host. After receiving the message, the destination host service node obtains the local TCP connection based on the user code and then sends the information, thus completing the message sending.
[0041] The following is a detailed implementation process of the present invention.
[0042] Step 1: Change the default configuration file of the control node server to the control node type. Other service applications use the default configuration. After startup, they will all be service nodes. When the service node starts, it will send a connection request to the central node by default, maintain the long connection in real time, and pull the TCP association relationship between the control node client and the server and save it to the local memory cache information.
[0043] Step 2: When a new client connects to a service node, it will broadcast its connection and the corresponding relationship with the service node to each service node through the central node. Each service node will save the information to its local memory cache.
[0044] Step 3: Cross-host SMS application TCP connection communication. Combined with, for example... Figure 4 The provided message sequence diagram provides a detailed explanation:
[0045] Client A requests the control node to allocate connection server IP information and establishes a long TCP connection with server A. Server A saves the connection relationship between the client and itself and synchronizes it with the control node. The control node then distributes the information to other nodes to maintain information synchronization.
[0046] Client A sends a message, server A receives, parses, and forwards it to the carrier's SMS gateway. Due to the packet sending rate limitation of a single TCP connection in the SMS channel, we often deploy multiple SMS applications to concurrently connect to the carrier's SMS gateway and send SMS messages. Since the SMS sending result receipt is asynchronous, the receipt corresponding to SMS packet A might be received by an application on server B. In this case, server B cannot find the corresponding TCP connection locally, so it parses the customer ID from the receipt packet, looks up the actual TCP connection binding information in its local Caffeine cache, repackages the packet, and sends it to the control node. The control node parses the packet and forwards it to server A for processing. Server A parses the packet, finds the customer ID, locates the corresponding bound TCP connection locally, and sends the receipt result back to client A. Client A receives the SMS sending result receipt, and the process ends. This completes cross-host SMS application TCP connection communication.
[0047] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied 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.
[0048] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0049] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0050] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0051] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention in any other way. Any person skilled in the art may make changes or modifications to the above-disclosed technical content to create equivalent embodiments. However, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the protection scope of the present invention.
[0052] The above are preferred embodiments of the present invention. Any changes made to the technical solution of the present invention that do not exceed the scope of the technical solution of the present invention shall fall within the protection scope of the present invention.
[0053] This patent is not limited to the above-described preferred embodiment. Anyone can derive other various implementation methods for cross-host communication via SMS TCP connection clusters based on the inspiration of this patent. All equivalent changes and modifications made within the scope of this patent application shall fall within the scope of this patent.
Claims
1. A method for implementing cross-host communication via SMS TCP connection clusters, characterized in that: By using one node in the cluster as the control and scheduling node, and combining it with Caffeine's high-speed memory to store messages from different service nodes, mutual communication between different cross-server SMS TCP connections within the cluster can be achieved. When sending a message, the system first attempts to determine if the bound TCP connection exists locally based on the user code. If not, it searches the local Caffeine cache for the host information of the connection based on the user code. Then, it sends a message packet containing the destination host and the receiving user information to a control node for processing and forwarding. The control node parses the protocol packet content and forwards the message to the destination host service node based on the destination host. After receiving the message, the destination host service node obtains the local TCP connection based on the user code and then sends the information, thus completing the message sending process. In the SMS TCP connection cluster, each server node maintains a long TCP connection with the control node, saves the connection relationship between the client and the corresponding server IP in real time, and synchronizes it to each server node through the control node. When a node in the SMS cluster receives a receipt message from the operator, it first tries to obtain whether the bound TCP session connection is local based on the user code. If not, it searches the local Caffeine memory information based on the user code to find the server node where the user session receiving the message is located. Then, the message packet containing the destination host and the receiving user information is sent to the central node for processing. The central node forwards the receipt message to the destination host service node according to the destination host. After receiving the message, the destination host service node parses the message type, obtains the corresponding client TCP connection according to the user code read from the message, and then sends the SMS receipt information, thus completing the message sending. Because of the packet sending rate limit of a single TCP connection in the SMS channel, multiple SMS applications are deployed to concurrently connect to the operator's SMS gateway to send SMS messages. At this time, the SMS sending result receipt is asynchronous and may be received by a server node that is not connected to the client. It is necessary to look up the actual TCP connection server through the local Caffeine cache and then forward the receipt by the control node.