CMPP protocol short message adaptation method and device, equipment and storage medium
The unified access and processing of CMPP, SMGP and SGIP protocols are realized through the CMPP protocol adaptation method, which solves the problem of protocol incompatibility among operators, improves SMS sending efficiency and system scalability, simplifies status reporting processing, and reduces Cost and complexity.
Patent Information
- Application Number
- CN202411483795.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-23
- Publication Date
- 2024-11-22
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The incompatibility of SMS protocols between different operators leads to low efficiency and reliability of SMS transmission across operators, increasing development and maintenance costs, and the differences in status reporting and error code formats complicate unified management.
Using the CMPP protocol adaptation method, the customer account information and system parameters are loaded through the adapter, and unified access and processing of CMPP, SMGP and SGIP protocols are realized, and the operator type is automatically identified for protocol conversion is improved. Efficiency, and improve security and scalability through XML configuration files and MD5/SHA-256 authentication mechanism.
Simplifies the system architecture, reduces development and maintenance costs, improves the accuracy and efficiency of SMS sending, achieves high concurrency processing capabilities, enhances the system's configurability and security, and supports scalability of operators and protocol types sex.
Smart Images

Figure CN119012146A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of short message sending, and in particular to a CMPP protocol short message adaptation method, device, equipment and storage medium. Background Art
[0002] With the rapid development of mobile communication technology and the widespread application of SMS services, SMS intercommunication between different operators has become an important demand. However, since major operators adopt different SMS protocol standards, such as China Mobile's CMPP, China Telecom's SMGP and China Unicom's SGIP, cross-operator SMS sending faces the problem of protocol incompatibility. This protocol difference not only increases development and maintenance costs, but also affects the efficiency and reliability of SMS services.
[0003] At the same time, many enterprises and service providers need to connect to the SMS gateways of multiple operators at the same time to achieve full network coverage of SMS sending capabilities. This requires them to maintain multiple sets of protocol interfaces at the same time, greatly increasing the complexity and operating costs of the system. In addition, there are differences in status report formats and error codes between different protocols, which brings challenges to unified SMS status management and error handling. Summary of the invention
[0004] The present invention provides a CMPP protocol short message adaptation method, device, equipment and storage medium. The present invention can seamlessly convert different protocol formats, uniformly process various status reports, and provide efficient and reliable short message sending services.
[0005] A first aspect of the present invention provides a CMPP protocol SMS adaptation method, the CMPP protocol SMS adaptation method comprising: Load customer account information and system parameters, initialize CMPP, SMGP, and SGIP adapters, and start CMPP listening service; Receive the client CMPP_CONNECT request, verify the client account information, generate a session identifier, and send a CMPP_CONNECT_RESP response; Receive the CMPP_SUBMIT request, parse the message content according to the customer account information, determine the target number operator type, create an SMS task object and put it into the priority queue; Obtain the SMS task object from the priority queue, convert the CMPP protocol into the target protocol according to the operator type, generate a protocol message object and put it into the corresponding sending queue; Obtain the protocol message object from the sending queue through the CMPP, SMGP and SGIP adapters, establish a connection with the operator gateway, send a message and receive a response; Receive the operator status report, find the corresponding SMS task object, convert the status code, construct a CMPP_DELIVER message and send it to the client.
[0006] A second aspect of the present invention provides a CMPP protocol SMS adaptation device, the CMPP protocol SMS adaptation device comprising: Initialization module, used to load customer account information and system parameters, initialize CMPP, SMGP and SGIP adapters, and start CMPP monitoring service; A receiving module, configured to receive a CMPP_CONNECT request from a client, verify the client account information, generate a session identifier, and send a CMPP_CONNECT_RESP response; A creation module is used to receive a CMPP_SUBMIT request, parse the message content according to the customer account information, determine the target number operator type, create an SMS task object and put it into a priority queue; An acquisition module, used to acquire the SMS task object from the priority queue, convert the CMPP protocol into a target protocol according to the operator type, generate a protocol message object and put it into a corresponding sending queue; Establishing a module, used to obtain the protocol message object from the sending queue through the CMPP, SMGP and SGIP adapters, establish a connection with the operator gateway, send a message and receive a response; The sending module is used to receive the operator status report, find the corresponding SMS task object, convert the status code, construct a CMPP_DELIVER message and send it to the client.
[0007] A third aspect of the present invention provides an electronic device, comprising: a memory and at least one processor, wherein the memory stores instructions; the at least one processor calls the instructions in the memory so that the electronic device executes the above-mentioned CMPP protocol SMS adaptation method.
[0008] A fourth aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the above-mentioned CMPP protocol SMS adaptation method.
[0009] Compared with the prior art, the present invention has the following beneficial effects: through the CMPP protocol adapter, unified access and processing of the three protocols of CMPP, SMGP and SGIP are realized, the system architecture is simplified, and the development and maintenance costs are reduced. The operator type is automatically identified according to the target mobile phone number, and the corresponding protocol is selected for conversion, which improves the accuracy and efficiency of SMS sending. The priority queue and multi-threading technology are adopted to achieve high concurrent SMS processing capability and significantly improve the throughput of the system. The mapping relationship between customer accounts, system parameters and status codes is managed through the XML configuration file, which enhances the configurability and maintainability of the system. The authentication mechanism based on MD5 and SHA-256 is introduced to enhance the security of client connection and effectively prevent unauthorized access. Through the unified status code mapping mechanism, the consistency processing of status reports of different operators is realized, and the subsequent status tracking and error handling process is simplified. The connection with the operator gateway is managed by the connection pool technology, which reduces the overhead of connection establishment and disconnection and improves the resource utilization efficiency. The system architecture design supports the addition of new operators and protocol types, has good scalability, and can adapt to future changes in business needs. The core logic such as protocol conversion and status report processing is separated from the specific business processing, which improves the modularity and code reusability of the system. By monitoring and logging each processing link, comprehensive system operation status and performance indicators are provided to facilitate problem diagnosis and performance optimization. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the embodiments of the present invention 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 invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0011] The structures, proportions, sizes, etc. illustrated in the drawings of this specification are only used to match the contents disclosed in the specification so as to facilitate understanding and reading by persons familiar with this technology. They are not used to limit the conditions under which the present invention can be implemented, and therefore have no substantive technical significance. Any structural modification, change in proportion or adjustment of size, without affecting the effects and purposes that can be achieved by the present invention, should still fall within the scope of the technical contents disclosed by the present invention.
[0012] Figure 1 It is a flowchart of a CMPP protocol SMS adaptation method provided by an embodiment of the present invention; Figure 2 is a schematic block diagram of the structure of a CMPP protocol SMS adaptation device provided by an embodiment of the present invention; Figure 3It is a schematic block diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0013] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0014] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.
[0015] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0016] It should be further understood that the term "and / or" used in the present specification and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations. Figure 1 An embodiment of the CMPP protocol SMS adaptation method in the embodiment of the present invention includes: Step 100: Load customer account information and system parameters, initialize CMPP, SMGP and SGIP adapters, and start CMPP monitoring service; It is understandable that the execution subject of the present invention may be a CMPP protocol SMS adapter device, or a terminal or a server, which is not limited here. The embodiment of the present invention is described by taking a server as the execution subject as an example.
[0017] Specifically, read the client_info.xml configuration file and extract the customer account information, including user name, password, bound IP and fixed SP code. This information is the basis for the interaction between the customer and the platform, ensuring the legitimacy of the customer identity and the security of the system communication. The customer configuration data is stored in the XML structure, and the system reads and verifies it item by item. Parse the config.properties configuration file to obtain parameters such as the CMPP listening port number and the SGIP uplink listening port number. The CMPP listening port number is used for customer access services, while the SGIP uplink listening port number is used to receive the user's uplink SMS. By dynamically configuring these parameters, the system can flexibly respond to different deployment requirements. Load the rpt_codeMapping.xml file and extract the mapping relationship between the status report codes of different operators to achieve the correct conversion and information transmission of the status codes of different operators and ensure seamless docking between protocols. All customer account information, system parameters and status report code mapping relationships are stored in the memory after parsing to improve the system access speed and processing performance. In the process of initializing the adapter, the CMPP adapter is initialized based on the customer account information, and the remote IP, port, account and password are set. Then, the SMGP and SGIP adapters are initialized in turn. These adapters are used to handle the SMS sending needs of different operators and ensure effective communication with their respective operators. After the initialization is completed, connection pools are created for the CMPP, SMGP, and SGIP adapters to ensure that connections are reused in high concurrency situations, reducing the connection overhead when sending messages each time, thereby improving processing efficiency. The CMPP listening service is started based on the CMPP listening port number, and the SGIP uplink listening service is started based on the SGIP uplink listening port number. The CMPP listening service processes the client's downlink SMS requests, and the SGIP listening service receives the user's uplink SMS, thereby realizing two-way SMS interaction.
[0018] Step 200: Receive a CMPP_CONNECT request from the client, verify the client account information, generate a session identifier, and send a CMPP_CONNECT_RESP response; Specifically, the CMPP_CONNECT request sent by the client is received, and the Source_Addr field is extracted from the request, where the Source_Addr field is the SP's enterprise code, which is the core basis for the system to identify the customer's identity. The code is used to find the corresponding customer configuration information in the memory. These configuration information are loaded when the system starts, including customer account, password, bound IP address, shared key, etc. The AuthenticatorSource field and timestamp information are extracted from the CMPP_CONNECT request. The AuthenticatorSource is obtained by the client through MD5 calculation of the SP enterprise code, shared key and timestamp, and is used for identity authentication. The system re-uses the MD5 algorithm to generate the authentication code, and compares the generated authentication code with the AuthenticatorSource submitted by the client to determine whether the customer's identity is legal. If the two authentication codes are the same, the authentication is passed, otherwise the system will reject the connection request. After the authentication is completed, the Version field in the CMPP_CONNECT request is checked to ensure that the protocol version is compatible. The protocol version compatibility check ensures that the communication between the client and the system proceeds smoothly. If the client version exceeds the system support range, the system will return an error status. After authentication is passed and protocol version compatibility is confirmed, a unique session identifier (Session ID) is generated to track and manage the status during the life cycle of the connection. The session identifier is generated using the SHA-256 algorithm based on the current timestamp, random number, and SP enterprise code. SHA-256 ensures the uniqueness and unpredictability of the session identifier, thereby improving security. After the session identifier is generated, the client's IP address, port number, user name, and session identifier are combined into complete connection information and stored in the connection manager to manage the status of all currently active connections. The role of the connection manager is to ensure that the system can effectively track and manage each connection under high concurrency conditions to ensure overall communication stability and reliability. Construct a CMPP_CONNECT_RESP response message, set the Status field to 0 to indicate a successful connection, and calculate the AuthenticatorISMG field to verify the ISMG identity. The AuthenticatorISMG is calculated by using MD5 on Status, AuthenticatorSource, and shared secret to ensure the integrity of the response message and the reliability of the ISMG identity. At the same time, set the Version field to the highest supported version number to ensure the compatibility of subsequent message interactions. The CMPP_CONNECT_RESP response message is sent to the client to complete the connection establishment process.
[0019] Step 300: Receive a CMPP_SUBMIT request, parse the message content according to the customer account information, determine the target number operator type, create an SMS task object and put it into the priority queue; It should be noted that the CMPP_SUBMIT request sent by the client is received, and the Total_Length, Command_Id and Sequence_Id fields are extracted from the request. These fields together constitute the message header of the message. The message header is used to identify and track the SMS request, so that the system can confirm the request source and its processing status in the subsequent processing. The message body of the CMPP_SUBMIT request is parsed to extract important fields in the message body, including Msg_Id, Pk_total, Pk_number, Registered_Delivery, Service_Id, Fee_UserType, Fee_terminal_Id, Msg_Fmt, Src_Id, DestUsr_tl, Dest_terminal_Id, Msg_Length and Msg_Content. These fields contain key information about the SMS content, target number, billing information and service type, which are the basis for SMS processing and sending. The customer's account information is used to further process the request. According to the customer user name in the CMPP_SUBMIT request, the content of the corresponding client_info.xml configuration file is obtained from the memory. The client_info.xml contains various configuration information of the customer, among which the number segment regular expression is used to help the system determine the operator to which the target number belongs. Based on the number segment regular expression in the configuration, each target number extracted from the Dest_terminal_Id field is matched, and the operator type corresponding to each target number is determined through the matching result. In this way, according to the number ownership, the appropriate operator channel is selected for sending, thereby improving the SMS arrival rate and sending efficiency. The billing method of the SMS is determined according to the billing information field in the CMPP_SUBMIT request. The Fee_UserType field indicates which party is billed, and the Fee_terminal_Id field specifies the specific user of the billing. Through the analysis of these two fields, it is determined who bears the cost of the SMS, whether it is the source number, the destination number, or the service provider. Based on the value of the Service_Id field, the corresponding service type configuration is searched in the memory, and the service type configuration determines the specific processing strategy adopted for the SMS. For example, different services have different priorities, different fee structures or different delivery paths. By obtaining the corresponding service configuration, the SMS message can be optimized according to the strategy. All the information of the CMPP_SUBMIT request, including the message header, message body, target operator type, billing method and related service processing strategy, is encapsulated into an SMS task object. The SMS task object is the core data structure of the system when processing SMS requests, and contains all the data required to execute the SMS request.Calculate the priority of the SMS task object based on the value of the Msg_level field. The Msg_level field is used to specify the urgency of the SMS. A higher level indicates that the SMS needs to be processed first. Calculate the priority based on the value of this field to ensure that high-priority SMS requests can be responded to quickly in high concurrency situations. Create a priority queue that uses the priority of SMS tasks as the sorting basis to ensure that SMS tasks with higher priorities can be processed first. Insert the SMS task object into the priority queue and sort and manage it according to priority. The introduction of the priority queue can effectively optimize the SMS processing process, ensure that important tasks are processed first when resources are limited, and improve the overall responsiveness and service quality of the system.
[0020] Step 400: Get the SMS task object from the priority queue, convert the CMPP protocol to the target protocol according to the operator type, generate a protocol message object and put it into the corresponding sending queue; Specifically, the SMS task object with the highest priority is taken out from the priority queue to ensure that the most urgent SMS request is processed first. After taking out the task object, based on the operator type contained in the SMS task object, the corresponding protocol conversion strategy is selected to adapt to the network environment and technical requirements of different operators. Different operators use different SMS gateway protocols. The system performs protocol conversion according to the type of the target operator and generates a message object that meets the operator's standards. For SMS tasks of mobile numbers, the system does not need to perform protocol conversion, but keeps the CMPP format unchanged. A CMPP_SUBMIT message object is directly generated, and the extracted fields are encapsulated in the original CMPP protocol format to ensure seamless connection with China Mobile's gateway. For telecom numbers, the CMPP_SUBMIT message is converted to the SMGP_SUBMIT format. During the conversion process, the fields between different protocols are mapped. The Msg_Id field in the CMPP protocol is mapped to the MsgID field in the SMGP protocol to ensure that the message can be uniquely tracked throughout its life cycle. The Registered_Delivery field is mapped to the NeedReport field, which is used to indicate whether a status report is required. The telecommunications network processes this field to decide whether to feedback the message sending status. The Msg_level is mapped to the Priority field in SMGP to indicate the priority of the message so that it can be reasonably scheduled when it is sent. The Service_Id field is mapped to the ServiceID field, indicating the specific service type involved in the SMS. For China Unicom numbers, the CMPP_SUBMIT message is converted to the SGIP_SUBMIT format. The Msg_Id in the CMPP protocol is mapped to the SPNumber field in the SGIP protocol. This field represents the service code of the SP and is used to identify the source and purpose of the message. The Registered_Delivery field is mapped to the ReportFlag field to determine whether the China Unicom gateway needs to feedback a status report on the message. The Service_Id is mapped to the ServiceType field in SGIP to describe the service type provided by the SMS. Find the client_info.xml configuration file<xxxx_remove_sign> Tag to determine whether the signature in the SMS content needs to be removed. SMS signatures are usually used to identify the sender, but in some cases, the signature needs to be removed during the conversion process, especially when adapting protocols between different operators to meet the requirements of specific operators. If the signature needs to be removed, delete the predefined signature content from the beginning or end of the Msg_Content field. The specific way to remove the signature depends on the predefined rules, which involves finding a specific signature string and removing it.Generate a new protocol message object based on the converted protocol format and associate it with the original SMS task object to ensure that the system can always trace back to the original request throughout the entire SMS processing process, facilitating error handling, status tracking, and statistical analysis. According to the target protocol type, select the corresponding sending queue and insert the generated protocol message object into the selected sending queue. Different sending queues correspond to different operators and network environments, such as CMPP sending queues for China Mobile, SMGP sending queues for China Telecom, and SGIP sending queues for China Unicom. By inserting the message object into the corresponding sending queue, it is ensured that the message is sent to the target gateway along the correct path while waiting for sending processing. Each sending queue is processed according to FIFO (first in, first out) or other specific scheduling strategies to ensure that the SMS message can be efficiently sent to the target operator's network and finally delivered to the receiving user.
[0021] Step 500: Obtain the protocol message object from the sending queue through the CMPP, SMGP and SGIP adapters, establish a connection with the operator gateway, send a message and receive a response; Specifically, multiple worker threads are created for each operator, corresponding to the three protocols of CMPP, SMGP and SGIP. These worker threads are managed by thread pool technology. When the thread pool is initialized, the appropriate number of worker threads is configured for each protocol, and the minimum number of idle threads and the maximum number of threads are set to ensure that the system can effectively perform resource scheduling in a high-concurrency environment. In this way, processing resources are flexibly allocated according to the actual request load, avoiding blocking caused by insufficient resources and inefficiency caused by waste of resources. When the worker thread starts, each thread obtains the protocol message object waiting to be sent from the corresponding sending queue. According to the protocol type, the message object is assigned to the corresponding CMPP, SMGP or SGIP worker thread for processing. In the worker thread, the connection status with the target operator gateway is checked. If the connection is disconnected, the system calls the reconnection mechanism to reestablish the connection. The design of the reconnection mechanism ensures the robustness and reliability of the system. When the connection is interrupted due to network fluctuations or other reasons, the system can automatically try to restore the connection to ensure the continuous sending of messages. When the worker thread determines that the connection status is normal, it obtains an available connection from the connection pool based on the connection pool technology. The connection pool is an important means of managing the connection with the operator gateway. It can effectively reduce the overhead of establishing and disconnecting the connection each time a message is sent, and improve the performance of the system. If there is no available connection in the connection pool, a new connection is created and added to the connection pool for subsequent requests. The dynamic expansion of the connection pool ensures that the system can still obtain available connections in time when the load suddenly increases, ensuring the continuity of the service. After obtaining the available connection, the protocol message object is serialized into a byte stream and the message packet is assembled according to the format requirements of the corresponding protocol. Different operator gateways use different protocol formats, so the assembly of the message packet is strictly carried out in accordance with the protocol specifications. For example, the CMPP protocol, SMGP protocol, and SGIP protocol have their own requirements for the structure of the message header and message body. According to the definition of the specific protocol, the various fields of the protocol message object are correctly filled into the byte stream, and the integrity and correctness of the message packet are guaranteed. After the message packet is assembled, it is sent to the corresponding operator gateway through the established connection. At the same time as sending, a timer is started to monitor the message sending process and set a timeout threshold to deal with delays or failures. The purpose of setting a timeout threshold is to enable the system to take appropriate measures, such as resending the message or recording failure information, if the carrier gateway does not return a response within the specified time, so as to avoid wasting system resources due to long waiting. After the message is successfully sent, the system waits for and receives the response from the carrier gateway. The response message contains a status code and error information to indicate the processing result of the message. Parse the response content, extract the status code and error information, and if the status code indicates that the message has been successfully delivered to the carrier gateway, update the status of the SMS task object and mark it as sent or accepted.If the response contains error information, take appropriate remedial measures according to the error type, such as retrying to send, recording logs, or notifying relevant operators. For SMS tasks that require status reports, put the task object in the status tracking queue to continue monitoring the processing of the message. The status tracking queue is used to manage all SMS messages that require status reports. It obtains the final status of these SMS messages through regular polling or receiving active push notifications from operators, and returns the status report to the customer.
[0022] Step 600: Receive the operator status report, search for the corresponding SMS task object, convert the status code, construct a CMPP_DELIVER message and send it to the client.
[0023] Specifically, a status report listening thread is created for each operator, corresponding to the three protocols of CMPP, SMGP and SGIP respectively. The working mode of these threads is based on the non-blocking IO model, so as to realize the concurrent reception of gateway status reports of multiple operators. After successfully receiving the status report, the message identifier is extracted from the status report according to the characteristics of different protocols. For the CMPP protocol, the Msg_Id field is extracted as the message identifier, for the SMGP protocol, the MsgID field is extracted, and the SubmitSequenceNumber field is extracted for the SGIP protocol. Through these identifiers, the corresponding original SMS task object is found in the status tracking queue. The status tracking queue stores all SMS task objects that need to obtain status reports, and the corresponding object is found through the extracted message identifier. The status code and error code are parsed from the status report. For the SMGP protocol, the State and ErrorCode fields are extracted from the report, for the SGIP protocol, the State and ErrorCode fields are extracted, and for the CMPP protocol, the Stat field is extracted. These fields contain the processing status information of the SMS, such as whether it is successfully delivered, the reason for failure, etc. By parsing the status code and error code, the specific processing status of each SMS in the operator network is reflected. The status code conversion is performed based on the mapping rules defined in the rpt_codeMapping.xml file. Different operators use different status code standards. The rpt_codeMapping.xml file contains the mapping relationship of these status codes. Through the mapping rules, the status codes of various operators are converted into a unified internal format. If some status codes are not found in the predefined mapping rules, the default rules are applied for conversion to ensure that all status codes can be correctly processed and understood. After the status code conversion is completed, the CMPP_DELIVER message is constructed based on the converted status code and the information of the original SMS task object. The CMPP_DELIVER message is used to return the operator's status report to the original requesting client, thereby realizing the closed-loop processing of the status report. In the process of constructing the CMPP_DELIVER message, the converted status code is filled into the Msg_Content field, and the Registered_Delivery field is set to 1, indicating that this is a status report rather than an ordinary SMS message. Through the CMPP connection established between the system and the client, the constructed CMPP_DELIVER message is sent to the client to complete the closed-loop processing of the status report.
[0024] In the embodiment of the present invention, the unified access and processing of the three protocols of CMPP, SMGP and SGIP are realized through the CMPP protocol adapter, the system architecture is simplified, and the development and maintenance costs are reduced. The operator type is automatically identified according to the target mobile phone number, and the corresponding protocol is selected for conversion, which improves the accuracy and efficiency of SMS sending. The priority queue and multi-threading technology are adopted to achieve high concurrent SMS processing capabilities and significantly improve the throughput of the system. The mapping relationship between customer accounts, system parameters and status codes is managed through the XML configuration file, which enhances the configurability and maintainability of the system. The authentication mechanism based on MD5 and SHA-256 is introduced to enhance the security of client connections and effectively prevent unauthorized access. Through the unified status code mapping mechanism, the consistency processing of status reports of different operators is realized, and the subsequent status tracking and error handling process is simplified. The connection with the operator gateway is managed by the connection pool technology, which reduces the overhead of connection establishment and disconnection and improves the resource utilization efficiency. The system architecture design supports the addition of new operators and protocol types, has good scalability, and can adapt to future changes in business needs. The core logic such as protocol conversion and status report processing is separated from the specific business processing, which improves the modularity and code reusability of the system. By monitoring and logging each processing link, comprehensive system operation status and performance indicators are provided to facilitate problem diagnosis and performance optimization.
[0025] In a specific embodiment, the process of executing step 100 may specifically include the following steps: Read the client_info.xml configuration file to extract customer account information, including user name, password, bound IP and fixed SP code; parse the config.properties configuration file to obtain the CMPP listening port number and the SGIP uplink listening port number; load the rpt_codeMapping.xml file to extract the mapping relationship between different operator status report codes; Store the mapping relationship between customer account information, system parameters and status report codes in memory; Initialize the CMPP adapter based on the customer account information, set the remote IP, port, account and password; initialize the SMGP adapter based on the customer account information, set the remote IP, port, account and password; initialize the SGIP adapter based on the customer account information, set the remote IP, port, account and password; Create connection pools for the CMPP adapter, SMGP adapter, and SGIP adapter respectively, start the CMPP listening service according to the CMPP listening port number, and start the SGIP uplink listening service based on the SGIP uplink listening port number.
[0026] Specifically, by reading the client_info.xml configuration file, the detailed account information of the customer is extracted, including the user name, password, bound IP address and fixed SP code. For each customer's configuration information, the required data is extracted one by one from the XML structure and stored in the memory. For example, the user's bound IP address is used to verify the legitimacy of the login request, while the fixed SP code is used to identify the source of the message. Parse the config.properties configuration file to obtain important parameters required by the system, such as the CMPP listening port number and the SGIP uplink listening port number. For example, the CMPP listening port number is used to receive the SMS downlink request sent by the customer, while the SGIP uplink listening port number is used to receive the uplink message sent by the user through the Unicom network. By reading these parameters, different communication channels can be flexibly configured and managed to ensure that services are provided on the appropriate port. Load the rpt_codeMapping.xml file. This file contains the mapping relationship between the status report codes of different operators. Different operators use different status codes to indicate the sending status, such as success, failure or processing. Extract the mapping relationship of the status code from the rpt_codeMapping.xml file and store it in the memory. Through the mapping mechanism, the operator-specific status report code is converted into an internal unified standard status code for processing in cross-operator scenarios. All customer account information, system parameters, and status report code mapping relationships are stored in memory for quick access and call. The main purpose of storing this information in memory is to improve processing speed and avoid IO bottlenecks caused by frequent disk access. These data are stored as structured objects. For example, customer information is represented by a mapping table (Map), where the key is the user name and the value is an object containing all customer configurations. System parameters are stored in the form of key-value pairs for easy search and use during initialization. Initialize the CMPP adapter based on customer account information. During the initialization process, set the remote IP, port, account, and password to establish an effective connection with the China Mobile gateway. The same process applies to the initialization of the SMGP and SGIP adapters, setting the remote IP, port, account, and password for them respectively to communicate with the Telecom and Unicom gateways. The initialization of the adapter is a prerequisite for the system to interact with different operator networks, ensuring that the system can send and receive text messages normally in various environments. In order to improve the efficiency of the connection and the performance of the system, create connection pools for the CMPP adapter, SMGP adapter, and SGIP adapter respectively. Connection pool is a resource management technology used to maintain a certain number of reusable connections, so that when communication is needed, they can be directly obtained from the connection pool without establishing and disconnecting the connection each time. The size of the connection pool needs to be set reasonably, usually setting the minimum number of idle connections and the maximum number of connections.The minimum number of idle connections is used to ensure that the system can maintain enough available connections when the load is low, while the maximum number of connections limits the maximum number of connections that the system can create when the load is high to prevent resource exhaustion. Connection pool management is described by the following formula:. ; in, Indicates the number of connections in the current connection pool. and Respectively represent the minimum and maximum number of connections, Indicates the current load demand. Through dynamic adjustment, resources can be used efficiently and different business loads can be coped with. After the connection pool configuration is completed, the CMPP listening service is started according to the CMPP listening port number, and the SGIP uplink listening service is started based on the SGIP uplink listening port number. The function of the CMPP listening service is to wait for the customer to send a SMS downlink request, and accept the customer's connection and message submission request by binding to the specified port. When starting the listening service, consider the concurrent processing capability and use the thread pool to handle multiple connection requests. Each thread in the thread pool is responsible for processing a connection request, thereby ensuring the performance and stability of the system under high concurrency. The size of the thread pool is dynamically adjusted according to the system's processing capability and load conditions, and its management process is expressed by the following formula: ; in, Indicates the maximum concurrent processing capability. is the maximum number of threads in the thread pool, It is the number of requests that each thread can process per second. By properly configuring the size of the thread pool, stable services can be provided under different load conditions. In the process of starting the listening service, the client identity authentication operation is performed to ensure that only authorized clients can access the system. The authentication process is based on the username, password and timestamp of the request provided by the client, and an authentication code is generated through an encryption algorithm, which is then compared with the authentication code calculated by the system. For example, when using the MD5 algorithm for client authentication, it is expressed as follows: ; in, is the calculated authentication hash value, username and password are the customer's username and password respectively, and timestamp is the request timestamp. In this way, only legitimate customers can pass the authentication, ensuring the security of the entire system. After all configurations are completed and the listening service is successfully started, the system starts running and waits for customer requests. When customers submit SMS requests through the CMPP adapter, these requests are processed through the pre-configured connection and listening services, and the messages are routed to the correct operator gateway. In the case of high concurrency, the use of connection pools and thread pools can significantly improve the system's response speed, reduce the delay of each request, and create new connections when needed to cope with increased load.
[0027] In a specific embodiment, the process of executing step 200 may specifically include the following steps: Receive the CMPP_CONNECT request sent by the client, extract the Source_Addr field from the request, obtain the SP enterprise code, and search for the corresponding customer configuration information in the memory according to the SP enterprise code; Extract the AuthenticatorSource field and timestamp information from the CMPP_CONNECT request, and generate an authentication code using the MD5 algorithm based on the shared secret in the customer configuration information, combined with the SP enterprise code and timestamp information; Compare the generated authentication code with the AuthenticatorSource field to determine whether the authentication is successful; Check the Version field in the CMPP_CONNECT request to confirm the compatibility of the client protocol version; Generate a unique session identifier using the SHA-256 algorithm based on the current timestamp, random number, and SP enterprise code; Combine the client IP address, port number, user name and session identifier into connection information and store it in the connection manager; Construct a CMPP_CONNECT_RESP response message, set the Status field to 0, calculate the AuthenticatorISMG field, set the highest version number supported by the system, and send the CMPP_CONNECT_RESP response message to the client to complete the connection establishment process.
[0028] Specifically, when the system receives a CMPP_CONNECT request, the Source_Addr field is extracted from the request message, which contains the SP enterprise code (i.e., the unique identifier of the service provider). The SP enterprise code is used to identify the identity of the client and is the unique identifier of the customer in the system. According to the extracted SP enterprise code, the corresponding customer configuration information is searched in the memory. The customer configuration information is loaded from the configuration file and stored in the memory when the system starts up for quick access. This information includes the customer's username, password, shared secret, and other important parameters related to the customer, such as the bound IP address and port number. The AuthenticatorSource field and timestamp information are extracted from the CMPP_CONNECT request. AuthenticatorSource is an authentication code generated by the client after performing MD5 calculation on the SP enterprise code, shared secret, and timestamp, which is used to verify the identity of the customer. After finding the customer configuration information, the MD5 algorithm is used to generate the authentication code based on the shared secret in the customer configuration, combined with the SP enterprise code and timestamp. The SP enterprise code, shared secret, and timestamp are concatenated into a string, and then the string is hashed by MD5. The formula for generating the authentication code is as follows: MD5(Source_Addr+shared_secret+timestamp); in, Indicates the generated MD5 authentication code, Source_Addr is the SP enterprise code extracted from the request, and shared_secret_ is the shared key in the customer configuration. It is the timestamp extracted from the CMPP_CONNECT request. The MD5 algorithm is an irreversible hash function that can convert an input string of any length into a fixed-length hash value. The calculated authentication code is compared with the AuthenticatorSource field in the request. If the two are the same, the authentication is successful; if they are different, the system rejects the connection request. After the identity authentication is successful, the Version field in the CMPP_CONNECT request is checked to confirm the compatibility of the client protocol version. The value of the Version field is extracted from the request and compared with the version range supported by the system. For example, if the system supports a version range of 1.0 to 3.0, and the client's Version field is 2.0, it indicates compatibility. Otherwise, an error status is returned to inform the client that the version is incompatible. After completing the identity authentication and version compatibility check, a unique session identifier (Session ID) is generated for this connection. To ensure the uniqueness and security of the session identifier, the SHA-256 algorithm is used to calculate it based on the current timestamp, a random number, and the SP enterprise code. SHA-256 is a secure hash algorithm that converts input data into a fixed-length 256-bit hash value. The formula for generating a session identifier is as follows: ; in, is the generated session identifier, timestamp is the current timestamp, random is a random number, and Source_Addr is the SP enterprise code. By introducing random numbers, the unpredictability of the session identifier is increased, thereby improving security. The session identifier uniquely identifies the connection throughout the life cycle of the connection and is used to track and manage subsequent interaction processes. After the session identifier is generated, the client's IP address, port number, user name, and generated session identifier are combined into complete connection information, and the information is stored in the connection manager. Construct a CMPP_CONNECT_RESP response message to complete the connection establishment process. When constructing the response message, set the Status field to 0, indicating that the connection is successful; if the authentication fails or the version is incompatible, the Status field will be set to the corresponding error code. Calculate the AuthenticatorISMG field to verify the identity of the ISMG (i.e., SMS gateway). AuthenticatorISMG is obtained by performing MD5 calculation on Status, AuthenticatorSource, and shared secret. The calculation formula is as follows: MD5(Status+AuthenticatorSource+shared_secret); in, Is the generated ISMG authentication code, Status indicates the status of the connection, AuthenticatorSource is the authentication code sent by the client, and shared_secret is the shared secret in the client configuration. By calculating the AuthenticatorISMG field, the client can verify the identity of the ISMG, thereby ensuring the security of communication. Set the Version field to the highest supported version number to inform the client of the highest protocol version that the system can currently support, ensuring that subsequent message interactions proceed correctly. Send the constructed CMPP_CONNECT_RESP response message to the client to complete the connection establishment process.
[0029] In a specific embodiment, the process of executing step 300 may specifically include the following steps: Receive the CMPP_SUBMIT request sent by the client, extract the Total_Length, Command_Id, and Sequence_Id fields from the request to form a message header; Parse the message body of the CMPP_SUBMIT request and extract the Msg_Id, Pk_total, Pk_number, Registered_Delivery, Service_Id, Fee_UserType, Fee_terminal_Id, Msg_Fmt, Src_Id, DestUsr_tl, Dest_terminal_Id, Msg_Length, and Msg_Content fields; According to the user name in the customer account information, obtain the corresponding client_info.xml configuration from the memory; Based on the number segment regular expression in the configuration, match each target number in the Dest_terminal_Id field to determine its corresponding operator type; Determine the SMS billing method based on the values of the Fee_UserType and Fee_terminal_Id fields, and search the memory for the corresponding service type configuration based on the Service_Id field to obtain the relevant processing strategy; Encapsulate all the information of the CMPP_SUBMIT request, the determined operator type, the billing method and the processing strategy into a SMS task object, and calculate the priority of the SMS task object based on the value of the Msg_level field; Create a priority queue, use priority as the sorting basis, and insert SMS task objects into the priority queue to ensure that high-priority SMS tasks can be processed first.
[0030] Specifically, receive the CMPP SUBMIT request and extract the Total_Length, Command_Id and Sequence_Id fields from the request, which together constitute the message header of the request. Total_Length is used to indicate the length of the entire message, Command_Id is used to identify the type of request, and Sequence_Id is the sequence number of the message, which is used to identify and track the order and processing status of the request. Parse the message body of the CMPP_SUBMIT request and extract each field in the message body in turn, including Msg_Id, Pk_total, Pk_number, Registered_Delivery, Service_Id, Fee_UserType, Fee_terminal_Id, Msg_Fmt, Src_Id, DestUsr_tl, Dest_terminal_Id, Msg_Length and Msg_Content fields. These fields contain key information such as SMS content, target number, billing information and service type. Msg_Id is used to uniquely identify this SMS. The Pk_total and Pk_number fields are used to identify the number of the SMS if it is a long SMS. The Registered_Delivery field is used to indicate whether a status report is required. Service_ld indicates the specific type of service. Fee_UserType and Fee_terminal_ld indicate the information of the billing user. Msg_Fmt is used to specify the SMS format, such as text or binary. Src_Id is the sender address of the SMS. DestUsr_tl, Dest_terminal_Id, Msg_Length, and Msg_Content respectively indicate the number of users receiving the SMS, the target user number, the message length, and the specific SMS content. According to the user name in the customer account information, the corresponding customer configuration in the client_info.xml configuration file is obtained from the memory. The customer configuration contains some key account information and sending rules, such as regular expressions for number segments, fixed SP codes, etc. After finding the customer configuration in the memory, each target number in the Dest_terminal_Id field is matched based on the number segment regular expression in the configuration to determine the type of operator corresponding to each number. For example, the regular expression defines that numbers starting with certain specific numbers belong to specific operators. The system matches each target number to determine which of China Mobile, China Unicom, or China Telecom these numbers belong to. In this way, appropriate sending strategies are adopted for different operators to improve the success rate and efficiency of SMS sending. The billing method of SMS is determined based on the values of the Fee_UserType and Fee_terminal_Id fields.The Fee_UserType field indicates who should bear the cost of the SMS, such as the sender or the receiver, while the Fee_terminal_Id specifies the specific billing user. Based on the values of these two fields, the party that bears the cost of this SMS is determined, and the correct billing record is made in the subsequent processing process. According to the Service_Id field, the corresponding service type configuration is searched in the memory to obtain the relevant processing strategy. Different Service_Ids represent different service types, such as marketing promotion, verification code sending, etc. Different service types usually have different priorities, sending paths and fee structures. By searching the service type configuration, the optimal processing strategy is selected for each SMS task. After collecting all the necessary information, all the information in the CMPP_SUBMIT request, the operator type billing method of the target number, and the service processing strategy are encapsulated into an SMS task object. The SMS task object contains all the data required to execute the SMS request. The priority of the SMS task object is calculated based on the value of the Msg_level field. The Msg_level field is used to indicate the urgency of the SMS. A higher level indicates that the SMS needs to be processed first. The priority of the SMS task is calculated according to the following formula:. ; in, Indicates the priority of the SMS task. The weight indicating the urgency, Indicates the urgency level of the message. Indicates the weight of the service type, An identifier that indicates the type of service. Priority calculation ensures that important SMS messages (such as emergency notifications or verification code messages) are given higher priority and can be processed first in high concurrency situations. Create a priority queue, use the calculated priority as the basis for sorting, and insert the SMS task object into the priority queue. The priority queue is based on The value of determines the position where the SMS task is inserted, ensuring that high-priority SMS tasks are prioritized in the queue. During the SMS task processing, ensure the reasonable scheduling of resources. For example, in a high concurrency situation, the number of SMS tasks in the queue increases rapidly. Use the following formula to calculate the current queue load ratio: ; in, Indicates the load ratio of the current queue. Indicates the number of SMS tasks in the current queue. Indicates the maximum capacity of the queue. When a certain threshold is exceeded, measures are taken, such as limiting new requests from entering the queue or adding processing threads to increase the task processing speed.
[0031] In a specific embodiment, the process of executing step 400 may specifically include the following steps: Take out the SMS task object with the highest priority from the priority queue, and select the corresponding protocol conversion strategy based on the operator type in the SMS task object; For mobile numbers, keep the CMPP format unchanged and directly generate a CMPP_SUBMIT message object; For telecom numbers, convert the CMPP_SUBMIT message to SMGP_SUBMIT format, map Msg_Id to the MsgID field, map Registered_Delivery to the NeedReport field, map Msg_level to the Priority field, and map Service_Id to the ServiceID field; For China Unicom numbers, convert the CMPP_SUBMIT message to the SGIP_SUBMIT format, map Msg_Id to the SPNumber field, map Registered_Delivery to the ReportFlag field, and map Service_Id to the ServiceType field; According to the client_info.xml configuration file<xxxx_remove_sign> Tag, to determine whether the signature in the SMS content needs to be removed; If the signature needs to be removed, the predefined signature content is deleted from the beginning or end of the Msg_Content field, and a new protocol message object is generated based on the converted protocol format and associated with the original SMS task object; According to the target protocol type, the corresponding sending queue is selected, and the generated protocol message object is inserted into the selected sending queue to wait for sending processing.
[0032] Specifically, the SMS task object with the highest priority is taken out from the priority queue, and the corresponding protocol conversion strategy is selected according to the operator type in the SMS task object. According to the operator type of the target number in the task object, the corresponding protocol conversion strategy is selected. SMS tasks are sent to users of different operators, and different operators use different protocols to process SMS messages. Determine which operator the target number belongs to. If it is a mobile number, the system keeps the CMPP format unchanged and directly generates a CMPP_SUBMIT message object. All fields remain the same to ensure that the system and the mobile operator's gateway can be seamlessly connected. The CMPP protocol is a standard protocol of China Mobile and is suitable for SMS transmission on mobile networks. Retaining the original CMPP format can reduce the overhead of message conversion and improve processing efficiency. If the target number belongs to a telecommunications network, the CMPP_SUBMIT message is converted to the SMGP_SUBMIT format to meet the protocol requirements of the telecommunications operator. During the conversion process, field mapping is performed. For example, the Msg_Id field in the CMPP protocol is mapped to the MsgID field in the SMGP protocol. Msg_Id is the unique identifier of the SMS, which is used to track and confirm the status of the message. The Registered_Delivery field is mapped to the NeedReport field in the SMGP protocol, which indicates whether a status report needs to be sent. The Msg_level field is mapped to the Priority field in the SMGP protocol to determine the priority of the SMS, so that it can be reasonably scheduled in the operator network. At the same time, the Service_Id field is mapped to the ServiceID field. Service_Id is used to describe the service type of the SMS. These mapping relationships ensure that the original CMPP message can be correctly converted into a format that complies with the SMGP protocol, so that telecom operators can correctly understand and process the message content. If the target number belongs to the Unicom network, the system converts the CMPP_SUBMIT message to the SGIP_SUBMIT format. During the conversion process, the Msg_Id field is mapped to the SPNumber field in the SGIP protocol, which indicates the number of the service provider and is used to identify the source of the message. The Registered_Delivery field is mapped to the ReportFlag field in the SGIP, indicating whether a status report is required, and the Service_Id is mapped to the ServiceType field in the SGIP, describing the service type to which the SMS belongs. These mappings ensure that the message can be correctly delivered to the Unicom network and processed correctly. After completing the protocol conversion, determine whether the SMS content needs to remove the signature. The signature is the identification information attached to the SMS content to show the identity of the sender. In order to adapt to the requirements of different operators or specific business rules, determine whether to remove the signature.According to the client_info.xml configuration file<xxxx_remove_sign> Tag to determine whether this operation needs to be performed. If the configuration file indicates that the signature needs to be removed, delete the predefined signature content from the beginning or end of the Msg_Content field. After the signature processing is completed, a new protocol message object is generated based on the converted protocol format and associated with the original SMS task object, so that the system can track the relationship between the original task and the final message sent during subsequent processing, which is convenient for status tracking and troubleshooting. The generation of the message object is described by the following formula:. ; in, Represents the generated new protocol message object. is the original CMPP_SUBMIT message, Indicates the process of protocol conversion. Function It means that the original message is converted and signed to generate a new message object that meets the requirements of the target operator. Select the corresponding sending queue according to the type of the target protocol. Each protocol type (CMPP, SMGP, SGIP) corresponds to an independent sending queue, which is used to manage the message objects to be sent and ensure that the messages are sent to the operator gateway in the correct order and rules. Insert the generated protocol message object into the corresponding sending queue, for example, CMPP messages are inserted into the CMPP sending queue, and SMGP messages are inserted into the SMGP sending queue. The process of inserting messages into the queue is expressed by the following formula: ; in, Indicates the sending queue of the corresponding protocol type. Indicates the protocol type (such as CMPP, SMGP, SGIP), It is the protocol message object to be sent. By inserting the message into the corresponding sending queue, the orderly sending of the message is ensured. And it is managed and allocated accordingly according to different protocol types. The message objects in the waiting sending queue enter the sending stage. Each sending queue will be processed by the corresponding worker thread and send the message to the operator's gateway. In order to ensure the successful sending of the message, the status of the message will be monitored during the sending process. If the confirmation response from the operator is not received within the specified time, the message will be resent or the failure log will be recorded. During the sending process, the status of the SMS task object is updated according to the feedback from the operator to ensure that the customer can obtain accurate message sending results.
[0033] In a specific embodiment, the process of executing step 500 may specifically include the following steps: Create multiple working threads for each operator, corresponding to the three protocols of CMPP, SMGP and SGIP. Based on the thread pool technology, initialize the number of working threads for each protocol, and set the minimum number of idle threads and the maximum number of threads; Get the protocol message object waiting to be sent from the corresponding sending queue, and assign it to the corresponding worker thread according to the protocol type. For each worker thread, check the connection status with the target operator gateway. If the connection is disconnected, call the reconnection mechanism. Based on the connection pool technology, obtain an available connection from the connection pool. If there is no available connection, create a new connection, serialize the protocol message object into a byte stream, and assemble the message packet according to the format requirements of the corresponding protocol; Send the assembled message packet to the corresponding carrier gateway through the established connection, start the timer, wait for the response from the carrier gateway, and set the timeout threshold; Receive the response from the operator gateway, parse the response content, extract the status code and error information, and update the status of the SMS task object based on the response result. If a status report is required, put the SMS task object into the status tracking queue.
[0034] Specifically, multiple working threads are created for each operator, corresponding to the three protocols of CMPP, SMGP and SGIP. These working threads are managed through thread pool technology to achieve reasonable scheduling and efficient utilization of system resources. When initializing the thread pool, a certain number of working threads are created for each protocol, and the minimum number of idle threads and the maximum number of threads are set for the thread pool. The minimum number of idle threads indicates the number of available threads that the system always maintains under low load conditions to cope with sudden sending requests, while the maximum number of threads limits the maximum number of threads that the system can create under high load conditions to prevent resource exhaustion. Assuming that the system initializes 20 threads for the CMPP protocol, the minimum number of idle threads is 5, and the maximum number of threads is 50, the behavior of the thread pool is described by the following formula: ; in, Indicates the number of threads in the current thread pool. Indicates the minimum number of idle threads, Indicates the maximum number of threads. Indicates the number of threads required for the current system processing. The number of threads is adjusted dynamically according to the load to ensure that it can meet the needs under high load without wasting resources. After the thread pool is initialized, the protocol message objects waiting to be sent are obtained from the corresponding sending queue and assigned to the corresponding worker threads according to the protocol type of the message. For example, CMPP type messages will be assigned to CMPP threads, SMGP messages will be assigned to SMGP threads, and so on. After receiving the task, each worker thread checks the connection status with the target carrier gateway. If it is found that the connection has been disconnected, the reconnection mechanism is called to re-establish the connection to ensure that the message can be sent normally. The function of the reconnection mechanism is to ensure that the system can automatically restore the connection when facing network fluctuations or other abnormal situations, thereby improving the reliability of the system. Once the connection status is confirmed to be normal, an available connection is obtained from the connection pool based on the connection pool technology. The connection pool is used to manage the connection with the carrier gateway to avoid re-establishing the connection every time a message is sent, thereby reducing the overhead caused by the establishment and disconnection of the connection. If there is no available connection in the connection pool and the maximum number of connections has not been reached, the system will create a new connection and add it to the connection pool. This process is described by the following formula: ; in, Indicates the number of currently available connections. Indicates the maximum number of connections allowed in the connection pool. Indicates the number of currently available connections. Indicates the number of newly added connections. In this way, the connection pool is dynamically expanded as needed to ensure that available connections can be obtained in time even under high load conditions. After obtaining an available connection, the protocol message object is serialized into a byte stream and the message package is assembled according to the format requirements of the corresponding protocol. Different protocols have different requirements for the format of messages. For example, the CMPP, SMGP and SGIP protocols differ in the structure of the message header and message body. According to the specific protocol standard, each field in the message object is serialized into a byte stream and assembled into a complete message package according to the protocol requirements. Assume that the system sends a CMPP_SUBMIT message, and arranges the various fields of the message, such as Msg_ld, Service_ld, Src_ld, etc., in sequence according to the definition of the CMPP protocol, and serializes them into a byte stream. The serialization process is described by the following formula: ; in, Represents the serialized byte stream, Represents each field in the message object, and Serialize is a function that converts these fields into a byte stream according to the protocol format. When the message package is assembled, the system sends the message package to the corresponding operator gateway through the established connection. While the message is being sent, a timer is started to monitor the sending process and set a timeout threshold. The timeout threshold is used to prevent the system from waiting and occupying resources if the gateway does not respond in time. If no response is received from the operator gateway within the set time, the system will determine it as a timeout and resend the message or record the failure of the sending. The setting of the timer is described by the following formula: ; in, Indicates the waiting time. Indicates the set timeout threshold. Indicates the time that has passed. Exceed , the system triggers the timeout processing logic. After successfully sending the message, the system waits for and receives the response from the operator gateway. The response message usually contains a status code and error information to indicate the processing result of the message. Parse the response content, extract the status code and error information, and if the status code indicates that the message has been successfully delivered to the operator gateway, update the status of the SMS task object and mark it as "sent" or "accepted". If the response contains error information, take appropriate remedial measures according to the error type, such as resending the message, recording an error log, or notifying the operator to intervene. For SMS tasks that require status reports, put the task object in the status tracking queue to continue tracking the processing of the message. The status tracking queue is used to manage all SMS tasks that require status reports, obtain the final status of these SMS messages by periodic polling or receiving active push from the operator, and return the status report to the customer. This process is described by the following formula: ; in, Represents a state tracking operation, Indicates the state tracking queue, Represents the SMS task object that needs to track status. Insert SMS tasks that need status reports into the status tracking queue to ensure that these tasks can be continuously tracked and status feedback can be obtained.
[0035] In a specific embodiment, the process of executing step 600 may specifically include the following steps: Create a status report listening thread for each operator, corresponding to the three protocols of CMPP, SMGP and SGIP respectively, and based on the non-blocking IO model, realize the concurrent reception of gateway status reports of multiple operators; Extract the message identifier from the received status report, extract Msg_Id for CMPP, extract MsgID for SMGP, and extract SubmitSequenceNumber for SGIP; According to the extracted message ID, find the corresponding original SMS task object in the status tracking queue; Parse the status code and error code from the status report, extract the State and ErrorCode fields for SMGP, extract the State and ErrorCode fields for SGIP, and extract the Stat field for CMPP; Based on the mapping rules defined in the rpt_codeMapping.xml file, the status codes of different operators are converted into a unified format; For status codes that are not in the predefined mapping rules, the default rules are applied for conversion, and a CMPP_DELIVER message is constructed based on the converted status code and the original SMS task object information; Fill the converted status code into the Msg_Content field of the CMPP_DELIVER message and set the Registered_Delivery field to 1; Through the CMPP connection established with the client, the constructed CMPP_DELIVER message is sent to the client to complete the closed-loop processing of the status report.
[0036] Specifically, a status report listening thread is created for each operator (China Mobile, China Telecom and China Unicom). Each thread uses a non-blocking IO model to communicate with the corresponding operator gateway. When no status report arrives, the thread will not be blocked, but will continue to execute other tasks, thereby making full use of CPU resources. The implementation of non-blocking IO enables the system to process status reports from multiple operators at the same time without creating a separate blocking thread for each connection, significantly improving the concurrent processing capability of the system. When a certain operator gateway sends a status report, the system's listening thread will immediately capture the report and extract the message identifier from the report. In the CMPP protocol, the message identifier is Msg_Id, while the corresponding field in the SMGP protocol is MsgID and in the SGIP protocol is SubmitSequenceNumber. The purpose of extracting the message identifier is to find the original SMS task object corresponding to the status report. Each SMS is assigned a unique message identifier when it is sent, which is used to track the entire life cycle of the SMS. By extracting the message identifier, the corresponding original SMS task object can be found from the status tracking queue. The status tracking queue is used to manage all SMS tasks that need to obtain status reports. It stores detailed information of each SMS, including message ID, target number, sending time, etc. The following formula is used to describe the search for the corresponding task object in the status tracking queue: ; in, Indicates the original SMS task object found. Indicates the state tracking queue, Represents the message identifier extracted from the status report. Through this process, the original SMS task corresponding to the status report is located. The status code and error code are parsed from the status report. For the SMGP protocol, the State and ErrorCode fields are extracted from the report. These fields are used to indicate the processing status of the SMS and the specific error type. For the SGIP protocol, the State and ErrorCode fields are extracted, and for the CMPP protocol, the Stat field is extracted to indicate the status information. The purpose of parsing the status code is to determine the processing result of the SMS in the operator's network, such as whether it is successfully delivered, whether it fails due to network failure, etc. Since different operators use different status codes to indicate the processing status of the SMS, these status codes are uniformly converted so that customers can understand the results of SMS sending in a consistent way. By loading the rpt_codeMapping.xml file, the mapping rules between different operator status codes are defined in the file. Based on these mapping rules, the operator-specific status code is converted into the standard format within the system. The conversion of the status code is expressed by the following formula: ; in, Indicates the unified status code after conversion. represents the mapping function, Indicates the original status code. Through the mapping function , converting status codes from different operators into a unified format. For status codes that are not in the predefined mapping rules, the default rules are applied for conversion to ensure that all status codes can be correctly processed and understood. The default conversion rule is to map unknown status codes to "unknown status" or other common identifiers, thereby avoiding situations where the system cannot handle unknown status codes. Based on the converted status code and the information of the original SMS task object, a CMPP DELIVER message is constructed to feed back the status report to the customer, completing the closed-loop processing of the status report. When constructing the CMPP_DELIVER message, the converted status code is filled into the Msg_Content field, and the Registered_Delivery field is set to 1 to indicate that this is a status report rather than an ordinary SMS message. The construction process of the CMPP_DELIVER message is described by the following formula: ; in, Indicates that the construction is completed CMPP_DELIVER message, is the identifier of the original message, It is the status code after unified conversion. is the value of the Registered_Delivery field (set to 1 in the status report). Through this process, a status report message that complies with the CMPP protocol standard is generated. After the CMPP DELIVER message is constructed, the message is sent to the client through the CMPP connection established with the client, completing the closed-loop processing of the entire status report.
[0037] Furthermore, the method also includes the following steps of dynamic load balancing: setting initial weight values for CMPP, SMGP and SGIP adapters respectively; periodically collecting performance indicators of each adapter, including response time, success rate and throughput; calculating the health score of each adapter using a weighted moving average algorithm based on the collected performance indicators; dynamically adjusting the weight value of the adapter according to the health score; creating a weight-based polling scheduler for allocating SMS tasks; giving priority to adapters with high weight values when allocating SMS tasks; setting an adaptive threshold, and temporarily removing an adapter from the polling list when the health of the adapter is lower than the threshold; starting a recovery detection thread for the removed adapter and checking its status regularly; and re-adding the removed adapter to the polling list when it returns to normal; and recording load balancing operation logs for subsequent analysis and optimization.
[0038] The specific implementation steps are as follows: The system sets initial weight values for the three adapters CMPP, SMGP and SGIP, such as CMPP: 5, SMGP: 3, SGIP: 2. These initial values are set based on historical data and expected performance. The system creates a performance monitoring module that collects performance indicators of each adapter every 60 seconds. The collected indicators include: average response time (milliseconds), success rate (percentage) and throughput (number of messages processed per second). These raw data are stored in a circular buffer, retaining the data for the last 30 minutes. The health calculation module uses a weighted moving average algorithm to process the collected performance data. The algorithm is as follows: Health = 0.5*(1 / normalized response time) + 0.3*success rate + 0.2*normalized throughput, where normalization is mapping the value to the range of 0-1. Based on the calculated health, the system dynamically adjusts the weight value of the adapter: new weight = old weight*(0.8+0.2*health) This weight value changes smoothly with health. The system implements a weight-based polling scheduler. Assuming the current weights are CMPP:4, SMGP:3, SGIP:2, the scheduling order will be: CMPP, SMGP, CMPP, SGIP, CMPP, SMGP, CMPP. Set an adaptive threshold with an initial value of 0.6 for health. When the health of an adapter is below this threshold for three consecutive times, it is removed from the polling list. The system starts a recovery detection thread to check the status of the removed adapter every 30 seconds. When the health rises above the threshold and lasts for 2 minutes, it is re-added to the polling list. Detailed load balancing logs record the time and reason for each weight adjustment, adapter removal and recovery. The logs are segmented every hour for subsequent analysis. Administrators can view the load balancing status in real time through the web interface, including the current weight, health, and throughput charts of each adapter. The system also provides the function of manually adjusting weights and thresholds to deal with special situations. The system integrates a self-optimization module that analyzes the load balancing logs of the past 24 hours and uses machine learning algorithms (such as decision trees) to optimize the weight calculation formula and threshold settings to achieve continuous improvement of system performance.
[0039] Furthermore, it also includes an intelligent retry mechanism: setting the maximum number of retries and the initial retry interval for each SMS task object; when sending fails, putting the SMS task object into the retry queue; using the exponential backoff algorithm to calculate the time interval for the next retry; creating a retry scheduler to trigger the retry operation according to the calculated time interval; before retrying, checking the current status of the target operator gateway; if the target gateway is unavailable, trying to switch to the backup gateway; recording the results of each retry, including the success rate and response time; based on the retry results, dynamically adjusting the retry strategy, such as adjusting the retry interval or switching the sending channel; when the maximum number of retries is reached, recording the failure information in persistent storage; providing a retry statistical report for analyzing system performance bottlenecks and optimizing retry strategies.
[0040] The specific implementation steps are as follows: The system sets the maximum number of retries (default is 5) and the initial retry interval (default is 10 seconds) for each SMS task object. These parameters are stored in the properties of the task object and can be adjusted according to different business scenarios. When sending fails, the system captures the exception and analyzes the cause of the failure. Based on the type of failure (such as network timeout, server rejection, content filtering, etc.), the system decides whether a retry is required. If a retry is required, the SMS task object is placed in a priority queue as a retry queue. The system uses an exponential backoff algorithm to calculate the time interval for the next retry: new interval = minimum value (maximum interval, initial interval * (2^number of retries) * (1 + random number (0, 0.1))) This ensures that the retry interval increases as the number of failures increases, and adds a small amount of randomness to prevent multiple tasks from retrying at the same time and causing instantaneous high load. Create a retry scheduler that maintains a small top heap with the key of the heap as the next retry time. The scheduler loops to check the top element of the heap, and when the retry time is reached, it extracts the task and triggers the retry operation. Before performing a retry, the system first checks the current status of the target operator gateway. If the target gateway is detected to be unavailable (for example, it cannot be connected for three consecutive times), the system will try to switch to the pre-configured backup gateway. If all backup solutions fail, the task is put back into the retry queue and the retry interval is increased. The system records the results of each retry in detail, including success rate, response time, failure reason, etc. These data are stored in a time series database for subsequent analysis and strategy optimization. Based on the retry results, the system implements a dynamic adjustment mechanism. For example, if a certain type of failure (such as a specific error code) shows a high retry success rate, the system will automatically reduce the initial retry interval for this type of failure. On the contrary, if a certain type of failure always fails after retry, the system will increase the retry interval or directly reduce the maximum number of retries. When the maximum number of retries is reached, the system will record the failure information in a persistent storage (such as a distributed file system). This information includes a complete retry history, detailed error information of the last failure, etc., which is convenient for subsequent manual intervention and analysis. The system provides a real-time retry statistics report, showing key indicators such as the distribution of various failure reasons, average number of retries, and retry success rate. Administrators can adjust the retry strategy or improve the system architecture based on these reports. The system integrates a machine learning module that analyzes historical retry data, identifies key factors that affect the retry success rate (such as time, gateway, content type, etc.), and fine-tunes retry parameters in real time to continuously optimize system performance.
[0041] Furthermore, it also includes the steps of adaptively splitting long text messages: setting a maximum character number threshold for a single text message; after receiving a CMPP_SUBMIT request, detecting the encoding method and the number of characters of the text message content; if the number of characters exceeds the threshold, starting an adaptive splitting algorithm; calculating the maximum safe character number of each sub-text message according to different encoding methods; analyzing the semantic structure of the text message content and finding a suitable splitting point; dividing the text message content at the splitting point to generate multiple sub-text messages; generating a unique message identifier for each sub-text message and setting an associated tag; updating the total number and current sequence number information of each sub-text message; encapsulating the split sub-text messages into independent text message task objects respectively; and inserting the sub-text message task objects into the priority queue in the order of splitting.
[0042] The specific implementation steps are as follows: The system first sets the maximum character count threshold for a single SMS. For GSM7-bit encoding, the threshold is 160 characters; for UCS-2 encoding, the threshold is 70 characters. These thresholds take into account the space occupied by the SMS header under different encoding methods. When the system receives the CMPP_SUBMIT request, it immediately detects the encoding method of the SMS content. The system implements an encoding detection algorithm to determine the encoding type by analyzing the character distribution in the content. For example, if the content contains only ASCII characters, it is considered to be GSM7-bit encoding; if it contains Chinese characters, it is determined to be UCS-2 encoding. If the number of characters detected exceeds the corresponding threshold, the system activates the adaptive splitting algorithm. The algorithm first calculates the number of messages to be split, and then estimates the number of safe characters for each sub-message. For GSM7-bit encoding, considering the extra space occupied by the long SMS header, the number of safe characters for each sub-message is 153; for UCS-2 encoding, the number of safe characters is 67. The system implements a semantic analysis module to find suitable split points. This module uses natural language processing technology to analyze the sentence structure first, and splits the message at the end of the sentence, such as a period or question mark. If a single sentence is too long, it continues to analyze secondary separators, such as commas and semicolons. In places where there are no punctuation marks, the system analyzes word boundaries to avoid splitting in the middle of words. In addition to considering semantic structure, the splitting algorithm also needs to handle special cases. For example, for SMS messages containing URLs or special format data, the system will identify these special parts and they will not be split improperly. The system maintains a regularexpression library to identify common special content formats. After determining the split point, the system generates multiple sub-messages. A message identifier is generated for each sub-message in the format of "original Msg_Id+sequence number". At the same time, the system sets an association tag that these sub-messages belong to the same group. The system updates the metadata of each sub-message, including the total number of messages (Pk_total) and the current sequence number (Pk_number). This ensures that the receiving end can correctly reassemble the long message. For the SMPP protocol, the system also sets the esm_class field accordingly to indicate that this is a long message. Each sub-message is encapsulated as an independent SMS task object, inheriting most of the properties of the original SMS task (such as priority, validity period, etc.). The system creates a transaction manager for this group of sub-tasks to track the sending status of each sub-task. The system inserts the sub-message task objects into the priority queue in the order of splitting. In order to ensure the integrity of long SMS, the system implements a special scheduling strategy: whenever it finds sub-messages belonging to the same group in the queue, it will give priority to all sub-messages in the group until all are sent.
[0043] Furthermore, it also includes the steps of intelligent channel selection: establishing a multi-dimensional scoring model, including channel cost, delivery rate, speed and stability; regularly collecting historical performance data of each channel; using machine learning algorithms, such as decision trees or random forests, to train the channel selection model; for each SMS task, extracting feature vectors, including target number, SMS content type and priority; inputting the feature vectors into the trained model to predict the optimal channel; setting a confidence threshold, and when the prediction confidence is lower than the threshold, adopting an alternative strategy; recording the results and actual performance of each channel selection; using online learning algorithms, such as online gradient descent, to continuously optimize model parameters; regularly evaluating model performance and retraining the entire model when necessary; generating a channel selection report to analyze the effectiveness of the selection strategy and potential improvements.
[0044] The specific implementation steps are as follows: The system establishes a multi-dimensional scoring model. The model considers the following factors: channel cost (price per SMS), delivery rate (percentage of successful delivery), speed (average delivery delay), and stability (frequency of service interruption). Each factor is assigned a weight, with initial values of 30% for cost, 40% for delivery rate, 20% for speed, and 10% for stability. The system implements a data collection module to obtain performance data from each channel regularly (such as every hour). These data include: number of successful deliveries, number of failures, average response time, distribution of error types, etc. The data is stored in a time series database, retaining the history of the last 30 days. Using the collected data, the system uses the random forest algorithm to train the channel selection model. The advantage of random forest is that it can handle nonlinear relationships and has the ability to self-evaluate the importance of features. The input features of the model include: the operator to which the target number belongs, the number segment, the SMS type (normal / marketing), the SMS length, the sending time period, etc. The output is the prediction of the optimal channel. For each incoming SMS task, the system extracts its feature vector. For example, a feature vector may be: [1 (mobile), 1385 (number segment), 0 (normal SMS), 50 (SMS length), 14 (sending hours)]. The system also considers some dynamic features, such as the current real-time load of each channel. The extracted feature vector is input into the trained model, and the model returns the fitness score of each channel. The system selects the channel with the highest score as the preferred sending channel. In order to control risks, the system sets a confidence threshold (initial value is 0.8). If the highest score is lower than this threshold, the system will adopt an alternative strategy, such as polling to select a channel with the highest preset priority. The system records the results and actual performance of each channel selection in detail. These records include: selected channel, predicted score, actual delivery status, sending delay, etc. This data is used to continuously evaluate and improve the model. The system uses an online gradient descent algorithm to achieve real-time fine-tuning of model parameters. Whenever a sending result is received, the system uses this new sample to update the model parameters to ensure that the model can quickly adapt to changes in channel performance. The system evaluates model performance every day and calculates indicators such as prediction accuracy and ROC curve. If the model performance is found to be degraded (such as accuracy below 80% for 3 consecutive days), the system triggers a complete model retraining. Retraining uses the data from the last 7 days, and a comparative test is performed after retraining to ensure that the new model performs better than the old model. The system generates a detailed channel selection report. The report includes: the utilization rate, success rate, average cost of each channel, and key factors affecting model identification. Administrators can manually adjust channel policies based on these reports, such as temporarily disabling channels with poor performance or adjusting the weights of certain features.
[0045] The CMPP protocol SMS adaptation method in the embodiment of the present invention is described above. The CMPP protocol SMS adaptation device 10 in the embodiment of the present invention is described below. Figure 2 In one embodiment of the present invention, a CMPP protocol SMS adaptation device 10 includes: Initialization module 11, used to load customer account information and system parameters, initialize CMPP, SMGP and SGIP adapters, and start CMPP monitoring service; The receiving module 12 is used to receive a CMPP_CONNECT request from a client, verify the client account information, generate a session identifier, and send a CMPP_CONNECT_RESP response; Create module 13, which is used to receive the CMPP_SUBMIT request, parse the message content according to the customer account information, determine the target number operator type, create an SMS task object and put it into the priority queue; The acquisition module 14 is used to obtain the SMS task object from the priority queue, convert the CMPP protocol into the target protocol according to the operator type, generate the protocol message object and put it into the corresponding sending queue; Establishing module 15, used to obtain protocol message objects from the sending queue through CMPP, SMGP and SGIP adapters, establish a connection with the operator gateway, send messages and receive responses; The sending module 16 is used to receive the operator status report, find the corresponding SMS task object, convert the status code, construct a CMPP_DELIVER message and send it to the client.
[0046] Through the cooperation of the above components, the unified access and processing of the three protocols of CMPP, SMGP and SGIP are realized through the CMPP protocol adapter, which simplifies the system architecture and reduces the development and maintenance costs. The operator type is automatically identified according to the target mobile phone number, and the corresponding protocol is selected for conversion, which improves the accuracy and efficiency of SMS sending. The priority queue and multi-threading technology are adopted to achieve high-concurrency SMS processing capabilities and significantly improve the system throughput. The XML configuration file is used to manage the mapping relationship between customer accounts, system parameters and status codes, which enhances the configurability and maintainability of the system. The authentication mechanism based on MD5 and SHA-256 is introduced to enhance the security of client connections and effectively prevent unauthorized access. Through the unified status code mapping mechanism, the consistent processing of status reports of different operators is achieved, which simplifies the subsequent status tracking and error handling process. The connection pool technology is used to manage the connection with the operator gateway, which reduces the overhead of connection establishment and disconnection and improves resource utilization efficiency. The system architecture design supports the addition of new operators and protocol types, has good scalability, and can adapt to future changes in business needs. The core logic such as protocol conversion and status report processing is separated from specific business processing, which improves the modularity and code reusability of the system. By monitoring and logging each processing link, comprehensive system operation status and performance indicators are provided to facilitate problem diagnosis and performance optimization.
[0047] See also Figure 3 , Figure 3 The electronic device 300 provided in the embodiment of the present invention is a schematic block diagram of the structure, wherein the electronic device 300 includes a processor 301 and a memory 302, wherein the processor 301 and the memory 302 are connected via a device bus 203, wherein the memory 302 may include a non-volatile storage medium and an internal memory.
[0048] The non-volatile storage medium can store a computer program. The computer program includes program instructions, and when the program instructions are executed by the processor 301, the processor 301 can execute any of the above-mentioned CMPP protocol SMS adaptation methods.
[0049] The processor 301 is used to provide computing and control capabilities to support the operation of the entire electronic device 300 .
[0050] The internal memory provides an environment for the operation of the computer program in the non-volatile storage medium. When the computer program is executed by the processor 301, the processor 301 can execute any of the above-mentioned CMPP protocol SMS adaptation methods.
[0051] Those skilled in the art will understand that Figure 3The structure shown in the figure is only a block diagram of a part of the structure related to the scheme of the present invention, and does not constitute a limitation on the electronic device 300 involved in the scheme of the present invention. The specific electronic device 300 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0052] It should be understood that the processor 301 may be a central processing unit (CPU), and the processor 301 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0053] It should be noted that those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the electronic device 300 described above can refer to the corresponding process of the aforementioned CMPP protocol SMS adaptation method, which will not be repeated here.
[0054] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by one or more processors, the one or more processors implement the CMPP protocol SMS adaptation method provided in the embodiment of the present invention.
[0055] The computer-readable storage medium may be an internal storage unit of the electronic device 300 in the aforementioned embodiment, such as a hard disk or memory of the electronic device 300. The computer-readable storage medium may also be an external storage device of the electronic device 300, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped with the electronic device 300.
[0056] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0057] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for enabling an electronic device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store program codes.
[0058] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A CMPP protocol SMS adaptation method, characterized in that: The method comprises: Load customer account information and system parameters, initialize CMPP, SMGP, and SGIP adapters, and start CMPP listening service; Receive the client CMPP_CONNECT request, verify the client account information, generate a session identifier, and send a CMPP_CONNECT_RESP response; Receive the CMPP_SUBMIT request, parse the message content according to the customer account information, determine the target number operator type, create an SMS task object and put it into the priority queue; Obtain the SMS task object from the priority queue, convert the CMPP protocol into the target protocol according to the operator type, generate a protocol message object and put it into the corresponding sending queue; Obtain the protocol message object from the sending queue through the CMPP, SMGP and SGIP adapters, establish a connection with the operator gateway, send a message and receive a response; Receive the operator status report, find the corresponding SMS task object, convert the status code, construct a CMPP_DELIVER message and send it to the client.
2. The CMPP protocol SMS adaptation method according to claim 1, characterized in that: The loading of customer account information and system parameters, initialization of CMPP, SMGP and SGIP adapters, and starting of CMPP monitoring service include: Read the client_info.xml configuration file to extract customer account information, including user name, password, bound IP and fixed SP code; parse the config.properties configuration file to obtain the CMPP listening port number and the SGIP uplink listening port number; load the rpt_codeMapping.xml file to extract the mapping relationship between different operator status report codes; Store the mapping relationship between customer account information, system parameters and status report codes in memory; Initialize the CMPP adapter based on the customer account information, set the remote IP, port, account and password; initialize the SMGP adapter based on the customer account information, set the remote IP, port, account and password; initialize the SGIP adapter based on the customer account information, set the remote IP, port, account and password; A connection pool is created for each of the CMPP adapter, the SMGP adapter and the SGIP adapter, a CMPP listening service is started according to the CMPP listening port number, and a SGIP uplink listening service is started based on the SGIP uplink listening port number.
3. The CMPP protocol SMS adaptation method according to claim 1, characterized in that: The receiving of the client CMPP_CONNECT request, verifying the client account information, generating a session identifier, and sending a CMPP_CONNECT_RESP response includes: Receive a CMPP_CONNECT request sent by the client, extract the Source_Addr field from the request, obtain the SP enterprise code, and search for corresponding customer configuration information in the memory according to the SP enterprise code; Extract the AuthenticatorSource field and timestamp information from the CMPP_CONNECT request, and generate an authentication code using the MD5 algorithm based on the shared secret in the customer configuration information, combined with the SP enterprise code and timestamp information; Compare the generated authentication code with the AuthenticatorSource field to determine whether the authentication is successful; Check the Version field in the CMPP_CONNECT request to confirm the compatibility of the client protocol version; Generate a unique session identifier using the SHA-256 algorithm based on the current timestamp, random number, and SP enterprise code; Combine the client IP address, port number, user name and the session identifier into connection information and store it in the connection manager; A CMPP_CONNECT_RESP response message is constructed, the Status field is set to 0, the AuthenticatorISMG field is calculated, the highest version number supported by the system is set, and the CMPP_CONNECT_RESP response message is sent to the client to complete the connection establishment process.
4. The CMPP protocol SMS adaptation method according to claim 1, characterized in that: The receiving of the CMPP_SUBMIT request, parsing the message content according to the customer account information, determining the target number operator type, creating an SMS task object and placing it in a priority queue, includes: Receive a CMPP_SUBMIT request sent by the client, extract Total_Length, Command_Id, and Sequence_Id fields from the request to form a message header; Parse the message body of the CMPP_SUBMIT request and extract the Msg_Id, Pk_total, Pk_number, Registered_Delivery, Service_Id, Fee_UserType, Fee_terminal_Id, Msg_Fmt, Src_Id, DestUsr_tl, Dest_terminal_Id, Msg_Length, and Msg_Content fields; According to the user name in the customer account information, obtain the corresponding client_info.xml configuration from the memory; Based on the number segment regular expression in the configuration, each target number in the Dest_terminal_Id field is matched to determine the corresponding operator type; Determine the billing method of the SMS according to the values of the Fee_UserType and Fee_terminal_Id fields, and search the memory for the corresponding service type configuration based on the Service_Id field to obtain the relevant processing strategy; Encapsulate all the information of the CMPP_SUBMIT request, the determined operator type, the billing method and the processing strategy into a short message task object, and calculate the priority of the short message task object based on the value of the Msg_level field; A priority queue is created, the priority is used as a sorting basis, and the SMS task object is inserted into the priority queue to ensure that high-priority SMS tasks can be processed first.
5. The CMPP protocol SMS adaptation method according to claim 1, characterized in that: The obtaining of the SMS task object from the priority queue, converting the CMPP protocol into the target protocol according to the operator type, generating a protocol message object and placing it into a corresponding sending queue includes: Taking out the SMS task object with the highest priority from the priority queue, and selecting a corresponding protocol conversion strategy based on the operator type in the SMS task object; For mobile numbers, keep the CMPP format unchanged and directly generate a CMPP_SUBMIT message object; For telecom numbers, convert the CMPP_SUBMIT message to SMGP_SUBMIT format, map Msg_Id to the MsgID field, map Registered_Delivery to the NeedReport field, map Msg_level to the Priority field, and map Service_Id to the ServiceID field; For China Unicom numbers, convert the CMPP_SUBMIT message to the SGIP_SUBMIT format, map Msg_Id to the SPNumber field, map Registered_Delivery to the ReportFlag field, and map Service_Id to the ServiceType field; According to the client_info.xml configuration file<xxxx_remove_sign> Tag, to determine whether the signature in the SMS content needs to be removed; If the signature needs to be removed, the predefined signature content is deleted from the beginning or end of the Msg_Content field, and a new protocol message object is generated based on the converted protocol format and associated with the original SMS task object; According to the target protocol type, the corresponding sending queue is selected, and the generated protocol message object is inserted into the selected sending queue to wait for sending processing.
6. The CMPP protocol SMS adaptation method according to claim 1, characterized in that: The method of obtaining the protocol message object from the sending queue through the CMPP, SMGP and SGIP adapter, establishing a connection with the operator gateway, sending a message and receiving a response includes: Create multiple working threads for each operator, corresponding to the three protocols of CMPP, SMGP and SGIP. Based on the thread pool technology, initialize the number of working threads for each protocol, and set the minimum number of idle threads and the maximum number of threads; Get the protocol message object waiting to be sent from the corresponding sending queue, and assign it to the corresponding worker thread according to the protocol type. For each worker thread, check the connection status with the target operator gateway. If the connection is disconnected, call the reconnection mechanism. Based on the connection pool technology, obtain an available connection from the connection pool. If there is no available connection, create a new connection, serialize the protocol message object into a byte stream, and assemble the message packet according to the format requirements of the corresponding protocol; Send the assembled message packet to the corresponding carrier gateway through the established connection, start the timer, wait for the response from the carrier gateway, and set the timeout threshold; Receive the response from the operator gateway, parse the response content, extract the status code and error information, and update the status of the SMS task object based on the response result. If a status report is required, put the SMS task object into the status tracking queue.
7. The CMPP protocol SMS adaptation method according to claim 1, characterized in that: The receiving of the operator status report, searching for the corresponding SMS task object, converting the status code, constructing a CMPP_DELIVER message and sending it to the client includes: Create a status report listening thread for each operator, corresponding to the three protocols of CMPP, SMGP and SGIP respectively, and based on the non-blocking IO model, realize the concurrent reception of gateway status reports of multiple operators; Extract the message identifier from the received status report, extract Msg_Id for CMPP, extract MsgID for SMGP, and extract SubmitSequenceNumber for SGIP; According to the extracted message ID, find the corresponding original SMS task object in the status tracking queue; Parse the status code and error code from the status report, extract the State and ErrorCode fields for SMGP, extract the State and ErrorCode fields for SGIP, and extract the Stat field for CMPP; Based on the mapping rules defined in the rpt_codeMapping.xml file, the status codes of different operators are converted into a unified format; For status codes that are not in the predefined mapping rules, the default rules are applied for conversion, and a CMPP_DELIVER message is constructed based on the converted status code and the original SMS task object information; Fill the converted status code into the Msg_Content field of the CMPP_DELIVER message and set the Registered_Delivery field to 1; Through the CMPP connection established with the client, the constructed CMPP_DELIVER message is sent to the client to complete the closed-loop processing of the status report.
8. A CMPP protocol SMS adapter, characterized in that: The device is used to execute the CMPP protocol SMS adaptation method according to any one of claims 1 to 7, comprising: Initialization module, used to load customer account information and system parameters, initialize CMPP, SMGP and SGIP adapters, and start CMPP monitoring service; A receiving module, configured to receive a CMPP_CONNECT request from a client, verify the client account information, generate a session identifier, and send a CMPP_CONNECT_RESP response; A creation module is used to receive a CMPP_SUBMIT request, parse the message content according to the customer account information, determine the target number operator type, create an SMS task object and put it into a priority queue; An acquisition module, used to acquire the SMS task object from the priority queue, convert the CMPP protocol into a target protocol according to the operator type, generate a protocol message object and put it into a corresponding sending queue; Establishing a module, used to obtain the protocol message object from the sending queue through the CMPP, SMGP and SGIP adapters, establish a connection with the operator gateway, send a message and receive a response; The sending module is used to receive the operator status report, find the corresponding SMS task object, convert the status code, construct a CMPP_DELIVER message and send it to the client.
9. An electronic device, characterized in that: The electronic device comprises: a memory and at least one processor, wherein instructions are stored in the memory; The at least one processor calls the instruction in the memory to enable the electronic device to execute the CMPP protocol SMS adaptation method as described in any one of claims 1-7.
10. A computer-readable storage medium having instructions stored thereon, characterized in that: When the instructions are executed by the processor, the CMPP protocol SMS adaptation method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Short message retrying method and short message gateway
CN101951571A
Load balance system
CN104394224A
Short message sending method, and short message platform
CN108200544A
Short message sending method and device and network equipment
CN110557728A
A method of adapting mobile protocol to Unicom protocol and telecommunications protocol
CN110572784A
Cited By
HTTP (Hyper Text Transport Protocol) short message gateway processing method and device, equipment and storage medium
CN119211174A
HTTP short message gateway processing method, device, equipment and storage medium
CN119211174B
Multi-operator short message access priority selection system and method based on position
CN119946566A
Short message gateway collection management method and device based on CA certificate
CN120583385A
Short message extrusion processing method and system based on SMPP protocol
CN121240045A
