HTTP short message gateway processing method, device, equipment and storage medium
By receiving and verifying requests, performing content audits and channel selection in the SMS sending system, dynamically adjusting priority and billing, and using distributed caching and asynchronous processing queues, the efficiency and stability problems of traditional systems in high load and diversified environments are solved, and efficient, intelligent and reliable SMS sending is achieved.
Patent Information
- Application Number
- CN202411700268.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2044-11-26
AI Technical Summary
When traditional SMS sending systems face challenges such as high load, content diversification, channel difference and personalized user needs, it is difficult to ensure the efficiency and stability of efficient SMS sending, content review, channel selection and billing management.
By receiving and verifying SMS sending requests, performing content review and template matching, intelligently selecting sending channels, dynamically adjusting priority, performing accurate billing, and using distributed caching and asynchronous processing queues to improve the system's concurrent processing capabilities and fault tolerance capabilities.
It realizes efficient processing of a large number of concurrent requests, intelligent selection of sending channels, flexible control of sending priority, accurate billing, and has the ability to fail over, which improves the success rate of SMS sending and the stability of the system.
Smart Images

Figure CN119211174B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of short message gateway processing, and in particular to an HTTP short message gateway processing method, device, equipment and storage medium. Background Art
[0002] Traditional SMS sending systems face many challenges. The surge in SMS volume has increased system load pressure, placing higher demands on system stability and reliability. Secondly, the diversification and complexity of SMS content has made content review more difficult, posing the risk of spam and illegal content flooding the system.
[0003] In addition, the differences between different operators and channels, as well as users' high requirements for SMS sending speed and arrival rate, make channel selection and route optimization particularly important. At the same time, with the personalization and diversification of user needs, flexible billing strategies and precise quota control have also become key challenges for SMS gateway systems. Faced with large-scale concurrent sending and complex network environments, how to ensure efficient SMS sending and fault recovery has become an urgent problem to be solved. Summary of the invention
[0004] The main purpose of the present invention is to provide an HTTP SMS gateway processing method, device, equipment and storage medium to realize an HTTP SMS gateway processing solution that can efficiently process a large number of concurrent requests, intelligently select sending channels, flexibly control sending priorities, accurately bill and have failover capabilities.
[0005] To achieve the above object, the present invention provides an HTTP short message gateway processing method, comprising the following steps:
[0006] Receive a text message sending request, perform preliminary verification on the text message sending request, including user name, password, registration code, IP address and request frequency, and generate a verification result;
[0007] According to the verification result, the SMS content is reviewed and template matched, the SMS processing method is determined, and the review result is generated;
[0008] Based on the review result, a sending channel is selected, wherein the selection of the sending channel takes into account the SMS type, the receiving mobile phone number operator type, the user package type, the channel priority, the channel load and the historical sending success rate;
[0009] According to the selected sending channel, the SMS is assigned a priority based on the user level, SMS type, user historical behavior and current system load, and the SMS is placed in a corresponding multi-level feedback queue;
[0010] According to the SMS information in the multi-level feedback queue, billing and quota control are performed, and the billing and quota control are based on the SMS type, the selected channel and the user package to generate a billing result;
[0011] According to the billing result, the SMS information to be sent is stored in the distributed cache system, the sending task is processed through the asynchronous processing queue and the sending work thread pool, and failover and intelligent retry are performed to obtain execution feedback information.
[0012] The present invention also provides an HTTP short message gateway processing device, comprising:
[0013] A receiving module is used to receive a text message sending request, perform preliminary verification on the text message sending request, the verification content includes user name, password, registration code, IP address and request frequency, and generate a verification result;
[0014] A matching module, used to review and template match the SMS content according to the verification result, determine the SMS processing method, and generate a review result;
[0015] A selection module, for selecting a sending channel based on the audit result, wherein the selection of the sending channel takes into account the SMS type, the receiving mobile phone number operator type, the user package type, the channel priority, the channel load and the historical sending success rate;
[0016] An allocation module is used to assign priorities to SMS messages according to the selected sending channel, wherein the priorities are based on user level, SMS type, user historical behavior and current system load, and the SMS messages are placed in corresponding multi-level feedback queues;
[0017] A control module, used to perform billing and quota control according to the SMS information in the multi-level feedback queue, wherein the billing and quota control generates a billing result based on the SMS type, the selected channel and the user package;
[0018] The execution module is used to store the SMS information to be sent into the distributed cache system according to the billing result, process the sending task through the asynchronous processing queue and the sending work thread pool, and perform failover and intelligent retry to obtain execution feedback information.
[0019] The present invention also provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any one of the above methods when executing the computer program.
[0020] The present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned methods are implemented.
[0021] In summary, the technical solution provided by the present invention effectively improves the security of the system and prevents unauthorized access and malicious attacks by comprehensively verifying the user name, password, registration code, IP address and request frequency. Combined with multiple audit methods such as null value check, signature verification, length limit and template matching, the compliance and quality of SMS content are significantly improved. Considering multiple factors such as SMS type, operator type, user package, channel priority, load situation and historical success rate, more accurate and efficient channel selection is achieved. Based on user level, SMS type, historical behavior and system load, the priority is dynamically adjusted to optimize the allocation of system resources and improve the processing efficiency of important information. Flexible billing is carried out according to SMS type, selected channel and user package situation, realizing more fair and reasonable cost management. Through the cooperation of distributed cache, asynchronous processing queue and working thread pool, the concurrent processing capability and stability of the system are significantly improved. The introduction of intelligent retry and failover strategies effectively improves the success rate of SMS sending and the fault tolerance of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 This is a schematic diagram of the steps of the HTTP SMS gateway processing method in one embodiment of the present invention;
[0023] Figure 2 This is a structural block diagram of an HTTP short message gateway processing device in one embodiment of the present invention;
[0024] Figure 3 It is a schematic block diagram of the structure of a computer device according to an embodiment of the present invention.
[0025] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0027] Reference Figure 1 This embodiment provides an HTTP SMS gateway processing method, comprising the following steps:
[0028] S1, receiving a text message sending request, performing preliminary verification on the text message sending request, the verification content includes user name, password, registration code, IP address and request frequency, and generating a verification result;
[0029] Among them, a text message sending request containing a user name, password, registration code, sender's mobile phone number, recipient's mobile phone number list, text message content, scheduled sending time and text message type is received, and the user name and password are input into the user verification module for matching verification to confirm the user's identity and obtain the user identity verification result. Based on the user identity verification result, the user status is queried to obtain the user's status information, including whether the user has been locked, whether it is in a valid state, and whether it meets the normal operating conditions allowed by the system. At the same time, based on the IP address provided in the text message sending request, it is matched with the IP address whitelist, and the IP address verification result is obtained by querying whether it meets the legal address in the whitelist, ensuring that the request comes from a trustworthy source, thereby reducing the risk of malicious attacks. The registration code provided in the text message sending request is input into the registration code verification module for validity verification to confirm whether the registration code is valid and obtain the registration code verification result. At the same time, the number of recent login attempts and time intervals of the user are counted and analyzed based on the user name to obtain the user's request frequency data. By analyzing these data, it is identified whether the frequency of the user's request meets the specified standard. According to the request frequency data, the user's request frequency is threshold judged to obtain the frequency verification result. For example, check whether the number of login attempts of a user within a period of time exceeds the set security threshold to prevent attacks such as brute force cracking. In this way, the user's login behavior is effectively managed and controlled to ensure the security of the system. Generate a comprehensive verification result based on the user identity authentication result, user status information, IP address verification result, registration code verification result and frequency verification result. If the verification fails, the verification failure is classified in detail to determine the specific failure type. Help the system manage different types of verification failures to ensure that each error can be handled in a targeted manner. For example, some verification failures are due to incorrect password input, while others are because the IP address is not in the whitelist. According to the type of verification failure, generate corresponding error response information based on the preset error response template. The error response template includes different preset error messages, such as prompting the user that the password is incorrect, reminding the user that the request source address is not trusted, or informing the user that the request frequency is too high. The generated error response information is combined with the comprehensive verification result to obtain the final verification result, ensuring that each request has a clear processing status.
[0030] S2, based on the verification result, review and template match the SMS content, determine the SMS processing method, and generate the review result;
[0031] Specifically, a null value check is performed on the SMS content to ensure that the submitted SMS content is not null, and a content validity identifier is obtained. If the SMS content is valid, based on the identifier, the user's signature setting is obtained from the user configuration database to determine whether an additional signature is required, and a signature requirement identifier is obtained. According to the signature requirement identifier, the corresponding signature content is extracted from the user information database. The extracted signature content is combined with the original SMS content to obtain the complete SMS content. Character statistics are performed on the complete SMS content to ensure that it meets the preset length restriction rule, and the SMS is judged whether it is compliant based on this rule to generate a length compliance identifier. Semantic analysis and keyword extraction are performed on the complete SMS content to obtain a content feature vector. The content feature vector is a set of feature data used to describe the SMS content, which can reflect the semantics, structure and possible intentions of the SMS. Through semantic analysis, the key content and information in the SMS are extracted, so as to more accurately perform template matching and review. Based on the content feature vector, the preset white template library and the black template library are similarity calculated to obtain the template matching result. The similarity calculation is to determine the matching degree between the SMS and the template by comparing the similarity between the SMS content and each template in the template library. According to the similarity value of the template matching results, the matching results are prioritized, and the template with the highest matching degree is selected to obtain the best matching template. Based on the type of the best matching template obtained, the corresponding processing strategy is executed. If it is a black template, it is marked as interception, and if it is a white template, it is marked as acceleration, and the corresponding processing strategy identifier is generated. In this way, the classification processing of different types of SMS is realized, which can not only ensure the efficient sending of compliant content, but also effectively intercept potential illegal or bad content. For the SMS content with the processing strategy identifier as interception, an explanation of the interception reason is generated, and the interception reason is associated with the SMS content to obtain an interception information record, which helps users understand the specific reasons why the SMS is intercepted, such as because the content contains sensitive information, violates certain regulations, or fails to pass template matching. At the same time, the record of interception information also facilitates system maintenance personnel to audit and track interception events, so as to make adjustments and optimizations when necessary. The length compliance identifier, template matching results, processing strategy identifier and interception information record are combined together to generate the final audit result, and the audit result is stored in the audit log database.
[0032] S3, based on the review results, select the sending channel. The selection of the sending channel takes into account the SMS type, the type of carrier of the receiving mobile phone number, the type of user package, the channel priority, the channel load and the historical sending success rate;
[0033] It should be noted that, according to the SMS type information in the audit results, the channel database is preliminarily screened to obtain a list of channels that meet the SMS type. Through the preliminary screening, it is ensured that the selected channel supports a specific SMS type, such as ordinary text SMS or voice SMS, reducing the complexity of subsequent screening. Based on the receiving mobile phone number in the SMS, the number prefix database is queried to match and identify the operator type corresponding to the mobile phone number, and the operator type identifier is obtained. According to this identifier, the channel list that meets the SMS type is screened to obtain a list of operator-matched channels, ensuring that the selected channel matches the receiver's operator type, thereby improving the success rate and delivery efficiency of SMS sending and avoiding failures caused by operator mismatch. The user package type is extracted from the user information database, and these channels are prioritized based on the user package type to obtain a list of package-prioritized channels, ensuring that channels that meet the user package conditions are selected first. For example, when a user subscribes to a certain operator or type of priority channel service, the system can match according to this preference. The package-prioritized channel list is optimized based on the package type, the service content subscribed by the user, and the relevant channel information, so as to provide users with the service quality that best meets their needs. The package-prioritized channel list is screened to determine the channel suitable for sending under the current system load. Extract the current load data of each channel from the channel status database, calculate the load rate, and obtain the channel load status list, which reflects the current usage of each channel to avoid selecting a channel with too high a load, which may cause message delay or failure to send. Input the load status list into the load balancing algorithm module, filter the channels based on the preset load threshold, and obtain a list of channels with qualified loads. Through load balancing, the task of sending SMS messages can be more scientifically allocated to avoid the situation where some channels are overloaded or resources are unevenly allocated, thereby improving the stability of the overall system. Extract the historical sending success rate data of each channel in the list of channels with qualified loads from the historical database, and calculate the weighted average success rate to obtain a list of channel success rates. Evaluate the reliability of each channel based on historical data, and measure the performance of each channel under different conditions by weighted average. According to the channel success rate list, sort the channels with qualified loads, select the top N channels with the highest success rate, and obtain a list of candidate channels. Input the list of candidate channels into the intelligent routing algorithm, comprehensively consider the priority, load status, and sending success rate of the channel, calculate the comprehensive score of each channel, and obtain a list of channel scores. The intelligent routing algorithm is a comprehensive evaluation method that combines multiple dimensions to select the best sending path for each SMS. The calculation of the comprehensive score is based on multiple attributes of the channel to ensure that the selected channel has a high score in terms of success rate, load, and priority, so as to ensure that it provides the best support for the sending task. Based on the channel score list, the channel with the highest score is selected as the final sending channel, and the channel selection result is generated.The channel selection results are stored in the routing log database for subsequent auditing and optimization.
[0034] S4, assigning priorities to the SMS according to the selected sending channel. The priorities are based on the user level, SMS type, user historical behavior and current system load, and the SMS is placed in the corresponding multi-level feedback queue;
[0035] Specifically, the user's level data is extracted from the user information database, and mapped according to the preset user level weight table to obtain the user level initial score. The basis for the division of user levels includes different membership levels, customer consumption limits, service purchase records, etc. Through mapping, different initial scores are assigned to different user levels to reflect the importance and priority of the user. Based on the type of SMS, the SMS type priority database is queried to obtain the corresponding type weight. The SMS type priority varies according to the content attributes of the SMS. For example, ordinary notification SMS, important warning information, transaction confirmation SMS, etc. have different priority weights. By querying the SMS type priority database, different types of SMS are assigned corresponding priority weights. The type weight and the user level initial score are weighted to obtain the type weighted score. At the same time, the user's recent sending records are extracted from the user behavior analysis database to calculate the user's sending volume, success rate and complaint rate, and obtain relevant indicators of the user's historical behavior. User behavior data can reflect the performance and behavioral characteristics of users in using SMS gateway services. For example, too high sending frequency, more sending failures, or more user complaints all affect their priority. The user's historical behavior indicators are input into the behavior scoring model, and the user behavior score is obtained by calculating the preset scoring rules to reflect the user's stability and standardization. The type weighted score and the user behavior score are normalized. The normalized values are combined according to the preset weights to obtain the user's comprehensive score. The current system load data, including CPU usage, memory occupancy, and network bandwidth utilization, are obtained from the system monitoring module to calculate the system load index. The system load index is an important indicator for measuring the current system's available resources, helping the system to reasonably adjust the priority of each task under high load conditions to ensure the stability of the service. Based on the system load index, the load adjustment strategy table is queried to obtain the corresponding priority adjustment coefficient. The adjustment coefficient is used to dynamically adjust the user's comprehensive score according to the actual operating status of the system, so as to ensure that the system can give priority to important requests when the load is high, and avoid the failure of critical tasks to be processed in time due to excessive load. The user's comprehensive score is multiplied by the adjustment coefficient to obtain the final priority score. According to the final priority score, the priority boundary table of the multi-level feedback queue is compared to determine the priority level of the SMS and generate the result of queue allocation. Based on the queue allocation results, the SMS message is encapsulated into a task object and inserted into the multi-level feedback queue of the corresponding priority. At the same time, the queue status information is updated and the confirmation information of the queue insertion is generated.
[0036] S5, based on the SMS information in the multi-level feedback queue, performs billing and quota control, and the billing and quota control is based on the SMS type, the selected channel and the user package to generate the billing result;
[0037] Among them, the SMS information to be processed is extracted from the multi-level feedback queue, and the type of SMS, the selected sending channel and the user ID are parsed to obtain the basic data for billing, including the specific content attributes of the SMS, the channel through which it is sent, and which user initiated the request. Based on the user ID, the user package database is queried to extract the user's current package information, including the package type, the number of remaining SMS messages and the package unit price, to obtain the user's package information. The user package information reflects the service content ordered by the user in the system and the availability of the current package, which is an important basis for judging SMS billing and deduction. The number of remaining SMS messages in the user package determines whether this sending will incur additional fees, and the package unit price is used to calculate the cost within the package. At the same time, according to the type of SMS and the selected sending channel, the billing rule database is queried to obtain the corresponding basic price and discount coefficient to obtain the channel billing parameters. The billing rule database stores the basic price settings for different channels and SMS types, as well as the discount coefficients applicable to specific users or services. The acquisition of channel billing parameters ensures that in addition to considering the user package information, the final cost calculation can be adjusted according to the sending channel and specific type. The user's package information and channel billing parameters are input into the billing strategy module, and the final billing method is determined according to the preset billing priority rules to obtain the billing plan. The main function of the billing strategy module is to comprehensively evaluate the user's package status, channel charging standards, discounts and other factors to determine the best billing method. For example, if the user's current package still has a number of remaining items, the package billing is used first to avoid the generation of additional fees; when the number of package items is insufficient, the additional fee will be calculated based on the basic price and discount coefficient. Based on the billing plan, the fee required for this transmission is calculated, and factors such as the length of the SMS and the number of split items are considered to obtain the final original fee amount. For longer SMS, split it into multiple items for sending. Query the user's current account balance and credit limit from the user account database, calculate the total available amount, form the user's credit limit information, and reflect the total amount of resources that the user can currently use for payment. Compare the original fee amount with the user's credit limit information to determine whether the user has enough credit limit to complete the transmission operation and generate a credit limit verification result. If the user's available credit is sufficient, the system will pre-deduct the corresponding fees and update the balance information in the user's account; conversely, if the user's credit is insufficient, an error message will be generated, prompting the user that the credit is insufficient and the sending cannot be completed, and a pre-deduction result will be generated. Based on the pre-deduction result, the user's package usage record is updated, including the remaining number of user packages and the cumulative usage, etc., to obtain the package update result. The pre-deduction result, package update result and original billing information are integrated to generate the final billing result.
[0038] S6, based on the billing result, the SMS information to be sent is stored in the distributed cache system, the sending task is processed through the asynchronous processing queue and the sending work thread pool, and failover and intelligent retry are performed to obtain execution feedback information.
[0039] Among them, the SMS information to be sent is encoded based on the billing result to generate an SMS task object, which contains all the key information of the SMS to be sent, such as SMS content, recipient information, sending time and related billing information. The SMS task object is serialized, and the serialized data is sharded according to the preset sharding strategy to generate a sharded data set. The sharding strategy is based on factors such as data size, sending frequency and target node load to ensure that the data can be efficiently distributed and stored. Consistent hashing is performed on the sharded data set to determine the storage node of each shard and generate a shard storage mapping table. Consistent hashing is a distributed data distribution technology that can reasonably distribute data to multiple storage nodes to ensure that the system can maintain high data availability and load balancing even when some nodes fail. According to the generated shard storage mapping table, each shard data is written to the corresponding distributed cache node and the cache write result is obtained. The cache write result is an important basis for the system to determine whether the data is successfully stored. If some shards encounter failures during writing, the system will record the failure and adjust the storage strategy accordingly to ensure the integrity and availability of the data. The metadata of the SMS task is generated based on the cache write result, and it is submitted to the asynchronous processing queue to obtain the queue entry confirmation. The asynchronous processing queue is an important message scheduling mechanism that effectively manages the processing order of a large number of SMS tasks to ensure that each task can be processed in a timely manner. At the same time, an idle thread is selected from the sending work thread pool and bound to the task in the asynchronous processing queue to form a task processing thread. The task processing thread is responsible for executing the SMS sending operation, reading the data of the SMS task from the distributed cache system, and operating according to the set sending process to ensure that the SMS can be sent to the end user through the correct channel. After the SMS sending operation is completed, a sending result is obtained, and the sending result is analyzed to determine whether it is successful. If the SMS sending fails, the reason for the failure is analyzed, and the corresponding retry plan is determined according to the preset retry strategy to generate a retry task. The retry strategy usually takes into account the specific cause of the failure, such as network failure, unreachable target server or temporary congestion of the channel, and different failure reasons correspond to different retry strategies. Based on the strategic retry mechanism, the failed tasks are retried more specifically to ensure that the SMS delivery rate can be maximized even in some unforeseen circumstances. Submit the retry task to a dedicated retry queue, and the failover module takes over the entire retry process. The failover module performs intelligent retries, combining multiple factors to determine the best time and number of retries in order to improve the success rate of retries. For example, if the sending channel is congested, choose to wait for a while before retrying instead of sending repeatedly immediately. Through intelligent fault handling, the overall sending success rate is improved while maintaining stability.After the retry is completed, the retry result is obtained, and the initial sending result is integrated with the retry result to generate a complete execution feedback information.
[0040] In one example, a text message sending request is received, and a preliminary verification is performed on the text message sending request, the verification content includes a user name, password, registration code, IP address and request frequency, and a verification result is generated, including: receiving a text message sending request containing a user name, password, registration code, sender's mobile phone number, recipient's mobile phone number list, text message content, scheduled sending time and text message type; entering the user name and password into a user verification module for matching verification to obtain a user identity verification result, and querying the user status based on the user identity verification result to obtain user status information; querying and matching the IP address whitelist according to the IP address in the text message sending request to obtain an IP address verification result, and entering the registration code into the registration code verification module to obtain the user identity verification result. The authentication module performs validity verification to obtain the registration code verification result; based on the user name, the number of recent user login attempts and the time interval are statistically analyzed to obtain the user request frequency data, and based on the user request frequency data, a threshold judgment is made on the user request frequency to obtain the frequency verification result; based on the user identity authentication result, user status information, IP address verification result, registration code verification result and frequency verification result, a comprehensive verification result is generated, and based on the comprehensive verification result, the verification failure situation is classified to obtain the verification failure type; based on the verification failure type and the preset error response template, the corresponding error response information is generated, and the error response information and the comprehensive verification result are combined to obtain the final verification result.
[0041] In this example, a text message sending request containing a user name, password, registration code, sender's mobile phone number, recipient's mobile phone number list, text message content, scheduled sending time, and text message type is received. The user name and password are entered into the user verification module for matching verification, and the user name and password are compared with the records in the user database stored in the system to confirm the identity of the user. The result of the user identity verification returns a Boolean value. If the user name and password match, the verification is passed, otherwise the verification fails. The user status is queried based on the user identity verification result. User status information refers to the user's account status, such as whether it is in a "normal" state, whether it is "locked" or "disabled". The query of the user status is achieved by searching the relevant fields in the user database. For example, assuming that the user status field in the database is identified as "status", its possible values include "active", "locked", "disabled", etc. The "status" field of the user is queried based on the authentication result. If the status is "active", it means that the user status is normal and the processing continues; if the status is "locked" or "disabled", there is a problem with the user account, the system will abort subsequent operations, and return relevant error information. Verify the source IP address of the request. To ensure that the request comes from a trusted address, query and match the IP address whitelist according to the IP address in the SMS request to obtain the IP address verification result. The IP address whitelist contains all trusted IP addresses that are allowed to access the system. By comparing the IP in the user request with the address in the whitelist, it is determined whether the request comes from a legitimate channel. Verify the registration code submitted by the user and input it into the registration code verification module for validity verification to confirm whether the registration code is valid. The registration code is a unique identifier generated and distributed to the user by the system. By comparing the registration code submitted by the user with the records in the database, forgery and illegal requests can be effectively prevented. Based on the user name, the number of recent user login attempts and time intervals are statistically analyzed to obtain the frequency data of user requests. The statistics of user request frequency data are used to identify whether the user has abnormal behavior, such as frequent login attempts are a sign of brute force cracking. According to the user's login record, the number of user login attempts within the specified time window is counted. By setting a request frequency threshold, such as setting the maximum number of attempts per 10 minutes to 3 times, it is determined whether the user exceeds the security limit. A comprehensive verification result is generated based on the user identity authentication result, user status information, IP address verification result, registration code verification result, and frequency verification result. For example, the comprehensive verification result is "passed" only when all verification results are "passed"; if any one of the verifications fails, the comprehensive verification result is "failed". If the comprehensive verification result is "failed", the verification failure is classified to determine the specific failure type.For example, if the failure reason is because the IP address is not in the whitelist, the failure type is "illegal IP address"; if the failure is due to exceeding the login frequency limit, the failure type is "too high request frequency". Through the detailed classification of failure reasons, different types of failures can be handled more targetedly and detailed error information can be provided to users. Based on the verification failure type and the preset error response template, the corresponding error response information is generated. The generated error response information is combined with the comprehensive verification result to obtain the final verification result. The final verification result includes whether the verification is passed or not, and also includes detailed error reasons, so that users can understand the specific reasons why the request was rejected.
[0042] In one example, based on the verification result, the SMS content is reviewed and template matched, the SMS processing method is determined, and the review result is generated, including: performing a null value check on the SMS content to obtain a content validity identifier, and based on the content validity identifier, obtaining the user signature setting from the user configuration database to obtain a signature requirement identifier; based on the signature requirement identifier, extracting the corresponding signature content from the user information database, combining the signature content with the SMS content to obtain the complete SMS content; performing character statistics on the complete SMS content, judging according to a preset length restriction rule to obtain a length compliance identifier, and performing semantic analysis and keyword extraction on the complete SMS content to obtain a content feature vector; based on the content feature vector, The preset white template library and black template library are used for similarity calculation to obtain template matching results, and the matching results are prioritized according to the similarity values of the template matching results, and the template with the highest matching degree is selected to obtain the best matching template; based on the type of the best matching template, the corresponding processing strategy is executed, if it is a black template, it is marked as interception, and if it is a white template, it is marked as acceleration to obtain a processing strategy identifier; for the SMS content with the processing strategy identifier as interception, an interception reason description is generated, and the interception reason description is associated with the SMS content to obtain an interception information record; the length compliance identifier, template matching result, processing strategy identifier and interception information record are combined to generate the final audit result, and the audit result is stored in the audit log database.
[0043] In this example, the SMS content is checked for null values. The validity of the content is determined by checking whether the SMS content field is an empty string or whether there are blank characters, and the content validity flag is obtained. If the content is determined to be invalid, the system terminates the processing and generates a corresponding error response, prompting the user to provide valid SMS content. The user's signature settings are obtained from the user configuration database to determine whether an additional signature is required. Based on the content validity flag If it is "valid", query the user configuration database to obtain the signature requirement identifier , indicating whether the user requires a signature to be attached to the text message. If "Signature required", the corresponding signature content is extracted from the user information database. Assume that the signature content variable is , and then combine the signature content with the SMS content to get the complete SMS content . It is expressed as:
[0044] ;
[0045] Indicates the complete text message content. Represents the original text message content, and Indicates the user's signature content. Perform character statistics on the complete SMS content to determine whether the SMS content meets the preset length limit rules. Assume that the SMS content length is , the preset maximum length is , the system will judge:
[0046] ;
[0047] in, Is the length compliance mark. If the length compliance mark is "compliant", the SMS can continue to be processed; if it is not compliant, an error response is generated to prompt the user that the SMS content is too long. After confirming that the SMS length is compliant, semantic analysis and keyword extraction are performed on the complete SMS content to obtain the content feature vector The content feature vector is extracted by using natural language processing (NLP) technology on the text message content, including word segmentation, part-of-speech tagging, entity recognition and other steps to extract keywords and semantic features from the text message. Assume that the extracted keywords are , the content feature vector is expressed as:
[0048] ;
[0049] in, Indicates keywords The weights are calculated by methods such as TF-IDF (term frequency-inverse document frequency). Content feature vector It reflects the core semantics of SMS and is an important input for subsequent template matching. Based on the content feature vector, the similarity of the preset white template library and black template library is calculated to obtain the template matching result. Assume that the white template library and the black template library are and , the matching degree is determined by calculating the cosine similarity between the content feature vector and each template feature vector. , similarity The calculation formula is:
[0050] ;
[0051] in, Representation Template The characteristic vector of Representation vector The norm of . By calculating the similarity between the content and each template, the matching results are prioritized and the template with the highest similarity is selected as the best matching template. Based on the type of the best matching template, the corresponding processing strategy is executed. If the best matching template belongs to the black template, the SMS is marked as "intercepted", and if it belongs to the white template, it is marked as "accelerated", thereby obtaining the processing strategy identifier For SMS content marked as intercepted, generate an interception reason description, associate the interception reason description with the SMS content, and obtain an interception information record. , template matching results, processing strategy identification The audit results are combined with the interception information records to generate the final audit results. The audit results are stored in the audit log database for future audit and analysis.
[0052] In one example, a sending channel is selected based on the audit result, and the selection of the sending channel takes into account the SMS type, the receiving mobile phone number operator type, the user package type, the channel priority, the channel load and the historical sending success rate, including: based on the SMS type information in the audit result, a preliminary screening of the channel database is performed to obtain a channel list that meets the SMS type, and based on the receiving mobile phone number, a query and match is performed on the number prefix database to obtain an operator type identifier; based on the operator type identifier, a secondary screening is performed on the channel list that meets the SMS type to obtain an operator matching channel list, and the user package type is extracted from the user information database, and the operator matching channel list is prioritized based on the user package type to obtain a package priority channel list; for each channel in the package priority channel list, its The current load data is used to calculate the load rate, obtain the channel load status list, and input the channel load status list into the load balancing algorithm module, and screen it based on the preset load threshold to obtain a load-qualified channel list; the historical sending success rate data of each channel in the load-qualified channel list is extracted from the historical database, and the weighted average success rate is calculated to obtain a channel success rate list, and based on the channel success rate list, the load-qualified channel list is sorted, and the top N channels with the highest success rate are selected to obtain a candidate channel list; the candidate channel list is input into the intelligent routing algorithm, and the channel priority, load status and success rate are comprehensively considered to calculate the comprehensive score of each channel to obtain a channel score list; according to the channel score list, the channel with the highest score is selected as the final sending channel, and the channel selection result is generated, and the channel selection result is stored in the routing log database.
[0053] In this example, the channel database is initially screened to find a list of channels that match a specific SMS type. Based on the SMS type in the audit result, such as "normal text SMS" or "marketing SMS", the channel database is queried to filter out channels that match the type. Assuming that the SMS type is "marketing SMS", the channel database is filtered to obtain a list of all channels that support the sending of marketing SMS. Based on the receiving mobile phone number, the number prefix database is queried and matched to obtain the operator type identifier. The number prefix database stores the number segments of different operators. By matching the prefix of the receiving mobile phone number, it is determined which operator the number belongs to, which helps the system give priority to the channels that support the corresponding operator when selecting channels to avoid sending failures due to mismatch between channels and operators. Based on the operator type identifier, the channel list that matches the SMS type is secondary screened to obtain a list of channels that match the operator. After obtaining the operator matching channel list, the selection is further optimized to sort the channels based on the user package type. The user's package type is extracted from the user information database. Assuming that the package type is "standard package", the package type includes certain priority sending channels. For example, the "standard package" subscribed by the user enjoys priority for certain channels, while other channels have relatively lower priority. Based on this information, the operator is matched with a channel list. Sort by priority and get a list of channels with priority for packages , where the channels with higher priority are in front. For each channel in the package priority channel list, consider the current load of each channel to ensure that the selected channel can stably and effectively process new sending requests. Extract the current load data of each channel from the channel status database, including CPU usage, bandwidth utilization, etc. Assume that the current load of a channel is , and its calculation formula is:
[0054] ;
[0055] in, Indicates the current resource usage of the channel, such as bandwidth or CPU usage. Indicates the total amount of resources available for the channel. By calculating the load rate , get the load status list of each channel. Input the load status list into the load balancing algorithm module, filter the channels based on the preset load threshold to determine the list of channels with qualified loads. For example, if the set load threshold is 0.8, that is, the resource utilization rate cannot exceed 80%, then only channels with a load rate below 80% will be selected to ensure that each selected channel has sufficient resources to handle new sending tasks. Finally, the historical sending success rate is considered to optimize the channel selection. The historical sending success rate data of each channel in the load qualified channel list is extracted from the historical database. Assuming that a channel The historical sending success rate is The weighted average success rate is calculated based on the success rate data to more accurately reflect the reliability of each channel. The weighted average calculation of the success rate is expressed as:
[0056] ;
[0057] in, represents the weighted average success rate, Indicates The success rate of each channel, The weight representing the success rate is set based on the historical sending volume or priority. In this way, the comprehensive performance of each channel is evaluated to obtain a channel success rate list. Based on the channel success rate list, the list of channels with qualified loads is sorted, and the top channels with the highest success rate are selected. channels, and obtain a list of candidate channels . The candidate channel list The intelligent routing algorithm module is input to calculate the comprehensive score of each channel by comprehensively considering multiple factors such as channel priority, load status, and sending success rate. The calculation of the comprehensive score is achieved through the following formula:
[0058] ;
[0059] in, Indicates channel The comprehensive score of Indicates the priority of the channel. Indicates the load rate of the channel, Indicates the sending success rate of the channel. , and It is the weight coefficient of different factors, which is used to balance the impact of priority, load rate and success rate on the comprehensive score. The suitability of the channel is determined according to its overall performance, so as to improve the success rate and efficiency of sending. According to the channel score list, the channel with the highest score is selected as the final sending channel, and the channel selection result is generated. This selection result is stored in the routing log database for subsequent auditing and system performance analysis.
[0060] In one example, a priority is assigned to a text message according to a selected sending channel, and the priority is based on the user level, text message type, user historical behavior and current system load, and the text message is placed in a corresponding multi-level feedback queue, including: extracting user level data from a user information database, mapping it according to a preset user level weight table, and obtaining an initial user level score; based on the text message type, querying the text message type priority database, obtaining the corresponding type weight, and performing weighted calculation with the user level initial score to obtain a type weighted score; extracting the user's recent sending records from a user behavior analysis database, calculating the user's sending volume, success rate and complaint rate, and obtaining a user's historical behavior indicator; inputting the user's historical behavior indicator into a behavior scoring model, and calculating it according to preset scoring rules to obtain a user behavior score. Score, and normalize the type weighted score and user behavior score, and combine them according to the preset weights to obtain the user's comprehensive score; obtain the current system load data from the system monitoring module, including CPU usage, memory occupancy and network bandwidth utilization, and calculate the system load index; based on the system load index, query the load adjustment strategy table to obtain the corresponding priority adjustment coefficient, and multiply the user's comprehensive score by the priority adjustment coefficient to obtain the final priority score; according to the final priority score, compare the priority boundary table of the multi-level feedback queue to determine the priority level of the SMS and obtain the queue allocation result; based on the queue allocation result, encapsulate the SMS information into a task object, insert it into the multi-level feedback queue of the corresponding priority, and update the queue status information to obtain the queue insertion confirmation information.
[0061] In this example, user level data is extracted from the user information database in order to preliminarily classify users. User level data reflects the importance of users in the system, and these levels are related to the user's historical consumption, service usage, etc. Mapping is performed according to the preset user level weight table to obtain the initial score of the user level, and different priorities are assigned to different user groups, thereby achieving differentiated services when allocating resources. After obtaining the initial score of the user level, the type of SMS is considered in order to set different priorities for different types of SMS. SMS types include "notification SMS", "marketing SMS", etc., and each type has a corresponding weight in the priority database. Based on the SMS type, the SMS type priority database is queried. Assuming that the SMS type is "marketing SMS", its weight is 2, recorded as . Set the initial score of the user level Weights related to SMS type Perform weighted calculation to obtain type weighted score , its formula is expressed as:
[0062] ;
[0063] in, Indicates the type weighted score, which is used to integrate the priority weight of the user level and SMS type. In order to refine the user's priority evaluation, the user's recent sending records are extracted from the user behavior analysis database to calculate the user's sending volume, success rate and complaint rate, and obtain the user's historical behavior indicators. For example, if the user's sending volume in the past 30 days is The sending success rate is The complaint rate is , these data can reflect whether the user's sending behavior is compliant and stable. These behavior data are input into the behavior scoring model. The behavior scoring model uses the preset scoring rules to calculate the user behavior score. For example, the behavior score considers the combination of the sending success rate and the complaint rate. Assume that the scoring rule is:
[0064] ;
[0065] in, and is the weight coefficient in the scoring rule, which is used to balance the impact of the sending success rate and the complaint rate on the final behavior score. , (95% success rate), , (1% complaint rate), then the behavior score . Through scoring, the quality of user behavior can be effectively measured so that those users with good performance can be given priority when allocating resources. Weighted score for type and user behavior score Normalization is performed to ensure that the two values are within the same range for comparison and combination. The normalized values are recorded as and . According to the preset weight and The two values are weighted together to get the user's comprehensive score. , and its calculation formula is:
[0066] ;
[0067] User comprehensive score It reflects the comprehensive performance of user level, SMS type and user behavior. After obtaining the user's comprehensive score, consider the current system load. Obtain the current load data from the system monitoring module, including CPU usage , memory usage and network bandwidth utilization These indicators reflect the current resource usage of the system. Use this data to calculate the system load index , the formula is:
[0068] ;
[0069] For example, if , , , then the load index is:
[0070] ;
[0071] Based on the load index, query the load adjustment strategy table to determine the corresponding priority adjustment coefficient Assuming that under the current load, the adjustment coefficient is 0.9, the user's comprehensive score Multiply it by the adjustment factor to get the final priority score
[0072] ;
[0073] like , , the final priority score is:
[0074] ;
[0075] Based on the final priority score , compare the priority boundary table of the multi-level feedback queue to determine the priority level of the SMS and obtain the queue allocation result. The multi-level feedback queue is used to manage SMS tasks of different priorities. High-priority SMS will be assigned to queues with higher priorities to ensure that these SMS can be processed first when system resources are tight. Based on the queue allocation result, the SMS is encapsulated into a task object and inserted into the multi-level feedback queue of the corresponding priority. Update the queue status information to ensure that new tasks can be correctly managed and tracked, and generate queue insertion confirmation information for subsequent processing.
[0076] Furthermore, the sending volume, success rate and complaint rate in the user's historical behavior indicators are respectively input into the multi-channel input layer of the behavior scoring model, each channel corresponds to an indicator, and each channel contains historical data of 5 time steps to obtain the initial time series input tensor; the time attention mechanism is applied to the initial time series input tensor, and the attention weight of each time step is calculated to obtain the time weighted input tensor; the time weighted input tensor is input into the one-dimensional convolution layer, using 32 convolution kernels, the kernel size is 3, the step size is 1, the padding method is "same", and the activation function is LeakyReLU to obtain the local feature map; for the local feature The maximum pooling operation is applied to the graph with a pooling size of 2 to obtain a downsampled feature map; the downsampled feature map is input into the LSTM layer, which contains 64 hidden units, and the tanh activation function is used to obtain a temporal coding vector; the temporal coding vector is concatenated with the user's static features (such as user level and credit score) to obtain a mixed feature vector; the self-attention mechanism is applied to the mixed feature vector to calculate the correlation weights between features to obtain an attention-weighted feature vector; the attention-weighted feature vector is input into the residual network, which contains 3 residual blocks, each of which contains two fully connected layers and one skip connection, and the ELU activation function is used. The number of hidden units is 32, and the sequence dependency between features is simulated to obtain a serialized feature vector. The Squeeze-and-Excitation block is applied to the serialized feature vector to dynamically adjust the importance of feature channels. The channel recalibrated feature vector is obtained; the channel recalibrated feature vector is input into a bidirectional long short-term memory network (Bi-LSTM) with 16 hidden units to capture bidirectional context information and obtain a context-aware feature vector; adaptive instance normalization (AdaIN) is applied to the context-aware feature vector, and the normalization parameter is dynamically adjusted according to the feature statistics to obtain an adaptive normalized feature vector; the adaptive normalized feature vector is input into the output layer of the mixture density network (MDN), which contains 5 Gaussian mixture components, each of which is parameterized by mean, variance and mixing weight, to obtain the user behavior score represented by probability distribution.
[0077] In one example, billing and quota control are performed according to SMS information in a multi-level feedback queue. The billing and quota control are based on the SMS type, selected channel and user package to generate a billing result, including: extracting the SMS information to be processed from the multi-level feedback queue, parsing the SMS type, selected channel and user ID therein to obtain basic billing data, and querying the user package database based on the user ID to obtain the user's current package type, the remaining number of messages and the package unit price to obtain the user package information; querying the billing rule database according to the SMS type and the selected channel to obtain the corresponding basic price and discount coefficient to obtain the channel billing parameters; inputting the user package information and the channel billing parameters into the billing strategy module, and determining the final billing method to be adopted according to the preset billing priority rules to obtain the billing result. billing plan; based on the billing plan, calculate the fee required for this sending, taking into account the factors of SMS length and the number of split messages, obtain the original fee amount, and query the user's current account balance and credit limit from the user account database, calculate the total available amount, and obtain the user's credit limit information; compare the original fee amount with the user's credit limit information to determine whether the sending conditions are met and generate a credit limit verification result; according to the credit limit verification result, execute the corresponding processing strategy: if the credit limit is sufficient, withhold the corresponding fee and update the user account information; if the credit limit is insufficient, generate an error message and obtain the withholding result; based on the withholding result, update the user's package usage record, including the remaining number of messages and the cumulative usage, obtain the package update result, and integrate the withholding result, package update result and original billing information to generate a billing result.
[0078] In this example, the SMS messages to be processed are extracted from the multi-level feedback queue. The extracted SMS messages include the type of SMS, the selected sending channel, and the user ID. The purpose of parsing this information is to determine the specific conditions and requirements for sending, and to provide basic data for subsequent billing. The user package database is queried based on the user ID to obtain the current package information of the user. The user package information includes the user's package type, the number of SMS messages remaining in the package, and the unit price of the package. The billing rule database is queried according to the type of SMS and the selected channel to obtain the corresponding base price and discount factor to obtain the billing parameters of the channel. Assuming that the base price of "notification SMS" on "Channel A" is 0.10 yuan per message, and the discount factor is 0.9, the channel billing parameters are expressed by the following formula:
[0079] ;
[0080] in, Indicates the billing price of the channel. represents the base price, Represents the discount coefficient. Calculate the single fee that the user needs to pay when sending text messages using the selected channel for subsequent fee calculations. Input the user package information and channel billing parameters into the billing strategy module, determine the final billing method based on the preset billing priority rules, and obtain the billing plan. For example, give priority to the remaining number of messages in the user package. If the remaining number is insufficient, use the channel billing parameters to calculate the additional fee. Based on the billing plan, calculate the cost required for this text message sending. When calculating the cost, consider the length of the text message content and whether it needs to be split into multiple messages for sending. For example, if the text message content exceeds the maximum length of a single text message, it needs to be split into multiple messages. Assuming that the text message length is 140 characters and the maximum length of a single text message is 70 characters, then this text message needs to be split into 2 messages for sending. Set the cost of each text message to , then the original cost amount It is expressed as:
[0081] ;
[0082] in, Indicates the number of split SMS messages. Indicates the cost of each SMS. Query the user's current account balance and credit limit from the user account database to calculate the user's available total. The user's available total It is expressed as:
[0083] ;
[0084] in, Represents the account balance, Indicates the credit limit. Compare the original fee amount with the user's available total to determine whether the user has enough credit to complete the sending operation. Less than or equal to the total available , it means that the user's credit limit is sufficient, and the system will pre-deduct the corresponding fees and update the user's account information; if the fees are insufficient, the system will generate an error message, prompting the user that the balance is insufficient and the message cannot be sent. Update the user's package usage record, including the number of SMS messages remaining in the package and the cumulative usage. At the same time, record the user's cumulative usage for subsequent statistics and analysis. After updating the package information, generate the package update results for review and verification in the subsequent process. Integrate the pre-deduction results, package update results, and original billing information to generate the final billing result. This result is stored in the billing log database for subsequent auditing and analysis.
[0085] In one example, based on the billing result, the SMS information to be sent is stored in the distributed cache system, the sending task is processed by the asynchronous processing queue and the sending work thread pool, and failover and intelligent retry are performed to obtain execution feedback information, including: based on the billing result, the SMS information to be sent is encoded and processed to generate an SMS task object, and the SMS task object is serialized, and the serialized data is sharded according to the preset sharding strategy to obtain a sharded data set; consistent hash calculation is performed on the sharded data set to determine the storage node of each shard, obtain a sharded storage mapping table, and according to the sharded storage mapping table, the sharded data is written into the corresponding distributed cache node to obtain a cache write result; based on Cache write results, generate SMS task metadata, and submit it to the asynchronous processing queue, obtain queue entry confirmation, and select an idle thread from the sending work thread pool, bind it to the task in the asynchronous processing queue, and obtain the task processing thread; the task processing thread reads the SMS task data from the distributed cache system, executes the SMS sending operation, obtains the sending result, and analyzes the sending result. If the sending fails, determine the retry plan based on the failure cause and the preset retry strategy to obtain the retry task; submit the retry task to a dedicated retry queue, and the failover module takes over, executes the intelligent retry process, obtains the retry result, and integrates the sending result and the retry result to generate execution feedback information.
[0086] In this example, the SMS content, user information, channel information and other data are encoded to form a structured object that is convenient for subsequent processing, and the SMS task object is obtained. The SMS task object is serialized to convert the complex object into a format that can be stored and transmitted, such as JSON or binary format. Assume that the SMS task object is , the serialization process is expressed as:
[0087]
[0088] in, Represents serialized data. is a serialization operation function. Through serialization, the SMS task object is converted into a data format that can be persistently stored and transmitted in the network. According to the preset sharding strategy, the serialized data is sharded. Large data is divided into smaller blocks for easy storage and management in a distributed system. For example, if the serialized data is large, it is divided into multiple small fragments of equal size, which are recorded as , these fragments are collected to form a sharded dataset The sharding strategy is based on factors such as the size of the data and the load balance of the cache nodes to ensure that each storage node does not suffer performance degradation due to excessive data. Consistent hashing is performed on the sharded data set to determine the storage node for each shard. Consistent hashing is a distributed storage algorithm that can evenly map data to different storage nodes to achieve load balancing. Assuming the shard Mapped to storage nodes through consistent hashing function , the hash calculation is expressed as:
[0089] ;
[0090] in, Represents a storage node, and hash() is a consistent hash function. Through calculation, we get the shard storage mapping table , record which node each shard should be stored on. According to the mapping table, write the shard data to the corresponding distributed cache node to get the cache write result. Is a Boolean value or status code that indicates whether the data was successfully written. For example, if all shard data is successfully written to the cache, then If the data is successfully written to the distributed cache node, it is "successful", and if some shards fail to write, it is "failed". After the data is successfully written to the distributed cache node, the metadata of the SMS task is generated based on the cache writing result and submitted to the asynchronous processing queue. The metadata of the SMS task includes information such as the unique identifier of the SMS task, the location of the target cache node, and the task status. These metadata are submitted to the asynchronous processing queue so that the subsequent processing can obtain the queue entry confirmation. The queue entry confirmation indicates that the SMS task has been successfully added to the processing queue and is waiting for further execution. Select an idle thread from the sending work thread pool and bind it to the task in the asynchronous processing queue to obtain the task processing thread. The task processing thread is responsible for executing the core operation of SMS sending, reading the data of the SMS task from the distributed cache system, and ensuring that all information is in the latest available state before sending. After the task processing thread successfully reads the SMS task data, it executes the SMS sending operation and obtains the sending result. The sending result indicates the status of this sending, such as "successful" or "failed". The sending result is analyzed. If the sending fails, it will determine whether a retry is required based on the cause of the failure and the preset retry strategy, and generate the corresponding retry task. The retry strategy takes into account the specific reasons for failure, such as network problems, unreachable target servers, channel congestion, etc. Different reasons correspond to different retry schemes. Assuming the retry strategy is "wait 5 seconds and retry up to 3 times", the system will generate a retry task object, which contains information such as the number of retries and the retry time. The retry task is submitted to a dedicated retry queue, which is taken over by the failover module to execute the intelligent retry process. The intelligent retry process adjusts the timing and number of retries according to the preset retry conditions and strategies. For example, if it is detected that the sending channel is temporarily unavailable, the retry time is postponed to wait for the channel to return to normal. After the retry is completed, the retry result is obtained and integrated with the initial sending result to generate the final execution feedback information. The execution feedback information contains all the states of the entire sending process, including whether the initial sending is successful, the number of attempts during the retry process, and the final sending result.
[0091] Further, the cache write result is parsed to extract the key information of the SMS task, including the task ID, sender ID, recipient list, content summary and timestamp, to obtain the basic information of the task; based on the basic information of the task, a task priority identifier is generated, and it is combined with the basic information of the task to form preliminary task metadata; the preliminary task metadata is compressed and encoded to obtain compressed metadata, and the hash value of the compressed metadata is calculated as the unique identifier of the task; the task unique identifier is associated with the compressed metadata to construct a complete task metadata structure; based on the complete task metadata structure, a task submission request is generated and sent to the queue manager of the asynchronous processing queue; the queue manager receives the task submission request, verifies its legitimacy and obtains a verification result; according to the verification result, if the verification passes, queue storage space is allocated to the task, and queue location information is generated; The task metadata is written into the allocated queue storage space, and the queue index is updated to obtain the result of the enqueue operation; based on the enqueue operation result, enqueue confirmation information is generated and returned to the task submission module; the current idle thread list is obtained from the thread pool management module, and the load of each thread is calculated to obtain thread load statistics; according to the thread load statistics, the load balancing algorithm is used to select the optimal idle thread to obtain the target processing thread; a task-thread binding request is generated, including the task unique identifier and the target processing thread ID, and sent to the thread scheduler; the thread scheduler receives the task-thread binding request, processes it, performs the binding operation, and obtains the binding result; based on the binding result, the thread status information and the task status information are updated, and a binding confirmation message is generated; the binding confirmation message is sent to the task management module and the thread pool management module to complete the association between the task and the processing thread.
[0092] Reference Figure 2 This embodiment provides an HTTP short message gateway processing device, including:
[0093] Receiving module 1, used to receive a text message sending request, perform preliminary verification on the text message sending request, the verification content includes user name, password, registration code, IP address and request frequency, and generate a verification result;
[0094] Matching module 2, used to review and template match the SMS content according to the verification result, determine the SMS processing method, and generate the review result;
[0095] Selection module 3 is used to select a sending channel based on the audit results. The selection of the sending channel takes into account the SMS type, the type of operator of the receiving mobile phone number, the type of user package, the channel priority, the channel load and the historical sending success rate;
[0096] The allocation module 4 is used to assign priorities to the SMS according to the selected sending channel. The priorities are based on the user level, SMS type, user historical behavior and current system load, and the SMS is placed in the corresponding multi-level feedback queue;
[0097] Control module 5, used to perform billing and quota control based on the SMS information in the multi-level feedback queue, and the billing and quota control is based on the SMS type, the selected channel and the user package to generate the billing result;
[0098] Execution module 6 is used to store the SMS information to be sent into the distributed cache system according to the billing result, process the sending task through the asynchronous processing queue and the sending work thread pool, and perform failover and intelligent retry to obtain execution feedback information.
[0099] In this embodiment, for the specific implementation of each unit in the above device embodiment, please refer to the above method embodiment, which will not be repeated here.
[0100] Reference Figure 3 In an embodiment of the present invention, a computer device is also provided. The computer device may be a server, and its internal structure may be as follows: Figure 3 As shown. The computer device includes a processor, a memory, a display screen, an input device, a network interface and a database connected through a system bus. Among them, the processor designed by the computer is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store the corresponding data in this embodiment. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the above method is implemented.
[0101] Those skilled in the art will understand that Figure 3 The structure shown in the figure is merely a block diagram of a portion of the structure related to the solution of the present invention, and does not constitute a limitation on the computer device to which the solution of the present invention is applied.
[0102] An embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the above method is implemented. It can be understood that the computer-readable storage medium in this embodiment can be a volatile readable storage medium or a non-volatile readable storage medium.
[0103] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media provided by the present invention and used in the embodiments may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double-speed data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM.
[0104] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, device, article or method including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, device, article or method. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the presence of other identical elements in the process, device, article or method including the element.
[0105] The above description is only a preferred embodiment of the present invention, and does not limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made by using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A HTTP SMS gateway processing method, characterized in that: The following steps are involved: Receive a text message sending request, perform preliminary verification on the text message sending request, including user name, password, registration code, IP address and request frequency, and generate a verification result; According to the verification result, the SMS content is reviewed and template matched, the SMS processing method is determined, and the review result is generated; Based on the audit result, a sending channel is selected, and the selection of the sending channel takes into account the SMS type, the receiving mobile phone number operator type, the user package type, the channel priority, the channel load and the historical sending success rate; specifically comprising: according to the SMS type information in the audit result, a preliminary screening of the channel database is performed to obtain a channel list that meets the SMS type, and based on the receiving mobile phone number, a query and match is performed on the number prefix database to obtain an operator type identifier; according to the operator type identifier, a secondary screening of the channel list that meets the SMS type is performed to obtain an operator matching channel list, and the user package type is extracted from the user information database, and the operator matching channel list is prioritized based on the user package type to obtain a package priority channel list; for each channel in the package priority channel list, its The current load data is used to calculate the load rate, obtain a channel load status list, and the channel load status list is input into the load balancing algorithm module, and is screened based on a preset load threshold to obtain a load-qualified channel list; the historical sending success rate data of each channel in the load-qualified channel list is extracted from the historical database, and the weighted average success rate is calculated to obtain a channel success rate list, and based on the channel success rate list, the load-qualified channel list is sorted, and the top N channels with the highest success rate are selected to obtain a candidate channel list; the candidate channel list is input into the intelligent routing algorithm, and the channel priority, load status and success rate are comprehensively considered to calculate the comprehensive score of each channel to obtain a channel score list; according to the channel score list, the channel with the highest score is selected as the final sending channel, and a channel selection result is generated, and the channel selection result is stored in the routing log database; According to the selected sending channel, the SMS is assigned a priority based on the user level, SMS type, user historical behavior and current system load, and the SMS is placed in the corresponding multi-level feedback queue; According to the SMS information in the multi-level feedback queue, billing and quota control are performed, and the billing and quota control are based on the SMS type, the selected channel and the user package to generate a billing result; According to the billing result, the SMS information to be sent is stored in the distributed cache system, the sending task is processed through the asynchronous processing queue and the sending work thread pool, and failover and intelligent retry are performed to obtain execution feedback information.
2. The HTTP SMS gateway processing method according to claim 1, characterized in that: The receiving SMS sending request performs preliminary verification on the SMS sending request, the verification content includes user name, password, registration code, IP address and request frequency, and generates a verification result, including: Receive a text message sending request containing a user name, password, registration code, sender's phone number, list of recipients' phone numbers, text message content, scheduled sending time, and text message type; Input the user name and password into the user verification module for matching verification to obtain a user identity verification result, and query the user status based on the user identity verification result to obtain user status information; According to the IP address in the SMS sending request, the IP address whitelist is queried and matched to obtain the IP address verification result, and the registration code is input into the registration code verification module for validity verification to obtain the registration code verification result; Based on the user name, statistically analyze the number of recent login attempts and time intervals of the user to obtain user request frequency data, and perform threshold judgment on the user request frequency based on the user request frequency data to obtain a frequency verification result; Generate a comprehensive verification result based on the user identity authentication result, user status information, IP address verification result, registration code verification result and frequency verification result, and classify the verification failure situation according to the comprehensive verification result to obtain the verification failure type; Based on the verification failure type and a preset error response template, corresponding error response information is generated, and the error response information is combined with the comprehensive verification result to obtain a final verification result.
3. The HTTP SMS gateway processing method according to claim 2, characterized in that: According to the verification result, the SMS content is reviewed and template matched, the SMS processing method is determined, and the review result is generated, including: Performing a null value check on the content of the SMS to obtain a content validity identifier, and based on the content validity identifier, obtaining a user signature setting from a user configuration database to obtain a signature requirement identifier; According to the signature requirement identifier, the corresponding signature content is extracted from the user information database, and the signature content is combined with the SMS content to obtain the complete SMS content; Performing character statistics on the complete SMS content, judging according to a preset length restriction rule to obtain a length compliance mark, and performing semantic analysis and keyword extraction on the complete SMS content to obtain a content feature vector; Based on the content feature vector, similarity calculation is performed on the preset white template library and the black template library to obtain template matching results, and the matching results are prioritized according to the similarity values of the template matching results, and the template with the highest matching degree is selected to obtain the best matching template; Based on the type of the best matching template, a corresponding processing strategy is executed, if it is a black template, it is marked as interception, if it is a white template, it is marked as acceleration, and a processing strategy identifier is obtained; For the SMS content identified as intercepted by the processing policy, generating an interception reason description, associating the interception reason description with the SMS content, and obtaining an interception information record; The length compliance identifier, template matching result, processing strategy identifier and interception information record are integrated to generate a final audit result, and the audit result is stored in the audit log database.
4. The HTTP SMS gateway processing method according to claim 1, characterized in that: The SMS is assigned a priority based on the selected sending channel. The priority is based on the user level, SMS type, user historical behavior and current system load, and the SMS is placed in a corresponding multi-level feedback queue, including: Extract user level data from the user information database, map it according to a preset user level weight table, and obtain an initial user level score; Based on the SMS type, query the SMS type priority database to obtain the corresponding type weight, and perform weighted calculation with the initial score of the user level to obtain a type weighted score; Extract the user's recent sending records from the user behavior analysis database, calculate the user's sending volume, success rate and complaint rate, and obtain the user's historical behavior indicators; Input the user's historical behavior indicators into the behavior scoring model, calculate according to the preset scoring rules to obtain the user behavior score, and normalize the type weighted score and the user behavior score, and combine them according to the preset weights to obtain the user's comprehensive score; Obtain the current system load data from the system monitoring module, including CPU usage, memory usage, and network bandwidth utilization, and calculate the system load index; Based on the system load index, query the load adjustment strategy table to obtain the corresponding priority adjustment coefficient, and multiply the user comprehensive score by the priority adjustment coefficient to obtain a final priority score; According to the final priority score, the priority level of the short message is determined by comparing the priority boundary table of the multi-level feedback queue, and a queue allocation result is obtained; Based on the queue allocation result, the short message information is encapsulated into a task object, inserted into a multi-level feedback queue of a corresponding priority, and the queue status information is updated to obtain queue insertion confirmation information.
5. The HTTP SMS gateway processing method according to claim 4, characterized in that: The billing and quota control are performed according to the SMS information in the multi-level feedback queue, and the billing and quota control are based on the SMS type, the selected channel and the user package to generate the billing result, including: Extract the SMS messages to be processed from the multi-level feedback queue, parse the SMS type, selected channel and user ID therein, obtain the basic billing data, and query the user package database based on the user ID to obtain the user's current package type, remaining number of messages and package unit price, and obtain the user package information; According to the SMS type and the selected channel, query the billing rule database to obtain the corresponding basic price and discount coefficient, and obtain the channel billing parameters; Input the user package information and channel billing parameters into the billing strategy module, determine the final billing method to be adopted according to the preset billing priority rules, and obtain the billing plan; Based on the billing plan, the cost required for this sending is calculated, and the factors of the SMS length and the number of split messages are taken into consideration to obtain the original cost amount, and the user's current account balance and credit limit are queried from the user account database, the available total amount is calculated, and the user credit limit information is obtained; Compare the original fee amount with the user's credit information to determine whether the sending conditions are met and generate a credit verification result; According to the credit limit verification result, a corresponding processing strategy is executed: if the credit limit is sufficient, the corresponding fee is withheld and the user account information is updated; if the credit limit is insufficient, an error message is generated and the withholding result is obtained; Based on the pre-deduction result, the user package usage record is updated, including the remaining number of items and the cumulative usage, to obtain the package update result, and the pre-deduction result, the package update result and the original billing information are integrated to generate the billing result.
6. The HTTP SMS gateway processing method according to claim 5, characterized in that: According to the billing result, the SMS message to be sent is stored in the distributed cache system, the sending task is processed through the asynchronous processing queue and the sending work thread pool, and the failover and intelligent retry are performed to obtain the execution feedback information, including: Based on the billing result, the SMS information to be sent is encoded to generate an SMS task object, and the SMS task object is serialized, and the serialized data is fragmented according to a preset fragmentation strategy to obtain a fragmented data set; Perform consistent hash calculation on the shard data set to determine the storage node of each shard, obtain a shard storage mapping table, and write the shard data into corresponding distributed cache nodes according to the shard storage mapping table to obtain a cache write result; Generate SMS task metadata based on the cache write result, submit it to the asynchronous processing queue, obtain queue entry confirmation, select an idle thread from the sending work thread pool, bind it to the task in the asynchronous processing queue, and obtain a task processing thread; The task processing thread reads the SMS task data from the distributed cache system, executes the SMS sending operation, obtains the sending result, and analyzes the sending result. If the sending fails, a retry plan is determined according to the failure cause and the preset retry strategy to obtain the retry task; The retry task is submitted to a dedicated retry queue and taken over by the failover module, an intelligent retry process is executed, a retry result is obtained, and the sending result and the retry result are integrated to generate execution feedback information.
7. An HTTP short message gateway processing device, characterized in that: For implementing the steps of the method according to any one of claims 1 to 6, the device comprises: A receiving module is used to receive a text message sending request, perform preliminary verification on the text message sending request, the verification content includes user name, password, registration code, IP address and request frequency, and generate a verification result; A matching module, used to review and template match the SMS content according to the verification result, determine the SMS processing method, and generate a review result; A selection module, for selecting a sending channel based on the audit result, wherein the selection of the sending channel takes into account the SMS type, the receiving mobile phone number operator type, the user package type, the channel priority, the channel load and the historical sending success rate; An allocation module is used to assign priorities to SMS messages according to the selected sending channel, wherein the priorities are based on user level, SMS type, user historical behavior and current system load, and the SMS messages are placed in corresponding multi-level feedback queues; A control module, used to perform billing and quota control according to the SMS information in the multi-level feedback queue, wherein the billing and quota control generates a billing result based on the SMS type, the selected channel and the user package; The execution module is used to store the SMS information to be sent into the distributed cache system according to the billing result, process the sending task through the asynchronous processing queue and the sending work thread pool, and perform failover and intelligent retry to obtain execution feedback information.
8. A computer device comprising a memory and a processor, wherein a computer program is stored in the memory, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
CMPP protocol short message adaptation method and device, equipment and storage medium
CN119012146A
System and method for implementing a subscription-based social media platform
US8667075B1