Multidimensional protocol fusion direct connection communication method and device
By creating and encapsulating multiple direct-connected clients on the server side to realize multi-dimensional protocol fusion, the delay, complexity and scalability problems existing in the multi-dimensional protocol fusion direct-connected communication scheme in the prior art are solved, and unified interface communication between equipment of different manufacturers is realized, reducing access complexity and cost.
Patent Information
- Application Number
- CN202411504406.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-26
- Publication Date
- 2025-03-11
AI Technical Summary
The existing multidimensional protocol fusion direct-connect communication solution has problems such as increased latency, increased system complexity, limited scalability and flexibility in protocol converters, which cannot meet users' needs for multidimensional protocol fusion direct-connect communication.
By determining multiple SMS service providers based on the business needs of the target enterprise on the server side, creating multiple direct-connected clients, and encapsulating them in a package with a unified communication interface, receiving SMS sending requests and sending SMS content through the target direct-connected client.
It realizes communication and data exchange between equipment or systems of different manufacturers through unified interfaces, avoids integration obstacles caused by incompatibility between protocols and data formats, reduces the complexity and cost of manufacturer access, and maintains the stability of the system.
Smart Images

Figure CN119603260A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a multi-dimensional protocol fusion direct connection communication method and device. Background Art
[0002] With the rapid expansion of the company's business, it faces the dual challenges of accessing many different manufacturers and meeting diverse notification needs. In traditional communication methods, different manufacturers use different communication protocols and data formats. Therefore, the company needs to invest a lot of manpower and resources to develop and maintain interfaces with each manufacturer, which increases the cost and complexity of access.
[0003] At present, the existing multi-dimensional protocol fusion direct communication solutions are mainly achieved by adding protocol converters or using middleware to perform multi-dimensional protocol fusion, which usually introduces additional delays, reduces communication efficiency, and may increase system complexity and affect system stability. In addition, the existing multi-dimensional protocol fusion direct communication solutions also support multiple communication protocols by setting up network management equipment and realize the interconnection between different devices through protocol conversion. However, this often relies on centralized gateways, which limits the scalability and flexibility of the system and cannot meet the needs of users for fusion direct communication of multi-dimensional protocols. Summary of the invention
[0004] The present application provides a multi-dimensional protocol fusion direct connection communication method. The server of the multi-dimensional protocol fusion direct connection communication system first determines multiple SMS service providers according to the business needs of the target enterprise; then creates multiple direct connection clients according to the multiple SMS service providers, and encapsulates the multiple direct connection clients in a first encapsulation package with a unified communication interface; then receives a SMS sending request from outside the system; secondly, in the first encapsulation package, determines the target direct connection client corresponding to the SMS sending request; finally, sends the SMS content to the user through the target direct connection client. It enables devices or systems from different manufacturers to communicate and exchange data through a unified interface, avoiding integration barriers caused by incompatible protocols and data formats, which is conducive to reducing the complexity and cost of manufacturer access and maintaining the stability of the system.
[0005] In a first aspect, an embodiment of the present application provides a multi-dimensional protocol fusion direct communication method, which is applied to a server of a multi-dimensional protocol fusion direct communication system, and the method comprises the following steps:
[0006] Identify multiple SMS service providers based on the target company’s business needs;
[0007] Creating a plurality of direct connection clients according to the plurality of SMS service providers, each of the direct connection clients being used to interact with at least one user through a communication protocol and a data format of a corresponding SMS service provider;
[0008] Encapsulating the plurality of directly connected clients in a first encapsulation package having a unified communication interface;
[0009] Receiving a text message sending request from outside the system, wherein the information carried in the text message sending request includes sender information, receiver information and text message content;
[0010] In the first encapsulation package, determining a target direct-connection client corresponding to the SMS sending request;
[0011] The text message content is sent to the at least one user through the target direct connection client.
[0012] In a second aspect, an embodiment of the present application provides a multi-dimensional protocol fusion direct communication device, the device comprising:
[0013] A first determination unit, used to determine a plurality of SMS service providers according to the business needs of the target enterprise;
[0014] A creating unit, configured to create a plurality of direct connection clients according to the plurality of SMS service providers, each of the direct connection clients being configured to perform information interaction with at least one user through a communication protocol and a data format of a corresponding SMS service provider;
[0015] An encapsulation unit, configured to encapsulate the plurality of directly connected clients in a first encapsulation package having a unified communication interface;
[0016] A receiving unit, configured to receive a text message sending request from outside the system, wherein the information carried in the text message sending request includes sender information, receiver information and text message content;
[0017] A second determining unit, configured to determine, in the first encapsulation package, a target direct-connection client corresponding to the SMS sending request;
[0018] A sending unit is used to send the SMS content to the at least one user through the target direct connection client.
[0019] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the program includes instructions for executing the steps in the first aspect of the embodiment of the present application.
[0020] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program / instruction stored thereon, and the computer program / instruction is executed by a processor to implement the steps of the method described in the first aspect above.
[0021] It can be seen that in the embodiment of the present application, the server first determines multiple SMS service providers according to the business needs of the target enterprise; then, creates multiple direct connection clients according to the multiple SMS service providers, each of which is used to interact with at least one user through the communication protocol and data format of the corresponding SMS service provider; then, the multiple direct connection clients are encapsulated in a first encapsulation package with a unified communication interface; secondly, a SMS sending request from outside the system is received, and the information carried by the SMS sending request includes sender information, receiver information and SMS content; again, in the first encapsulation package, the target direct connection client corresponding to the SMS sending request is determined; finally, the SMS content is sent to at least one user through the target direct connection client. Compared with the existing solution of adding a protocol converter or using middleware to perform multi-dimensional protocol fusion direct communication, there is no need to add other equipment, and multiple direct connection clients can transmit data through a unified communication interface, which is conducive to reducing the complexity and cost of user access and maintaining the stability of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0023] Figure 1 It is a system architecture diagram of a multi-dimensional protocol fusion direct communication system provided in an embodiment of the present application;
[0024] Figure 2 is a structural block diagram of an electronic device provided in an embodiment of the present application;
[0025] Figure 3 It is an overall flow chart of a multi-dimensional protocol fusion direct communication method provided in an embodiment of the present application;
[0026] Figure 4 This is a flowchart of a method for limiting concurrent request flow provided by an embodiment of the present application;
[0027] Figure 5 This is an example diagram of a connection pool management system provided in an embodiment of the present application;
[0028] Figure 6 It is a block diagram of the functional units of a multi-dimensional protocol fusion direct communication device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0029] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0030] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0031] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0032] Currently, the existing multi-dimensional protocol fusion direct communication solutions are mainly achieved by adding protocol converters or using middleware to perform multi-dimensional protocol fusion, or by setting up network management equipment to support multiple communication protocols. This usually introduces additional delays, reduces communication efficiency, and may increase system complexity and affect system stability. It cannot meet users' needs for multi-dimensional protocol fusion direct communication.
[0033] In view of the above problems, an embodiment of the present application provides a multi-dimensional protocol fusion direct communication method and device, which is described in detail below in conjunction with the accompanying drawings.
[0034] See also Figure 1 , Figure 1 is a system architecture diagram of a multi-dimensional protocol fusion direct communication system provided in an embodiment of the present application, such as Figure 1 As shown, the system architecture diagram of the multi-dimensional protocol fusion direct communication system includes a server 110, a direct client factory component 120, a direct client 130, a direct client based on a Netty framework 140, a direct client wrapper 150 and a client current limiting component 160.
[0035] Among them, the direct client factory component 120 is used to create and manage the direct client 130; and, is used to create and manage the direct client 140 based on the Netty framework; and, is used to load the client current limiting component 160 to implement concurrent request flow limit management.
[0036] The direct connection client 130 may refer to any client that directly interacts with a short message service provider, and its main function is to encapsulate the logic of sending and receiving short messages, so that external systems or applications can easily send and receive short messages. It may use a specific API or protocol to achieve communication with a short message service provider (such as China Mobile, China Unicom, etc.).
[0037] Among them, the direct connection client 140 based on the Netty framework is obtained by the direct connection client 130 through initialization settings and configuration. It can efficiently handle SMS sending and receiving tasks, and can handle a large number of concurrent connections. It focuses on communicating with SMS service providers (such as China Mobile, China Unicom, etc.) through direct connections (such as TCP or UDP) without relying on traditional HTTP protocols.
[0038] The direct client wrapper 150 is a design pattern or component for encapsulating and simplifying the interaction with clients of different communication protocols. Its main purpose is to provide a unified interface so that clients of different communication protocols can operate in a consistent manner.
[0039] The client current limiting component 160 is used to limit the number of SMS requests that can be sent by each user or each IP address within a certain period of time through a rate limiter, which helps to protect the stable operation of the system and avoid service unavailability caused by a large number of requests.
[0040] Among them, the server 110 is used to create multiple direct connection clients 130 and direct connection clients 140 based on the Netty framework according to multiple SMS service providers; and, is used to encapsulate multiple direct connection clients 130 in a first encapsulation package with a unified communication interface through a direct connection client wrapper 150; and, is used to receive an SMS sending request from outside the system, and determine the target direct connection client corresponding to the SMS sending request in the first encapsulation package; and, is used to send SMS content to the user through the target direct connection client.
[0041] It can be seen that in this embodiment, the server 110 first determines multiple SMS service providers according to the business needs of the target enterprise; then, creates multiple direct connection clients 130 according to the multiple SMS service providers; then, encapsulates the multiple direct connection clients 130 in a first encapsulation package with a unified communication interface through the direct connection client wrapper 150; secondly, after receiving the SMS sending request from outside the system, in the first encapsulation package, determines the target direct connection client corresponding to the SMS sending request; finally, sends the SMS content to the user through the target direct connection client. It enables devices or systems of different manufacturers to communicate and exchange data through a unified interface, which is conducive to avoiding integration barriers caused by incompatible communication protocols and data formats, and reduces the complexity and cost of manufacturer access.
[0042] See also Figure 2 , Figure 2 is a structural block diagram of an electronic device provided in an embodiment of the present application, for executing Figure 1 Multi-dimensional protocol fusion direct communication system in Figure 2 As shown, the electronic device 200 may include one or more of the following components: a processor 210, a memory 220 coupled to the processor 210, wherein the memory 220 may store one or more computer programs, and the one or more computer programs may be configured to implement the method described in the above embodiment when executed by one or more processors 210. The electronic device may be a mobile phone terminal, a tablet computer, a laptop computer, and a wearable smart device.
[0043] The processor 210 may include one or more processing cores. The processor 210 uses various interfaces and lines to connect various parts of the entire electronic device 200, and executes various functions and processes data of the electronic device 200 by running or executing instructions, programs, code sets or instruction sets stored in the memory 220, and calling data stored in the memory 220. Optionally, the processor 210 can be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 210 can integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing display content; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 210, but may be implemented separately through a communication chip.
[0044] The memory 220 may include a random access memory (RAM) or a read-only memory (ROM). The memory 220 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 220 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc. The data storage area may also store data created by the electronic device 200 during use, etc.
[0045] It is understandable that the electronic device 200 may include more or fewer structural elements than those in the above structural block diagram, for example, including a power module, physical buttons, a Wi-Fi module, a speaker, a Bluetooth module, a sensor, etc., which are not limited here.
[0046] See also Figure 3 , Figure 3 This is an overall flow chart of a multi-dimensional protocol fusion direct communication method provided in an embodiment of the present application, which is applied to Figure 1 The server 110 in Figure 3 As shown, the method comprises the following steps:
[0047] Step S310: determining a plurality of SMS service providers according to the business requirements of the target enterprise.
[0048] In a possible embodiment, determining a plurality of SMS service providers according to the business needs of the target enterprise includes:
[0049] Obtaining the business needs of the target enterprise;
[0050] Determine multiple cooperative vendors based on the business requirements;
[0051] Acquire the multiple SMS service providers required by the multiple partner manufacturers.
[0052] Among them, the business needs can be determined by SMS type, sending volume, target group, SMS content, sending time requirements, budget, etc. Specifically, SMS types include marketing SMS, verification code SMS, notification SMS, voice SMS, etc.; sending volume requirements refer to the expected daily, monthly or annual SMS sending volume; target group refers to the target user group for SMS sending, such as domestic users, overseas users, users in specific industries, etc.; SMS content includes the length, format, and whether personalized customization is required for SMS content; sending time requirements include real-time sending, scheduled sending, etc.; budget includes SMS fees, platform fees, technical service fees, etc.
[0053] Among them, SMS service providers can include Alibaba Cloud SMS Service, Tencent Cloud SMS Service, Baidu Cloud SMS Service, Ronglian Cloud Communications, Yimi Soft, Interconnect, China Mobile SMS Platform, China Unicom SMS Platform, China Telecom SMS Platform, etc.
[0054] It is understandable that the target enterprise needs to connect with multiple manufacturers in the daily production and operation process. Under the traditional communication mode, different manufacturers use different communication protocols and data formats, corresponding to different SMS service providers. Therefore, after the target enterprise connects to multiple manufacturers, it needs to communicate and interact with users through different SMS service providers in accordance with different communication protocols and data formats. This solution encapsulates multiple direct connection clients corresponding to the SMS service providers required by multiple manufacturers in one package, and communicates and exchanges data through a unified interface, which is conducive to avoiding integration barriers caused by incompatible communication protocols and data formats.
[0055] Step S320: creating multiple direct connection clients according to the multiple SMS service providers, each of the direct connection clients being used to perform information exchange with at least one user through a communication protocol and a data format of a corresponding SMS service provider.
[0056] In a possible embodiment, the creating multiple direct connection clients according to the multiple SMS service providers includes:
[0057] Acquire configuration parameters according to the configuration files provided by the multiple SMS service providers;
[0058] Create a direct client factory component according to the configuration parameters;
[0059] Get client connection parameters and direct connection configuration files;
[0060] The direct connection client factory component creates the multiple direct connection clients according to the client connection parameters and the direct connection configuration file.
[0061] Among them, the configuration parameters include the URLs, user names, passwords and ports of the multiple SMS service providers; and the client connection parameters include the host name, port, user name, password, database name, etc.; and the direct connection configuration file includes the server address and port number, authentication information, connection timeout settings, and other custom settings, such as proxy configuration, retry strategy, etc.
[0062] Among them, a direct client refers to a client program that communicates directly with a server. This type of client does not need to forward requests through middleware or other services, but directly sends requests to the target server. This method is usually used in scenarios such as database connections, message queues, and remote procedure calls (RPCs). The direct client described in the embodiment of the present application can be a direct client based on the Netty framework.
[0063] It can be seen that in this embodiment, after the server determines the SMS service provider, it further obtains the configuration file provided by the SMS service provider, thereby creating a direct client factory component based on the configuration file, and then creating multiple direct clients through the direct client factory component. The multiple direct clients correspond one-to-one to the multiple SMS service providers, thereby realizing the creation of the direct client, and the target enterprise can interact with the user through SMS through the direct client.
[0064] Step S330: encapsulate the multiple directly connected clients in a first encapsulation package with a unified communication interface.
[0065] In a possible embodiment, encapsulating the plurality of directly connected clients in a first encapsulation package having a unified communication interface includes:
[0066] Create an adapter class for each of the direct connection clients;
[0067] Converting the multiple direct-connection client interfaces into the unified communication interface through the multiple adapter classes;
[0068] Creating a wrapper class for the plurality of direct connection clients;
[0069] The multiple direct connection clients are encapsulated in the first encapsulation package through the wrapper class.
[0070] Before converting the interfaces of the multiple direct-connected clients into the unified communication interface through the multiple adapter classes, the unified communication interface is determined according to the multiple direct-connected clients. The unified communication interface can perform all necessary operations, such as sending text messages, querying status, setting callbacks, etc.
[0071] The adapter class can be managed using the strategy mode or the factory mode, so when a new SMS service provider needs to be added, only a new adapter needs to be added.
[0072] Among them, the direct-connected client communicates and interacts through a unified communication interface, and the method also includes: encoding and decoding the data packets transmitted during the communication process through a data packet encoder and a data packet decoder; adapting the received data to the business logic processing program through a data receiving adapter to ensure that the data can be correctly processed by the application; and recombining the split data packets into complete data packets through a data packet unpacking processor.
[0073] It can be understood that the adapter class implements the unified interface and uses the respective communication protocols internally to interact with the corresponding SMS service provider; the wrapper class is responsible for managing and maintaining all adapter instances. When the user calls a method through the unified communication interface, the wrapper class selects the appropriate adapter to process the SMS sending request. In this way, users only need to interact with the direct client wrapper to use any supported SMS service.
[0074] Step S340: receiving a text message sending request from outside the system, wherein the information carried in the text message sending request includes sender information, receiver information and text message content.
[0075] In a possible embodiment, the receiving a text message sending request from outside the system includes:
[0076] Create and initialize a token bucket through a client current limiting component, wherein the token bucket is used to generate and consume tokens to perform current limiting processing on the SMS sending request;
[0077] Configuring the token bucket according to preset configuration parameters, wherein the configuration parameters include a token generation rate and a token bucket capacity;
[0078] When the SMS sending request is detected to enter the gateway layer, if it is checked that there is an available token in the token bucket, the SMS sending request is controlled to continue to be transmitted to the system, and one token is reduced; and,
[0079] If it is found that there is no available token in the token bucket, the SMS sending request is intercepted, and an error message is fed back to the sender of the SMS sending request to instruct the sender to resend the SMS sending request;
[0080] The SMS sending request is received.
[0081] Among them, the client-side current limiting component is used to control the frequency of SMS sending requests, and is usually integrated into the direct client factory component as a plug-in or module.
[0082] Among them, the token bucket is an algorithm for network traffic shaping and rate limiting. It is mainly used to control the rate of data transmission, ensure the rational use of network resources, and prevent network congestion. In many scenarios, such as API call restrictions and SMS sending restrictions, the token bucket algorithm has been widely used. The token bucket is a virtual container used to store tokens, each token represents the permission for a data packet or a certain amount of data to be sent.
[0083] Among them, the SMS sending request comes from the outside of the multi-dimensional protocol fusion direct communication system, such as third-party services, mobile applications, web applications, etc. External requests need to undergo identity authentication and permission checks to ensure the legitimacy and security of the request. In addition, the SMS sending request can also come from within the system, which may be initiated by a component or service within the system, such as the business logic module within the system, such as the order processing system automatically sending a confirmation SMS after the user completes the purchase, the system's monitoring or alarm service, sending a notification SMS when a specific event is detected, and the system's automatic reply function, such as the customer service robot automatically replying to user inquiries. Internal requests can usually access system resources more directly, but still need to follow the corresponding security and permission control.
[0084] It is understandable that tokens are added to the bucket at a fixed rate. This rate is usually set by the system administrator or service provider to control the maximum rate of data transmission. When a text message request needs to be sent, it must take out the corresponding number of tokens from the bucket. If there are enough tokens in the bucket, the text message request can be sent; if there are not enough tokens in the bucket, the text message request needs to wait until there are enough tokens available. The maximum capacity of the token bucket determines the maximum number of tokens that can be stored, which usually corresponds to the maximum burst data volume.
[0085] Step S350: determining, in the first encapsulation package, a target direct-connection client corresponding to the SMS sending request.
[0086] In a possible embodiment, determining, in the first encapsulation package, a target direct-connection client corresponding to the SMS sending request includes:
[0087] Create a routing key for each direct-connected client through the direct-connected client factory component, where the routing key is used to indicate the SMS service provider corresponding to each direct-connected client;
[0088] Determine a mapping relationship data set between the direct connection client and the SMS service provider according to the routing key;
[0089] Determine the target routing key corresponding to the SMS sending request according to the information carried by the SMS sending request;
[0090] Determine a target mapping relationship in the mapping relationship data set according to the target routing key;
[0091] The target direct-connection client is determined according to the target mapping relationship.
[0092] The routing key is a unique identifier used to identify a specific routing or client instance, which can be used as a basis for identifying different SMS service providers or different lines. The routing key can be constructed based on multiple factors, such as the target number, SMS type, priority, region, etc. A unique routing key can be generated using a hash algorithm or other methods.
[0093] Among them, in the direct client factory component, a mapping relationship from a routing key to a short message service provider is maintained for each created direct client instance, and a mapping relationship data set is obtained. Data structures such as Map and HashMap can be used to store this mapping relationship.
[0094] Among them, if there are multiple direct client instances associated with the same routing key, load balancing strategies such as polling and weighted polling can be used to select the appropriate instance to evenly distribute SMS sending requests to different direct client instances; and if a direct client instance is monitored to have a failure, it can be removed from the routing key mapping, and when a new SMS sending request arrives, it will be automatically routed to other available direct client instances.
[0095] It can be seen that in this embodiment, the direct client factory component constructs a mapping relationship data set between the direct client and the SMS service provider through the routing key, and determines the corresponding target routing key according to the information carried in the SMS sending request, and then determines the target mapping relationship in the mapping relationship data set, and determines the target direct client according to the target mapping relationship, thereby realizing flexible selection and determination of the target direct client, and realizing load balancing and failover, thereby improving the performance and reliability of the system.
[0096] Step S360: Send the SMS content to the at least one user through the target direct connection client.
[0097] In a possible embodiment, sending the SMS content to the at least one user through the target direct connection client includes:
[0098] Determine a target SMS service provider corresponding to the target direct-connection client according to the target mapping relationship;
[0099] Obtaining a target communication protocol and a target data format corresponding to the target SMS service provider;
[0100] Formatting the SMS sending request according to the target data format to obtain a standard SMS sending request; and sending the standard SMS sending request to the target SMS service provider according to the target communication protocol;
[0101] The target SMS service provider receives the standard SMS sending request, and sends the SMS content carried in the standard SMS sending request to the at least one user.
[0102] Among them, the communication protocols may include SMPP (Short Message Peer-to-Peer), HTTP / HTTPS, SMTP (Simple Mail Transfer Protocol), MQTT (Message Queuing Telemetry Transport), WebSocket, etc.; and the data format may include PDU (Protocol Data Unit), XML, JSON, etc.
[0103] Among them, in the process of sending SMS content, the system can realize the review and control of sensitive variables of the message through intelligent message security management. When the message content is output, sensitive content is automatically identified and desensitized to avoid information leakage. For SMS with sensitive content, direct connection to the operator channel is selected for sending after intelligent traffic calculation, thereby improving system security.
[0104] It can be understood that the SMS sending request is sent by the target client to the target SMS service provider. After receiving the SMS sending request, the target SMS service provider processes the SMS sending request according to the required communication protocol and data format, and sends the SMS content to the user, thereby realizing SMS interaction between the target client and the user through a unified communication interface, which is conducive to reducing the complexity and cost of manufacturer access.
[0105] In a possible embodiment, the target direct connection client and the target SMS service provider complete information exchange through a target database connection, and the standard SMS sending request is sent to the target SMS service provider according to the target communication protocol. The method includes:
[0106] Creating a connection pool, and storing a first number of pre-created database connections in the connection pool;
[0107] Create and initialize a daemon thread through a thread factory, where the daemon thread is used to manage and monitor the connection pool;
[0108] Monitoring the availability and occupancy status of the plurality of database connections through the daemon thread;
[0109] If it is detected that there is an available idle connection, one of the idle connections is determined as the target database connection; and,
[0110] If it is detected that there is no available idle connection, determining the target database connection according to the first number;
[0111] The target direct connection client sends the standard SMS sending request to the target SMS service provider according to the target communication protocol through the target database connection.
[0112] In a possible embodiment, determining the target database connection according to the first quantity includes:
[0113] If it is detected that the first number is less than a preset threshold, creating a new database connection in the connection pool as the target database connection; and,
[0114] If it is detected that the first number is equal to the preset threshold, the daemon thread continues to monitor until there is an available idle connection in the connection pool, and then one of the idle connections is determined as the target database connection.
[0115] Among them, connection pool is a technology for managing database connections, which allows applications to reuse established database connections when needed instead of creating new connections each time; database connection refers to a long connection between a direct client and a SMS service provider.
[0116] Among them, the daemon thread is a special background thread that runs throughout the life cycle of the application and will not be directly called by user code. The daemon thread is responsible for managing and monitoring the connection pool. It can establish, maintain and close database connections, and dynamically adjust the number of connections according to demand to ensure the health of the connection pool.
[0117] The preset threshold is used to represent the maximum number of database connections that the connection pool can accommodate.
[0118] Exemplarily, the connection pool may include a plurality of pre-created database connections, the number of which is 10. The daemon thread monitors the availability and occupancy status of the 10 database connections. If it is monitored that 6 connections are occupied and 4 connections are not occupied and are in an available state, an idle connection is allocated to the target direct-connected client from the 4 connections; and, if it is monitored that all 10 connections are occupied, or the unoccupied connections are all in an unavailable state, then a further comparison is made between the number 10 and a preset threshold, which may be 12. Then, a new database connection is created in the connection pool and allocated to the target direct-connected client. And, if the preset threshold is 10, then wait for an available unoccupied connection to appear in the connection pool.
[0119] It can be seen that in this embodiment, in the process of the target direct-connected client sending SMS content to the user through the target SMS service provider, the connection pool is managed through the daemon thread, and a database connection is allocated to the target direct-connected client to realize the SMS interaction process. This can solve the problem of frequent establishment and closing of database connections in high-concurrency scenarios, which leads to reduced system performance and response speed, and is conducive to improving system stability and reducing performance loss.
[0120] See also Figure 4 , Figure 4 A flowchart of a method for limiting concurrent request flow provided in an embodiment of the present application is shown in FIG. Figure 4 As shown, the method comprises the following steps:
[0121] Step S401, receiving a text message sending request.
[0122] Among them, the SMS sending request comes from outside the multi-dimensional protocol fusion direct communication system, such as third-party services, mobile applications, web applications, etc. External requests need to undergo identity authentication and permission checks to ensure the legitimacy and security of the request.
[0123] Among them, SMS sending requests can also come from within the system, which may be initiated by a component or service within the system, such as the business logic module within the system, such as the order processing system automatically sending a confirmation SMS after the user completes the purchase, the system's monitoring or alarm service, sending a notification SMS when a specific event is detected, and the system's automatic reply function, such as the customer service robot automatically replying to user inquiries, etc. Internal requests can usually access system resources more directly, but they still need to follow the corresponding security and permission controls.
[0124] Step S402: Obtain a token from a designated direct client token bucket.
[0125] In one embodiment, before obtaining a token from a designated direct client token bucket, the method further includes:
[0126] Create and initialize a token bucket through a client current limiting component, wherein the token bucket is used to generate and consume tokens to perform current limiting processing on the SMS sending request;
[0127] Configuring the token bucket according to preset configuration parameters, wherein the configuration parameters include a token generation rate and a token bucket capacity;
[0128] It is monitored that the SMS sending request enters the gateway layer.
[0129] Among them, the token bucket is an algorithm for network traffic shaping and rate limiting. It is mainly used to control the rate of data transmission, ensure the rational use of network resources, and prevent network congestion; and the token bucket is a virtual container used to store tokens, each token represents the permission for a data packet or a certain amount of data to be sent.
[0130] Step S403: whether the token is obtained.
[0131] If the token is obtained, step S404 is executed; and if the token is not obtained, step S407 is executed.
[0132] Step S404, the number of tokens in the token bucket -1.
[0133] In one embodiment, obtaining the token includes:
[0134] Checking that there are available tokens in the token bucket;
[0135] Controlling the SMS sending request to continue to be transmitted to the system;
[0136] The SMS sending request takes away a token when passing through the gateway layer.
[0137] Step S405, executing the business code.
[0138] Among them, the business code is used to check the token availability, execute the SMS sending logic, including connecting to the SMS sending service, building the SMS content, setting the sending target and other operations, and to process the sending results of the SMS sending request, including checking whether the SMS sending request is sent successfully, recording the sending record, notifying relevant personnel and other operations.
[0139] The SMS sending request will continue to be transmitted from the gateway layer to the multi-dimensional protocol fusion communication system until the system receives the SMS sending request.
[0140] Step S406, return the result.
[0141] Among them, after obtaining the token, the SMS sending request continues to be transmitted and sent to the system. According to the business code, it can be checked whether the SMS sending request is successfully sent, and the sending result is returned to the sender of the SMS request.
[0142] Step S407, obtaining a token from a token bucket of another directly connected client of the same SMS type.
[0143] In one embodiment, obtaining a token from a token bucket of another directly connected client of the same SMS type includes:
[0144] Checking that there are no available tokens in the token bucket;
[0145] Intercept SMS sending requests;
[0146] Obtain an alternative token bucket having the same SMS type as the SMS type of the SMS sending request;
[0147] The token is obtained from the candidate token bucket.
[0148] Among them, the SMS types may include verification code SMS, notification SMS, marketing SMS, service notification SMS, emergency SMS and subscription SMS, etc.
[0149] Step S408: whether the token is obtained.
[0150] If a token is obtained from the token bucket of other directly connected clients of the same SMS type, step S404 is executed; and if a token is not obtained from the token bucket of other directly connected clients of the same SMS type, step S409 is executed.
[0151] Step S409, return error information.
[0152] Among them, when it is checked that there is still no valid token in the token bucket of other directly connected clients of the same SMS type, the SMS sending request cannot obtain the token, and the SMS sending request is still intercepted and cannot be passed to the system, that is, the SMS sending request fails. The server will record the sending failure information, and feedback the sending failure information to the sender of the SMS request, and return an error message.
[0153] It can be seen that in this embodiment, when the SMS sending request reaches the gateway layer, a token will be obtained from the specified token bucket. If the token is not obtained, the token will be obtained from the token bucket of other directly connected clients of the same SMS type. Each SMS sending request obtains a token, and after obtaining the token, it can continue to be passed to the system. If the acquisition fails, it will be intercepted, that is, the sending fails. The server will return the sending result to the sender, thereby realizing the limiting management of concurrent request traffic based on the client-side current limiting component, effectively protecting the system from the impact of sudden traffic, and helping to improve the stability and availability of the system.
[0154] See also Figure 5 , Figure 5 An example diagram of a connection pool management system provided in an embodiment of the present application, such as Figure 5 As shown, the connection pool management system includes a direct connection client, a connection pool and a short message gateway.
[0155] Among them, connection pool is a technology for managing database connections, which allows applications to reuse established database connections when needed instead of creating new connections each time; database connection refers to the long connection between the direct client and the SMS service provider; and,
[0156] The connection pool can create a certain number of database connections based on multiple direct-connection clients to obtain connections, and store multiple database connections in the connection pool. After the target direct-connection client is determined, an idle connection is allocated to the target direct-connection client for communication interaction; and the connection pool can communicate bidirectionally with the SMS gateway, can actively send data to the SMS gateway, and can also receive data pushed by the SMS gateway.
[0157] The connection pool is managed and detected through a daemon thread. A daemon thread is a special background thread that runs throughout the life cycle of the application and is not directly called by user code. It can regularly check the connection status in the connection pool, delete invalid connections, create new connections, and dynamically adjust the number of connections based on demand to ensure the health of the connection pool.
[0158] Specifically, in the connection pool, the database connection can realize two-way communication with the SMS gateway based on NettyChannel. In the embodiment of the present application, the direct connection client can be a direct connection client based on the Netty framework. In the Netty framework, NettyChannel usually refers to a network communication channel, which represents a connection between a client and a server. The Netty framework is a high-performance network application framework for rapid development of maintainable network applications. It provides an asynchronous, event-driven network application framework and tools.
[0159] It can be seen that in this embodiment, in the process of the target direct connection client sending SMS content to the user through the target SMS service provider, the connection pool is managed by the daemon thread, unavailable connections are deleted, and new connections are created. Two-way communication with the SMS gateway is achieved through the NettyChannel channel, which can avoid the problem of frequently establishing and closing database connections in high-concurrency scenarios, and is conducive to improving system performance and response speed.
[0160] See also Figure 6 , Figure 6A functional unit block diagram of a multi-dimensional protocol fusion direct communication device 600 provided in an embodiment of the present application is shown in FIG. Figure 6 As shown, the multi-dimensional protocol fusion direct communication device 600 includes the following units:
[0161] A first determining unit 610 is used to determine a plurality of SMS service providers according to the business requirements of the target enterprise;
[0162] A creating unit 620, configured to create a plurality of direct connection clients according to the plurality of SMS service providers, each of the direct connection clients being configured to perform information interaction with at least one user through a communication protocol and a data format of a corresponding SMS service provider;
[0163] The encapsulation unit 630 is used to encapsulate the multiple directly connected clients in a first encapsulation package having a unified communication interface;
[0164] The receiving unit 640 is used to receive a text message sending request from outside the system, where the information carried in the text message sending request includes sender information, receiver information and text message content;
[0165] A second determining unit 650 is used to determine, in the first encapsulation package, a target direct-connection client corresponding to the SMS sending request;
[0166] The sending unit 660 is configured to send the SMS content to the at least one user via the target direct connection client.
[0167] In one embodiment, encapsulating the plurality of directly connected clients in a first encapsulation package having a unified communication interface includes:
[0168] Create an adapter class for each of the direct connection clients;
[0169] Converting the multiple direct-connection client interfaces into the unified communication interface through the multiple adapter classes;
[0170] Creating a wrapper class for the plurality of direct connection clients;
[0171] The multiple direct connection clients are encapsulated in the first encapsulation package through the wrapper class.
[0172] In one embodiment, receiving a text message sending request from outside the system includes:
[0173] Create and initialize a token bucket through a client current limiting component, wherein the token bucket is used to generate and consume tokens to perform current limiting processing on the SMS sending request;
[0174] Configuring the token bucket according to preset configuration parameters, wherein the configuration parameters include a token generation rate and a token bucket capacity;
[0175] When the SMS sending request is detected to enter the gateway layer, if it is checked that there is an available token in the token bucket, the SMS sending request is controlled to continue to be transmitted to the system, and one token is reduced; and,
[0176] If it is found that there is no available token in the token bucket, the SMS sending request is intercepted, and an error message is fed back to the sender of the SMS sending request to instruct the sender to resend the SMS sending request;
[0177] The SMS sending request is received.
[0178] In one embodiment, determining, in the first encapsulation package, a target direct-connection client corresponding to the SMS sending request includes:
[0179] Create a routing key for each direct-connected client through the direct-connected client factory component, where the routing key is used to indicate the SMS service provider corresponding to each direct-connected client;
[0180] Determine a mapping relationship data set between the direct connection client and the SMS service provider according to the routing key;
[0181] Determine the target routing key corresponding to the SMS sending request according to the information carried by the SMS sending request;
[0182] Determine a target mapping relationship in the mapping relationship data set according to the target routing key;
[0183] The target direct-connection client is determined according to the target mapping relationship.
[0184] In one embodiment, sending the SMS content to the at least one user through the target direct connection client includes:
[0185] Determine a target SMS service provider corresponding to the target direct-connection client according to the target mapping relationship;
[0186] Obtaining a target communication protocol and a target data format corresponding to the target SMS service provider;
[0187] Formatting the SMS sending request according to the target data format to obtain a standard SMS sending request; and sending the standard SMS sending request to the target SMS service provider according to the target communication protocol;
[0188] The target SMS service provider receives the standard SMS sending request, and sends the SMS content carried in the standard SMS sending request to the at least one user.
[0189] In one embodiment, the target direct connection client and the target SMS service provider complete information exchange through a target database connection, and the standard SMS sending request is sent to the target SMS service provider according to the target communication protocol. The method includes:
[0190] Creating a connection pool, and storing a first number of pre-created database connections in the connection pool;
[0191] Create and initialize a daemon thread through a thread factory, where the daemon thread is used to manage and monitor the connection pool;
[0192] Monitoring the availability and occupancy status of the plurality of database connections through the daemon thread;
[0193] If it is detected that there is an available idle connection, one of the idle connections is determined as the target database connection; and,
[0194] If it is detected that there is no available idle connection, determining the target database connection according to the first number;
[0195] The target direct connection client sends the standard SMS sending request to the target SMS service provider according to the target communication protocol through the target database connection.
[0196] In one embodiment, determining the target database connection according to the first quantity includes:
[0197] If it is detected that the first number is less than a preset threshold, creating a new database connection in the connection pool as the target database connection; and,
[0198] If it is detected that the first number is equal to the preset threshold, the daemon thread continues to monitor until there is an available idle connection in the connection pool, and then one of the idle connections is determined as the target database connection.
[0199] It can be understood that since the method embodiment and the device embodiment are different presentation forms of the same technical concept, the content of the method embodiment part in this application should be synchronously adapted to the device embodiment part and will not be repeated here.
[0200] It can be seen that the server of the device first determines multiple SMS service providers according to the business needs of the target enterprise; then, creates multiple direct connection clients according to the multiple SMS service providers; then, encapsulates the multiple direct connection clients in a first encapsulation package with a unified communication interface; secondly, receives an SMS sending request from outside the system, and the information carried by the SMS sending request includes sender information, receiver information and SMS content; thirdly, determines the target direct connection client corresponding to the SMS sending request in the first encapsulation package; finally, sends the SMS content to the user through the target direct connection client. It realizes data transmission between multiple direct connection clients through a unified communication interface, which is conducive to reducing the complexity and cost of manufacturer access and maintaining the stability of the system.
[0201] In addition, an embodiment of the present application also provides a computer storage medium, which stores a computer program that can be loaded by a processor and executed as described above for the multi-dimensional protocol fusion direct communication method. The computer-readable storage medium includes, for example: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0202] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0203] In the several embodiments provided in the present application, it should be understood that the disclosed methods, devices and systems can be implemented in other ways. For example, the device embodiments described above are merely schematic; for example, the division of the units is only a logical function division, and there may be other division methods in actual implementation; for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0204] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0205] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may be physically included separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0206] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform some steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a volatile memory or a non-volatile memory. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM) or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (double data rate SDRAM, DDR SDRAM), enhanced synchronous dynamic random access memory (enhanced SDRAM, ESDRAM), synchronous link dynamic random access memory (synchlink DRAM, SLDRAM) and direct memory bus random access memory (directrambus RAM, DR RAM) and other media that can store program code.
[0207] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0208] The embodiments of the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of the present application. At the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
[0209] Although the present application is disclosed as above, the present application is not limited thereto. Any person skilled in the art can easily think of changes or substitutions without departing from the spirit and scope of the present application, and can make various changes and modifications, including the combination of the above-mentioned different functions and implementation steps, including software and hardware implementation methods, all of which are within the scope of protection of the present application.
Claims
1. A multi-dimensional protocol fusion direct communication method, applied to a server of a multi-dimensional protocol fusion direct communication system, characterized in that: The method comprises: Identify multiple SMS service providers based on the target company’s business needs; Creating a plurality of direct connection clients according to the plurality of SMS service providers, each of the direct connection clients being used to interact with at least one user through a communication protocol and a data format of a corresponding SMS service provider; Encapsulating the plurality of directly connected clients in a first encapsulation package having a unified communication interface; Receiving a text message sending request from outside the system, wherein the information carried in the text message sending request includes sender information, receiver information and text message content; In the first encapsulation package, determining a target direct-connection client corresponding to the SMS sending request; The text message content is sent to the at least one user through the target direct connection client.
2. The method according to claim 1, characterized in that The step of determining, in the first encapsulation package, a target direct-connection client corresponding to the SMS sending request comprises: Create a routing key for each direct-connected client through the direct-connected client factory component, where the routing key is used to indicate the SMS service provider corresponding to each direct-connected client; Determine a mapping relationship data set between the direct connection client and the SMS service provider according to the routing key; Determine the target routing key corresponding to the SMS sending request according to the information carried by the SMS sending request; Determine a target mapping relationship in the mapping relationship data set according to the target routing key; The target direct-connection client is determined according to the target mapping relationship.
3. The method according to claim 2, characterized in that The sending the SMS content to the at least one user through the target direct connection client includes: Determine a target SMS service provider corresponding to the target direct-connection client according to the target mapping relationship; Obtaining a target communication protocol and a target data format corresponding to the target SMS service provider; Formatting the SMS sending request according to the target data format to obtain a standard SMS sending request; and sending the standard SMS sending request to the target SMS service provider according to the target communication protocol; The target SMS service provider receives the standard SMS sending request, and sends the SMS content carried in the standard SMS sending request to the at least one user.
4. The method according to claim 3, characterized in that The target direct connection client and the target SMS service provider complete information exchange through a target database connection, and the standard SMS sending request is sent to the target SMS service provider according to the target communication protocol. The method includes: Creating a connection pool, and storing a first number of pre-created database connections in the connection pool; Create and initialize a daemon thread through a thread factory, where the daemon thread is used to manage and monitor the connection pool; Monitoring the availability and occupancy status of the plurality of database connections through the daemon thread; If it is detected that there is an available idle connection, one of the idle connections is determined as the target database connection; and, If it is detected that there is no available idle connection, determining the target database connection according to the first number; The target direct connection client sends the standard SMS sending request to the target SMS service provider according to the target communication protocol through the target database connection.
5. The method according to claim 4, characterized in that The determining the target database connection according to the first quantity includes: If it is detected that the first number is less than a preset threshold, creating a new database connection in the connection pool as the target database connection; and, If it is detected that the first number is equal to the preset threshold, the daemon thread continues to monitor until there is an available idle connection in the connection pool, and then one of the idle connections is determined as the target database connection.
6. The method according to claim 5, characterized in that The receiving of a text message sending request from outside the system includes: Create and initialize a token bucket through a client current limiting component, wherein the token bucket is used to generate and consume tokens to perform current limiting processing on the SMS sending request; Configuring the token bucket according to preset configuration parameters, wherein the configuration parameters include a token generation rate and a token bucket capacity; When the SMS sending request is detected to enter the gateway layer, if it is checked that there is an available token in the token bucket, the SMS sending request is controlled to continue to be transmitted to the system, and one token is reduced; and, If it is found that there is no available token in the token bucket, the SMS sending request is intercepted, and an error message is fed back to the sender of the SMS sending request to instruct the sender to resend the SMS sending request; The SMS sending request is received.
7. The method according to any one of claims 2 to 6, characterized in that: The step of encapsulating the plurality of directly connected clients in a first encapsulation package having a unified communication interface includes: Create an adapter class for each of the direct connection clients; Converting the multiple direct-connection client interfaces into the unified communication interface through the multiple adapter classes; Creating a wrapper class for the plurality of direct connection clients; The multiple direct connection clients are encapsulated in the first encapsulation package through the wrapper class.
8. A multi-dimensional protocol fusion direct connection communication device, applied to a server of a multi-dimensional protocol fusion direct connection communication system, characterized in that: include: A first determination unit is used to determine a plurality of SMS service providers according to the business requirements of the target enterprise; A creating unit, configured to create a plurality of direct connection clients according to the plurality of SMS service providers, each of the direct connection clients being configured to perform information interaction with at least one user through a communication protocol and a data format of a corresponding SMS service provider; An encapsulation unit, configured to encapsulate the plurality of directly connected clients in a first encapsulation package having a unified communication interface; A receiving unit, configured to receive a text message sending request from outside the system, wherein the information carried in the text message sending request includes sender information, receiver information and text message content; A second determining unit, configured to determine, in the first encapsulation package, a target direct-connection client corresponding to the SMS sending request; A sending unit is used to send the SMS content to the at least one user through the target direct connection client.
9. An electronic device, characterized in that: The method comprises a processor, a memory, a communication interface and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the programs include instructions for executing the steps in any one of the methods of claims 1 to 7.
10. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: The computer program / instructions are executed by a processor to implement the steps of the method according to any one of claims 1 to 7.