A method, device, equipment and storage medium for splicing short messages

By embedding Lua scripts in the service cluster and using Lua scripts to determine the integrity of SMS data packets, the existing technology problems of high resource consumption and low timeliness of long SMS splicing are solved, and more efficient SMS splicing and processing are achieved.

CN114339637BActive Publication Date: 2024-08-23SHANGHAI DAHAN TRICOM COMM
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202111682413.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-30
Publication Date
2024-08-23
Estimated Expiration
2041-12-30

AI Technical Summary

Technical Problem

When processing long short message splicing, the existing technology consumes a lot of resources and has low timeliness, and it cannot ensure that the subsequent processing logic is triggered immediately when all data packets arrive. Especially when the amount of data in Redis is large, scanning and judgment take longer. , increasing the dwell time of text messages.

Method used

Embed a Lua script in the service cluster, and use the Lua script to determine whether all data sub-packets of the text messages to be spliced ​​have been received. This reduces the number of network requests and improves timeliness. It is improved to active notification mode and immediately when the last sub-data packet is received. Trigger subsequent processing logic.

Benefits of technology

It reduces the number of network requests, improves timeliness, ensures that subsequent processing logic is triggered immediately when all data packets arrive, and reduces SMS dwell time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114339637B
    Figure CN114339637B
Patent Text Reader

Abstract

The present application discloses a method, device, equipment and storage medium for splicing short messages, including: receiving a preset Lua script and embedding it into a service cluster; receiving a script call request sent by a short message platform, obtaining a data sub-packet of a short message to be spliced ​​in the short message platform, and judging whether the short message to be spliced ​​is a long short message based on the data parameters of the data sub-packet; if so, executing the Lua script, and judging whether all the data sub-packets of the short message to be spliced ​​are received based on the data parameters, and obtaining the corresponding execution result; if the execution result is that all the data sub-packets of the short message to be spliced ​​have been received, returning the execution result and all the data sub-packets of the short message to be spliced ​​to the short message platform, so that the short message platform splices the data sub-packets based on the data parameters, and obtains the complete data packet corresponding to the short message to be spliced. The present application reduces resource waste and improves timeliness by embedding a Lua script in a service cluster, using the Lua script to judge whether all data packets are received and returning the corresponding information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method, device, equipment and storage medium for splicing short messages. Background Art

[0002] In the SMS sending system, it is usually divided into two parts: the business system (client system) and the SMS platform (server system). The client system produces the SMS content and submits it to the server through the SMS protocol for sending. The communication protocol generally uses China Mobile CMPP (China Mobile Peer to Peer, China Mobile Point-to-Point Protocol) and other protocols. When the SMS content is larger than 140 bytes, it is called a long SMS. The client system needs to split the long SMS content into multiple data packets for submission. In some scenarios (such as security filtering of content, etc.), the server needs to complete the long SMS in sequence before further processing.

[0003] As the sending scale continues to expand, the concurrency requirements are getting higher and higher, and the timeliness requirements are getting higher and higher, both the client system and the server system will adopt a distributed cluster architecture. This will bring about a problem about the splicing of long SMS on the server: on the client, after a long SMS is split, it may be submitted to the server system in a random order through different links. At the same time, the server is also a distributed cluster structure. Different data sub-packets of the same long SMS may fall on different service nodes, and the arrival order is also unreliable.

[0004] The common method for processing long text message splicing at present is: after the server node receives one of the data sub-packets of a long text message sent by the client, it stores the data packet in Redis (Remote Dictionary Server) and scans Redis to determine whether all sub-packets of the same long text message have arrived. If they have arrived, they are taken out for processing. Another thread regularly scans Redis and determines whether all data packets of the same long text message have arrived. If all have arrived, all data packets under the long text message are taken out and the content is spliced ​​in order. Or when the maximum validity period is exceeded, it is taken out for processing. The existing technology has the following problems: resource consumption. The thread needs to continuously scan the IDs of all long text messages in Redis, take out and determine whether the data packets have arrived, and the frequency of network request operations to Redis is high and the number of times is large; the timeliness is reduced. This method belongs to passive scanning splicing, which cannot ensure that the subsequent processing logic is triggered immediately when all data packets of the long text message have arrived. Especially when the amount of data in Redis is very large, the scanning and judgment time will be correspondingly longer, further increasing the residence time of the text message. Summary of the invention

[0005] In view of this, the purpose of the present invention is to provide a method, device, equipment and storage medium for splicing short messages, which reduces the number of network requests and improves timeliness by using Lua scripts to determine whether all data sub-packets of the short messages to be spliced ​​have been received. The specific scheme is as follows:

[0006] In a first aspect, the present application discloses a method for splicing short messages, which is applied to a service cluster, and includes:

[0007] Receive a preset Lua script, and embed the Lua script into the service cluster;

[0008] Receive a script call request sent by a short message platform, obtain a data sub-packet of the short message to be spliced ​​in the short message platform, and determine whether the short message to be spliced ​​is a long short message based on data parameters of the data sub-packet;

[0009] If the short message to be spliced ​​is a long short message, the Lua script is executed to determine whether all the data sub-packets of the short message to be spliced ​​are received based on the data parameter, and obtain a corresponding execution result;

[0010] If the execution result is that all the data sub-packets of the SMS to be spliced ​​have been received, the execution result and all the data sub-packets of the SMS to be spliced ​​are returned to the SMS platform, so that the SMS platform can splice the data sub-packets based on the data parameters to obtain a complete data packet corresponding to the SMS to be spliced.

[0011] Optionally, the receiving a script call request sent by a short message platform, obtaining a data sub-packet of the short message to be spliced ​​in the short message platform, and judging whether the short message to be spliced ​​is a long short message based on a data parameter of the data sub-packet, comprises:

[0012] Obtaining data sub-packets of the SMS to be spliced ​​in the SMS platform, parsing the data sub-packets to obtain corresponding data parameters; the data parameters include SMS ID, total number of SMS messages, SMS content, SMS timeliness and data packet sequence number;

[0013] Based on the total number of the text messages, it is determined whether the text messages to be spliced ​​are long text messages.

[0014] Optionally, judging whether the to-be-joined text messages are long text messages based on the total number of text messages includes:

[0015] When the total number of the short messages is 1, it is determined that the short message to be spliced ​​is not a long short message, and the data sub-packet is directly returned to the short message platform;

[0016] When the total number of the short messages is greater than 1, it is determined that the short messages to be spliced ​​are long short messages.

[0017] Optionally, if the short message to be spliced ​​is a long short message, executing the Lua script to determine whether all the data sub-packets of the short message to be spliced ​​are received based on the data parameter, and obtaining a corresponding execution result, includes:

[0018] If the short message to be spliced ​​is a long short message, the Lua script is executed to store the data sub-package corresponding to the short message ID into the corresponding storage space;

[0019] Determining whether all the data sub-packets of the short message to be spliced ​​are received based on the number of the data sub-packets in the storage space and the total number of the short messages;

[0020] When the number of the data sub-packets in the storage space is not equal to the total number of text messages, the execution result is determined to be that all the data sub-packets of the text messages to be spliced ​​have not been received; when the number of the data sub-packets in the storage space is equal to the total number of text messages, the execution result is determined to be that all the data sub-packets of the text messages to be spliced ​​have been received.

[0021] Optionally, before storing the data sub-package corresponding to the SMS ID in the corresponding storage space, the method further includes:

[0022] Determine whether there is a storage space corresponding to the SMS ID in the service cluster based on the SMS ID;

[0023] If it does not exist, a storage space corresponding to the SMS ID is created in the service cluster.

[0024] Optionally, when the number of the data sub-packets in the storage space is not equal to the total number of the short messages, the execution result is that all the data sub-packets of the short messages to be spliced ​​are not received, further comprising:

[0025] Based on the SMS validity, determine whether the data sub-package corresponding to the SMS ID is expired. If not, continue to wait. If expired, delete all the data sub-packages corresponding to the SMS ID and end the current operation process.

[0026] Optionally, returning the execution result and all the data sub-packets of the short message to be spliced ​​to the short message platform so that the short message platform splices the data sub-packets based on the data parameters to obtain a complete data packet corresponding to the short message to be spliced, includes:

[0027] The execution result and all the data sub-packets of the short message to be spliced ​​are returned to the short message platform, so that the short message platform can splice the data sub-packets based on the data packet sequence number to obtain a complete data packet corresponding to the short message to be spliced.

[0028] In a second aspect, the present application discloses a short message splicing device, which is applied to a service cluster, comprising:

[0029] A script embedding module, used to receive a preset Lua script and embed the Lua script into the service cluster;

[0030] A data sub-packet acquisition module is used to receive a script call request sent by a short message platform and acquire a data sub-packet of a short message to be spliced ​​in the short message platform;

[0031] A long text message determination module, used for determining whether the text message to be spliced ​​is a long text message based on the data parameters of the data sub-packet;

[0032] A script execution module, for executing the Lua script if the short message to be spliced ​​is a long short message, so as to determine whether all the data sub-packets of the short message to be spliced ​​are received based on the data parameters, and obtain a corresponding execution result;

[0033] A result returning module is used to return the execution result and all the data sub-packets of the short message to be spliced ​​to the short message platform if the execution result is that all the data sub-packets of the short message to be spliced ​​have been received, so that the short message platform can splice the data sub-packets based on the data parameters to obtain a complete data packet corresponding to the short message to be spliced.

[0034] In a third aspect, the present application discloses an electronic device, comprising:

[0035] Memory, used to store computer programs;

[0036] The processor is used to execute the computer program to implement the steps of the SMS splicing method disclosed above.

[0037] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the SMS splicing method disclosed above is implemented.

[0038] It can be seen that the present application provides a method for splicing text messages, including: receiving a preset Lua script and embedding the Lua script into a service cluster; receiving a script call request sent by a text message platform, and obtaining data sub-packets of text messages to be spliced ​​in the text message platform, and judging whether the text messages to be spliced ​​are long text messages based on data parameters of the data sub-packets; if the text messages to be spliced ​​are long text messages, executing the Lua script to judge whether all the data sub-packets of the text messages to be spliced ​​have been received based on the data parameters, and obtaining corresponding execution results; if the execution result is that all the data sub-packets of the text messages to be spliced ​​have been received, returning the execution result and all the data sub-packets of the text messages to be spliced ​​to the text message platform, so that the text message platform splices the data sub-packets based on the data parameters to obtain a complete data packet corresponding to the text messages to be spliced. It can be seen that the present application embeds a Lua script in the service cluster, and then uses the Lua script to determine whether all the data sub-packets of the SMS to be spliced ​​are received. If so, the script execution result and all the data sub-packets of the SMS to be spliced ​​are returned to the SMS platform, thereby reducing the number of network requests and improving timeliness. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0040] Figure 1 A flow chart of a method for splicing short messages disclosed in this application;

[0041] Figure 2 A flowchart of a specific method for splicing short messages disclosed in this application;

[0042] Figure 3 A flowchart of a specific method for splicing short messages disclosed in this application;

[0043] Figure 4 A flowchart of a specific method for splicing short messages disclosed in this application;

[0044] Figure 5 A schematic diagram of the structure of the SMS splicing device provided for this application;

[0045] Figure 6 A structural diagram of an electronic device provided for this application. DETAILED DESCRIPTION

[0046] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0047] At present, the prior art has the following problems: it consumes resources. It requires a thread to continuously scan the IDs of all long text messages in Redis, take out and determine whether the data packets have arrived, and the frequency of network request operations to Redis is high and the number of times is large; the timeliness is reduced. This method belongs to passive scanning and splicing, and cannot ensure that the subsequent processing logic is triggered immediately when all data packets of long text messages have arrived. Especially when the amount of data in the Key in Redis is very large, the scanning and judgment time will be correspondingly longer, further increasing the residence time of the text message. To this end, the present application provides a text message splicing method that can reduce the number of network requests and improve timeliness.

[0048] The embodiment of the present invention discloses a method for splicing short messages. Figure 1 As shown, the method includes:

[0049] Step S11: Receive a preset Lua script, and embed the Lua script into the service cluster.

[0050] In this embodiment, a preset Lua script is received and embedded into the service cluster. It is understandable that the Lua script is a pre-written script for long text message splicing. It is a compact scripting language that can be compiled and run on almost all operating systems and platforms. In the process of using the Redis service cluster, sometimes it is necessary to operate the redis command atomically, and the Lua script can achieve this function. For example, deducting inventory operations, current limiting operations, etc. Compared with the prior art, it is not necessary to make multiple network requests, only one request is needed to complete, and the corresponding operations are completed with the Lua script on the Redis server, which can reduce the number of network requests and round-trip delay. In addition, the Redis service cluster is a high-performance distributed key-value (based on keyword value) database storage system, which supports storage of value types including string, list, set, zset (sorted set, ordered set), etc. These data types support push / pop (push / pop), add / remove (add / migrate) operations, and these operations are atomic.

[0051] Step S12: receiving a script call request sent by the SMS platform, obtaining a data sub-packet of the SMS to be spliced ​​in the SMS platform, and determining whether the SMS to be spliced ​​is a long SMS based on data parameters of the data sub-packet.

[0052] In this embodiment, after receiving the script call request sent by the SMS platform, the data sub-packet of the SMS to be spliced ​​in the SMS platform is obtained, and based on the data parameters of the data sub-packet, it is determined whether the SMS to be spliced ​​is a long SMS. It can be understood that when the SMS is a long SMS, the client splits the long SMS into several data sub-packets for submission, and receiving the script call request sent by the SMS platform indicates that the SMS platform has received a data sub-packet of the SMS to be spliced ​​sent by the client. Therefore, after receiving the script call request sent by the SMS platform, the data sub-packet of the SMS to be spliced ​​in the SMS platform is obtained, and based on the data parameters of the data sub-packet, it is determined whether the SMS to be spliced ​​is a long SMS. Each of the data sub-packets contains the corresponding data parameters.

[0053] Step S13: If the short message to be spliced ​​is a long short message, the Lua script is executed to determine whether all the data sub-packets of the short message to be spliced ​​are received based on the data parameters, and obtain a corresponding execution result.

[0054] In this embodiment, after judging whether the SMS to be spliced ​​is a long SMS based on the data parameters of the data sub-packet, if the SMS to be spliced ​​is a long SMS, it indicates that the long SMS corresponding to the SMS to be spliced ​​is split and needs to be spliced ​​accordingly, so the Lua script is executed. It can be understood that executing the Lua script reduces the number of network requests to Redis. Since the Lua script is atomic, Redis will execute the entire script as a whole, and no other commands will be inserted in the middle of the script execution. At the same time, the Lua script will be permanently stored in Redis, and other clients can reuse the Lua script without using code to complete the same logic. It should be pointed out that judging whether all the data sub-packets of the SMS to be spliced ​​are received based on the data parameters is to perform integrity judgment on the long SMS data packet. The integrity judgment process does not need to request Redis separately or add redundant threads to scan and judge.

[0055] Step S14: If the execution result is that all the data sub-packets of the SMS to be spliced ​​have been received, the execution result and all the data sub-packets of the SMS to be spliced ​​are returned to the SMS platform, so that the SMS platform splices the data sub-packets based on the data parameters to obtain a complete data packet corresponding to the SMS to be spliced.

[0056] In this embodiment, when the execution result is that all the data sub-packets of the short message to be spliced ​​have been received, the execution result and all the data sub-packets of the short message to be spliced ​​are returned to the short message platform, so that the short message platform splices the data sub-packets based on the data parameters to obtain a complete data packet corresponding to the short message to be spliced. It can be understood that compared with the prior art, the passive scanning and judgment mode is improved to an active notification mode. When the last sub-packet of the short message to be spliced ​​is received, the execution result and all the data sub-packets of the short message to be spliced ​​are returned to the short message platform, that is, the subsequent processing logic is immediately triggered when all the data packets of the long short message arrive, without waiting for scanning and judgment, thereby improving timeliness.

[0057] It can be seen that the present application provides a method for splicing text messages, including: receiving a preset Lua script and embedding the Lua script into a service cluster; receiving a script call request sent by a text message platform, and obtaining data sub-packets of text messages to be spliced ​​in the text message platform, and judging whether the text messages to be spliced ​​are long text messages based on data parameters of the data sub-packets; if the text messages to be spliced ​​are long text messages, executing the Lua script to judge whether all the data sub-packets of the text messages to be spliced ​​have been received based on the data parameters, and obtaining corresponding execution results; if the execution result is that all the data sub-packets of the text messages to be spliced ​​have been received, returning the execution result and all the data sub-packets of the text messages to be spliced ​​to the text message platform, so that the text message platform splices the data sub-packets based on the data parameters to obtain a complete data packet corresponding to the text messages to be spliced. It can be seen that the present application embeds a Lua script in the service cluster, and then uses the Lua script to determine whether all the data sub-packets of the SMS to be spliced ​​are received. If so, the script execution result and all the data sub-packets of the SMS to be spliced ​​are returned to the SMS platform, thereby reducing the number of network requests and improving timeliness.

[0058] See also Figure 2 As shown, the embodiment of the present invention discloses a method for splicing short messages. Compared with the previous embodiment, this embodiment further illustrates and optimizes the technical solution.

[0059] Step S21: Receive a preset Lua script, and embed the Lua script into the service cluster.

[0060] Step S22: Receive a script call request sent by the SMS platform, obtain the data sub-packet of the SMS to be spliced ​​in the SMS platform, and parse the data sub-packet to obtain corresponding data parameters; the data parameters include SMS ID, total number of SMS messages, SMS content, SMS timeliness and data packet sequence number.

[0061] In this embodiment, after receiving the script call request sent by the SMS platform and obtaining the data sub-packet of the SMS to be spliced ​​in the SMS platform, the data sub-packet is parsed to obtain the corresponding data parameters. It should be noted that the data parameters include the SMS ID, the total number of SMS messages, the SMS content, the SMS timeliness and the data packet sequence number.

[0062] It can be understood that the SMS ID is the unique ID corresponding to the SMS to be spliced ​​corresponding to the data sub-packet. After the SMS ID is obtained, the SMS ID can be used to determine which SMS to be spliced ​​the current data sub-packet is. The total number of SMS is the number of data sub-packets of the SMS to be spliced ​​corresponding to the SMS ID in the current data sub-packet. The total number of SMS can be used to determine whether all the data sub-packets of the SMS to be spliced ​​have been received. The SMS content is part of the SMS to be spliced. The SMS validity period is the valid time of the current data sub-packet. When it is in the time zone corresponding to the SMS validity period, this data sub-packet is still valid, and the SMS validity period in all data sub-packets of the SMS to be spliced ​​is the same. The data packet sequence number is to mark the data sub-packets according to the order of the content in the long SMS when splitting the long SMS corresponding to the SMS to be spliced, so that the contents of the data sub-packets can be spliced ​​in order during splicing, avoiding splicing errors caused by unclear order during the splicing process.

[0063] It should be noted that when data sub-packets with different SMS IDs in multiple SMS messages to be spliced ​​are received at the same time, the data sub-packets corresponding to each different SMS ID can call the Lua script at the same time, so as to process multiple call requests at the same time.

[0064] Step S23: determining whether the short messages to be spliced ​​are long short messages based on the total number of short messages.

[0065] In this embodiment, after obtaining the data sub-packets of the SMS to be spliced ​​in the SMS platform, Figure 3 As shown, it is determined whether the short message to be spliced ​​is a long short message. It can be understood that the data sub-packet contains the total number of short messages, so whether the short message to be spliced ​​is a long short message is determined based on the total number of short messages. When the total number of short messages is 1, it is determined that the short message to be spliced ​​is not a long short message, and the data sub-packet is directly returned to the short message platform; when the total number of short messages is greater than 1, it is determined that the short message to be spliced ​​is a long short message. It should be pointed out that when the total number of short messages is 1, it indicates that the short message to be spliced ​​has only one data sub-packet, that is, the currently received data sub-packet, which also indicates that the short message to be spliced ​​has not been split, so it can be determined that the current data sub-packet does not correspond to a long short message.

[0066] It should be noted that a text message with more than 70 characters is called a long message. According to the SMS communication protocol, when a text message exceeds 70 characters, the client needs to unpack the long message and send it to the server asynchronously. Therefore, when a data sub-packet with a total number of messages greater than 1 in the data parameter is received, it can be determined that the current data sub-packet corresponds to a long message. In some scenarios, the server needs to splice the long messages in sequence.

[0067] Step S24: If the short message to be spliced ​​is a long short message, the Lua script is executed to determine whether all the data sub-packets of the short message to be spliced ​​are received based on the data parameters, and obtain a corresponding execution result.

[0068] Step S25: If the execution result is that all the data sub-packets of the short message to be spliced ​​have been received, the execution result and all the data sub-packets of the short message to be spliced ​​are returned to the short message platform, so that the short message platform splices the data sub-packets based on the data packet sequence number to obtain the complete data packet corresponding to the short message to be spliced.

[0069] In this embodiment, if the execution result is that all the data sub-packets of the short message to be spliced ​​have been received, the execution result and all the data sub-packets of the short message to be spliced ​​are returned to the short message platform, so that the short message platform splices the data sub-packets based on the data packet sequence number to obtain a complete data packet corresponding to the short message to be spliced. It can be understood that when splicing, the contents of the data sub-packets are spliced ​​according to the data packet sequence number in each data sub-packet, so as to avoid splicing errors caused by unclear order during the splicing process.

[0070] For the specific contents of the above steps S21 and S24, reference may be made to the corresponding contents disclosed in the above embodiments, which will not be repeated here.

[0071] It can be seen that the embodiment of the present application obtains the corresponding data parameters by parsing the data sub-packets, and then determines whether the short message to be spliced ​​is a long short message based on the information in the data parameters. When the short message to be spliced ​​is a long short message, the Lua script is executed, and then it is determined based on the data parameters whether all the data sub-packets of the short message to be spliced ​​are received, and the execution result and all the data sub-packets of the short message to be spliced ​​are returned to the short message platform, thereby reducing the number of network requests and improving timeliness.

[0072] See also Figure 4 As shown, the embodiment of the present invention discloses a method for splicing short messages. Compared with the previous embodiment, this embodiment further illustrates and optimizes the technical solution.

[0073] Step S31: Receive a preset Lua script, and embed the Lua script into the service cluster.

[0074] Step S32: receiving a script call request sent by the SMS platform, and obtaining a data sub-packet of the SMS to be spliced ​​in the SMS platform, and determining whether the SMS to be spliced ​​is a long SMS based on data parameters of the data sub-packet.

[0075] Step S33: If the short message to be spliced ​​is a long short message, the Lua script is executed to store the data sub-package corresponding to the short message ID into a corresponding storage space.

[0076] In this embodiment, before the data sub-packet corresponding to the SMS ID is stored in the corresponding storage space, it is determined whether there is a storage space corresponding to the SMS ID in the service cluster based on the SMS ID. If not, a storage space corresponding to the SMS ID is created in the service cluster. It can be understood that if the current data sub-packet is the first data sub-packet among all the data sub-packets corresponding to the SMS ID it contains, it means that the storage space corresponding to the SMS ID of the current data sub-packet cannot be found in Redis, so it is necessary to create a storage space corresponding to the SMS ID. If the current data sub-packet is not the first data sub-packet among all the data sub-packets corresponding to the SMS ID it contains, the corresponding storage space is found in Redis based on the SMS ID, and the data sub-packet is directly stored in the corresponding storage space.

[0077] Step S34: judging whether all the data sub-packets of the short message to be spliced ​​are received based on the number of the data sub-packets in the storage space and the total number of the short messages.

[0078] In this embodiment, after the data sub-packets corresponding to the SMS ID are stored in the corresponding storage space, it is determined whether all the data sub-packets of the SMS to be spliced ​​are received based on the number of the data sub-packets in the storage space and the total number of SMS messages. It can be understood that the storage space corresponding to the SMS ID stores all the data sub-packets corresponding to the received SMS ID.

[0079] Step S35: When the number of the data sub-packets in the storage space is not equal to the total number of text messages, it is determined that the execution result is that all the data sub-packets of the text messages to be spliced ​​have not been received; when the number of the data sub-packets in the storage space is equal to the total number of text messages, it is determined that the execution result is that all the data sub-packets of the text messages to be spliced ​​have been received.

[0080] In this embodiment, when the number of the data sub-packets in the storage space is not equal to the total number of the short messages, it is determined that the execution result is that all the data sub-packets of the short messages to be spliced ​​have not been received; when the number of the data sub-packets in the storage space is equal to the total number of the short messages, it is determined that the execution result is that all the data sub-packets of the short messages to be spliced ​​have been received. It can be understood that when the execution result is that all the data sub-packets of the short messages to be spliced ​​have not been received, Figure 3 As shown, based on the SMS validity, determine whether the data sub-package corresponding to the SMS ID is expired. If it is not expired, continue to wait; if it is expired, delete all the data sub-packages corresponding to the SMS ID and end the current operation process.

[0081] Step S36: If the execution result is that all the data sub-packets of the SMS to be spliced ​​have been received, the execution result and all the data sub-packets of the SMS to be spliced ​​are returned to the SMS platform, so that the SMS platform splices the data sub-packets based on the data parameters to obtain a complete data packet corresponding to the SMS to be spliced.

[0082] For the specific contents of the above steps S31, S32, and S36, reference may be made to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.

[0083] It can be seen that the embodiment of the present application determines whether the short message to be spliced ​​is a long short message based on the data parameters of the data sub-packet. If the short message to be spliced ​​is a long short message, the Lua script is executed to store the data sub-packet corresponding to the short message ID into the corresponding storage space, and then based on the number of the data sub-packets in the storage space and the total number of short messages, it is determined whether all the data sub-packets of the short message to be spliced ​​have been received. When the number of the data sub-packets in the storage space is equal to the total number of short messages, it is determined that the execution result is that all the data sub-packets of the short message to be spliced ​​have been received, and the execution result and all the data sub-packets of the short message to be spliced ​​are returned to the short message platform, so that the short message platform splices the data sub-packets based on the data parameters to obtain the complete data packet corresponding to the short message to be spliced, thereby reducing the number of network requests and improving timeliness.

[0084] See also Figure 5 As shown, the embodiment of the present application also discloses a text message splicing device, including:

[0085] The script embedding module 11 is used to receive a preset Lua script and embed the Lua script into the service cluster;

[0086] The data sub-packet acquisition module 12 is used to receive the script call request sent by the SMS platform and obtain the data sub-packet of the SMS to be spliced ​​in the SMS platform;

[0087] A long text message determination module 13, configured to determine whether the text message to be spliced ​​is a long text message based on data parameters of the data sub-packet;

[0088] A script execution module 14, configured to execute the Lua script if the short message to be spliced ​​is a long short message, so as to determine whether all the data sub-packets of the short message to be spliced ​​are received based on the data parameters, and obtain a corresponding execution result;

[0089] The result returning module 15 is used to return the execution result and all the data sub-packets of the SMS to be spliced ​​to the SMS platform if the execution result is that all the data sub-packets of the SMS to be spliced ​​have been received, so that the SMS platform can splice the data sub-packets based on the data parameters to obtain a complete data packet corresponding to the SMS to be spliced.

[0090] It can be seen that the present application includes: receiving a preset Lua script and embedding the Lua script into a service cluster; receiving a script call request sent by a short message platform, and obtaining a data sub-packet of a short message to be spliced ​​in the short message platform, and judging whether the short message to be spliced ​​is a long short message based on the data parameter of the data sub-packet; if the short message to be spliced ​​is a long short message, executing the Lua script so as to judge whether all the data sub-packets of the short message to be spliced ​​have been received based on the data parameter, and obtaining a corresponding execution result; if the execution result is that all the data sub-packets of the short message to be spliced ​​have been received, returning the execution result and all the data sub-packets of the short message to be spliced ​​to the short message platform, so that the short message platform splices the data sub-packets based on the data parameter to obtain a complete data packet corresponding to the short message to be spliced. It can be seen that the present application reduces the number of network requests and improves timeliness by embedding a Lua script in a service cluster, and then using the Lua script to judge whether all the data sub-packets of the short message to be spliced ​​have been received, and if so, returning the script execution result and all the data sub-packets of the short message to be spliced ​​to the short message platform.

[0091] In some specific embodiments, the long message determination module 13 specifically includes:

[0092] A data parameter acquisition unit, used to acquire data sub-packets of the SMS to be spliced ​​in the SMS platform, and parse the data sub-packets to obtain corresponding data parameters; the data parameters include SMS ID, total number of SMS messages, SMS content, SMS timeliness and data packet sequence number;

[0093] The long text message determination unit is used to determine whether the text messages to be spliced ​​are long text messages based on the total number of text messages.

[0094] In some specific embodiments, the script execution module 14 specifically includes:

[0095] A script execution unit, configured to execute the Lua script if the short message to be spliced ​​is a long short message;

[0096] A storage space determination unit, configured to determine whether there is a storage space corresponding to the SMS ID in the service cluster based on the SMS ID;

[0097] a storage space creation unit, configured to create a storage space corresponding to the SMS ID in the service cluster if the storage space does not exist;

[0098] A data sub-packet storage unit, used for storing the data sub-packet corresponding to the SMS ID into a corresponding storage space;

[0099] A data sub-packet quantity judgment unit is used to determine that the execution result is that all the data sub-packets of the short messages to be spliced ​​have not been received when the number of the data sub-packets in the storage space is not equal to the total number of short messages, and to determine that the execution result is that all the data sub-packets of the short messages to be spliced ​​have been received when the number of the data sub-packets in the storage space is equal to the total number of short messages.

[0100] Furthermore, an embodiment of the present application also provides an electronic device. Figure 6 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram cannot be regarded as any limitation on the scope of use of the present application.

[0101] Figure 6 The present invention provides a schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the SMS splicing method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.

[0102] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.

[0103] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.

[0104] The operating system 221 is used to manage and control the hardware devices and computer program 222 on the electronic device 20, which can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the SMS splicing method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks.

[0105] Furthermore, an embodiment of the present application also discloses a storage medium, in which a computer program is stored. When the computer program is loaded and executed by a processor, the steps of the SMS splicing method disclosed in any of the aforementioned embodiments are implemented.

[0106] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0107] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0108] The above is a detailed introduction to a method, device, equipment and storage medium for splicing short messages provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A method for splicing short messages. It is characterized in that Applied to the service cluster, the service cluster is a Redis service cluster, which is a distributed key-value database storage system, and supports the storage of value types including string, list, set, and zset, and the value types all support push / pop and add / remove operations, including: Receive a preset Lua script, and embed the Lua script into the service cluster; Receive a script call request sent by a short message platform, obtain a data sub-packet of the short message to be spliced ​​in the short message platform, and determine whether the short message to be spliced ​​is a long short message based on data parameters of the data sub-packet; If the short message to be spliced ​​is a long short message, the Lua script is executed to determine whether all the data sub-packets of the short message to be spliced ​​are received based on the data parameter, and obtain a corresponding execution result; If the execution result is that all the data sub-packets of the short message to be spliced ​​have been received, the execution result and all the data sub-packets of the short message to be spliced ​​are returned to the short message platform, so that the short message platform splices the data sub-packets based on the data parameters to obtain a complete data packet corresponding to the short message to be spliced; The receiving of the script call request sent by the SMS platform, obtaining the data sub-packet of the SMS to be spliced ​​in the SMS platform, and judging whether the SMS to be spliced ​​is a long SMS based on the data parameters of the data sub-packet include: Obtaining data sub-packets of the SMS to be spliced ​​in the SMS platform, parsing the data sub-packets to obtain corresponding data parameters; the data parameters include SMS ID, total number of SMS messages, SMS content, SMS timeliness and data packet sequence number; Determining whether the short message to be spliced ​​is a long short message based on the total number of short messages; If the short message to be spliced ​​is a long short message, the Lua script is executed to determine whether all the data sub-packets of the short message to be spliced ​​are received based on the data parameter, and obtain a corresponding execution result, including: If the short message to be spliced ​​is a long short message, the Lua script is executed to store the data sub-package corresponding to the short message ID into the corresponding storage space; Determining whether all the data sub-packets of the short message to be spliced ​​are received based on the number of the data sub-packets in the storage space and the total number of the short messages; When the number of the data sub-packets in the storage space is not equal to the total number of the short messages, it is determined that the execution result is that all the data sub-packets of the short messages to be spliced ​​have not been received; when the number of the data sub-packets in the storage space is equal to the total number of the short messages, it is determined that the execution result is that all the data sub-packets of the short messages to be spliced ​​have been received; Before storing the data sub-package corresponding to the SMS ID into the corresponding storage space, the method further includes: Determine whether there is a storage space corresponding to the SMS ID in the service cluster based on the SMS ID; If it does not exist, create a storage space corresponding to the SMS ID in the service cluster; When the number of the data sub-packets in the storage space is not equal to the total number of the short messages, the execution result is that all the data sub-packets of the short messages to be spliced ​​are not received, and further includes: Based on the SMS validity, determine whether the data sub-package corresponding to the SMS ID is expired. If not, continue to wait. If expired, delete all the data sub-packages corresponding to the SMS ID and end the current operation process.

2. The method for splicing short messages according to claim 1, It is characterized in that The determining whether the to-be-joined text messages are long text messages based on the total number of text messages includes: When the total number of the short messages is 1, it is determined that the short message to be spliced ​​is not a long short message, and the data sub-packet is directly returned to the short message platform; When the total number of the short messages is greater than 1, it is determined that the short messages to be spliced ​​are long short messages.

3. The method for splicing short messages according to claim 1 or 2, It is characterized in that The returning the execution result and all the data sub-packets of the short message to be spliced ​​to the short message platform so that the short message platform splices the data sub-packets based on the data parameters to obtain a complete data packet corresponding to the short message to be spliced, includes: The execution result and all the data sub-packets of the short message to be spliced ​​are returned to the short message platform, so that the short message platform can splice the data sub-packets based on the data packet sequence number to obtain a complete data packet corresponding to the short message to be spliced.

4. A short message splicing device, It is characterized in that Applied to the service cluster, the service cluster is a Redis service cluster, which is a distributed key-value database storage system, and supports the storage of value types including string, list, set, and zset, and the value types all support push / pop and add / remove operations, including: A script embedding module, used to receive a preset Lua script and embed the Lua script into the service cluster; A data sub-packet acquisition module is used to receive a script call request sent by a short message platform and acquire a data sub-packet of a short message to be spliced ​​in the short message platform; A long text message determination module, used for determining whether the text message to be spliced ​​is a long text message based on the data parameters of the data sub-packet; A script execution module, for executing the Lua script if the short message to be spliced ​​is a long short message, so as to determine whether all the data sub-packets of the short message to be spliced ​​are received based on the data parameters, and obtain a corresponding execution result; A result returning module, for returning the execution result and all the data sub-packets of the short message to be spliced ​​to the short message platform if the execution result is that all the data sub-packets of the short message to be spliced ​​have been received, so that the short message platform can splice the data sub-packets based on the data parameters to obtain a complete data packet corresponding to the short message to be spliced; Wherein, the device is also used for: obtaining data sub-packets of the SMS to be spliced ​​in the SMS platform, parsing the data sub-packets to obtain corresponding data parameters; the data parameters include SMS ID, the total number of SMS messages, SMS content, SMS timeliness and data packet sequence number; judging whether the SMS to be spliced ​​is a long SMS based on the total number of SMS messages; if the SMS to be spliced ​​is a long SMS, executing the Lua script to store the data sub-packets corresponding to the SMS ID into the corresponding storage space; judging whether all the data sub-packets of the SMS to be spliced ​​are received based on the number of the data sub-packets in the storage space and the total number of SMS messages; when the number of the data sub-packets in the storage space is equal to the total number of SMS messages, the Lua script is executed to store the data sub-packets corresponding to the SMS ID into the corresponding storage space; judging whether all the data sub-packets of the SMS to be spliced ​​are received based on the number of the data sub-packets in the storage space and the total number of SMS messages; When the number of the data sub-packets in the storage space is not equal to the total number of the text messages, it is determined that the execution result is that all the data sub-packets of the text messages to be spliced ​​have not been received; when the number of the data sub-packets in the storage space is equal to the total number of the text messages, it is determined that the execution result is that all the data sub-packets of the text messages to be spliced ​​have been received; based on the text message ID, it is determined whether there is a storage space corresponding to the text message ID in the service cluster; if not, a storage space corresponding to the text message ID is created in the service cluster; based on the text message timeliness, it is determined whether the data sub-packet corresponding to the text message ID is expired; if not, continue to wait; if expired, delete all the data sub-packets corresponding to the text message ID and end the current operation process.

5. An electronic device, It is characterized in that include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the steps of the SMS splicing method as described in any one of claims 1 to 3.

6. A computer-readable storage medium, It is characterized in that Used to store computer programs; wherein, when the computer program is executed by a processor, the text message splicing method as described in any one of claims 1 to 3 is implemented.

Citation Information

Patent Citations

  • Short message processing method and short message processing device

    CN101695154A

  • Method for processing short messages, related device and system

    CN102860049A

  • Marketing short message management and control system and method

    CN112040431A

  • Cloud communication short message service platform

    CN112351392A

  • Cluster service flow limiting method and device, computing equipment and storage medium

    CN113467896A