CN113365231A - Method and device for sending short message - Google Patents
Method and device for sending short message Download PDFInfo
- Publication number
- CN113365231A CN113365231A CN202010148283.XA CN202010148283A CN113365231A CN 113365231 A CN113365231 A CN 113365231A CN 202010148283 A CN202010148283 A CN 202010148283A CN 113365231 A CN113365231 A CN 113365231A
- Authority
- CN
- China
- Prior art keywords
- short message
- current
- sending
- serial number
- current short
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W4/00—Services specially adapted for wireless communication networks; Facilities therefor
- H04W4/12—Messaging; Mailboxes; Announcements
- H04W4/14—Short messaging services, e.g. short message services [SMS] or unstructured supplementary service data [USSD]
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Mobile Radio Communication Systems (AREA)
Abstract
The invention discloses a method and a device for sending a short message, and relates to the technical field of computers. One embodiment of the method comprises: writing the state identifier of the current short message into a bit array; finding out the state identification of the short message with the previous sequence number of the current short message from the digit group so as to determine the sending state of the short message with the previous sequence number; and if the sending state of the short message with the previous serial number is successful, sending the current short message. The implementation mode can solve the technical problem that the delivery sequence of the short messages cannot be guaranteed.
Description
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for sending a short message.
Background
Short messages serve as one of the most original modes for triggering users of mobile phones, and have a lot of application scenes in the aspects of notification, marketing and the like. The sequential short message is one of the application modes, but the short message system has the characteristics of high throughput and high availability, so that a distributed architecture is basically adopted. How this architecture can send the short messages in sequence is to use the original message Middleware (MQ) to sort, use the memory to sort, and use the short messages to send in sequence the simplest.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art:
the above schemes can realize the sequencing of certain programs and can meet the requirements of partial services, but if the strict sequence is required, the above schemes have some defects. In addition, the above solutions all have a common drawback: the sending sequence can only be controlled at the moment of sending, and as the short message service provider needs to carry a large number of short message requests, the structure of the short message service provider can also be a distributed structure, so that even if the sending sequence of the short messages is ensured, the sending sequence can not be ensured.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for sending a short message, so as to solve the technical problem that the sending order of the short message cannot be guaranteed.
In order to achieve the above object, according to an aspect of the embodiments of the present invention, there is provided a method for sending a short message, including:
writing the state identifier of the current short message into a bit array;
finding out the state identification of the short message with the previous sequence number of the current short message from the digit group so as to determine the sending state of the short message with the previous sequence number;
and if the sending state of the short message with the previous serial number is successful, sending the current short message.
Optionally, writing the status identifier of the current short message into a bit array, including:
receiving short message information of a current short message transmitted by a service system, wherein the short message information comprises a service identifier, short message content, a short message serial number and a receiver identifier;
determining a bit array corresponding to the service identifier according to the service identifier of the current short message;
and determining the bit position occupied by the current short message in the bit array according to the serial number of the current short message, and writing the state identification of the current short message into the bit position.
Optionally, the state identifier of each short message occupies two bits in the bit array, and each short message occupies the bits in the bit array in sequence according to the sequence from small to large of the short message sequence number; where 00, 01, 10 and 11 represent four different transmission states, respectively.
Optionally, the step of finding out the status identifier of the short message with the previous sequence number of the current short message from the digit group, so as to determine the sending status of the short message with the previous sequence number includes:
positioning two bit positions occupied by the short message with the previous sequence number of the current short message in the bit array according to the previous sequence number of the current short message;
and determining the sending state of the short message with the previous serial number according to the state identifications of the two bit positions occupied by the short message with the previous serial number in the bit array.
Optionally, after sending the current short message, the method further includes:
and receiving the short message receipt code of the current short message returned by the short message service provider, and storing the short message receipt code and the corresponding relation between the service identifier of the current short message and the short message sequence number.
Optionally, storing the short message receipt code and the corresponding relationship between the service identifier of the current short message and the short message sequence number includes:
and storing in a key-value mode, taking the short message receipt code as a key, and taking the service identifier and the short message sequence number of the current short message as a value.
Optionally, after storing the short message receipt code and the corresponding relationship between the service identifier of the current short message and the sequence number of the current short message, the method further includes:
receiving a short message delivery state and a short message receipt code returned by a short message service provider;
matching out a corresponding service identifier and a short message serial number according to the returned short message receipt code;
and updating the state identifier of the bit position occupied by the short message sequence number in the bit array corresponding to the service identifier into successful delivery according to the matched service identifier and the matched short message sequence number.
Optionally, the method further comprises:
if the sending state of the short message with the previous serial number is in sending, the current short message is put into a waiting queue;
judging whether the sending state of the short message with the previous serial number is successful at preset time intervals; and if so, taking out the current short message from the waiting queue and sending the current short message.
Optionally, after the current short message is put into a waiting queue, the method further includes:
calculating the overtime waiting time of the current short message according to the time of the current short message transmitted from a service system and a preset overtime threshold;
judging whether the current short message reaches the overtime waiting time or not;
and if so, taking out the current short message from the waiting queue and sending the current short message.
Optionally, the method further comprises:
if the sending state of the short message with the previous serial number is delivery failure, judging whether the current short message strongly depends on the delivery success of the short message with the previous serial number;
if yes, the sending of the current short message is cancelled;
if not, the current short message is put into a waiting queue.
In addition, according to another aspect of the embodiments of the present invention, there is provided an apparatus for sending a short message, including:
the writing module is used for writing the state identifier of the current short message into the bit array;
the state module is used for searching out the state identifier of the short message with the previous sequence number of the current short message from the digit group so as to determine the sending state of the short message with the previous sequence number;
and the short message module is used for sending the current short message if the sending state of the short message with the previous sequence number is successful.
Optionally, the writing module is further configured to:
receiving short message information of a current short message transmitted by a service system, wherein the short message information comprises a service identifier, short message content, a short message serial number and a receiver identifier;
determining a bit array corresponding to the service identifier according to the service identifier of the current short message;
and determining the bit position occupied by the current short message in the bit array according to the serial number of the current short message, and writing the state identification of the current short message into the bit position.
Optionally, the state identifier of each short message occupies two bits in the bit array, and each short message occupies the bits in the bit array in sequence according to the sequence from small to large of the short message sequence number; where 00, 01, 10 and 11 represent four different transmission states, respectively.
Optionally, the status module is further configured to:
positioning two bit positions occupied by the short message with the previous sequence number of the current short message in the bit array according to the previous sequence number of the current short message;
and determining the sending state of the short message with the previous serial number according to the state identifications of the two bit positions occupied by the short message with the previous serial number in the bit array.
Optionally, the short message module is further configured to:
and after the current short message is sent, receiving a short message receipt code of the current short message returned by a short message service provider, and storing the short message receipt code and the corresponding relation between the service identifier and the short message sequence number of the current short message.
Optionally, the short message module is further configured to:
and storing in a key-value mode, taking the short message receipt code as a key, and taking the service identifier and the short message sequence number of the current short message as a value.
Optionally, the short message module is further configured to:
after storing the short message receipt code and the corresponding relation between the service identification of the current short message and the serial number of the current short message, receiving the short message delivery state and the short message receipt code returned by the short message service provider;
matching out a corresponding service identifier and a short message serial number according to the returned short message receipt code;
and updating the state identifier of the bit position occupied by the short message sequence number in the bit array corresponding to the service identifier into successful delivery according to the matched service identifier and the matched short message sequence number.
Optionally, the short message module is further configured to:
if the sending state of the short message with the previous serial number is in sending, the current short message is put into a waiting queue;
judging whether the sending state of the short message with the previous serial number is successful at preset time intervals; and if so, taking out the current short message from the waiting queue and sending the current short message.
Optionally, the short message module is further configured to:
after the current short message is put into a waiting queue, calculating the overtime waiting time of the current short message according to the time of the current short message transmitted from a service system and a preset overtime threshold;
judging whether the current short message reaches the overtime waiting time or not;
and if so, taking out the current short message from the waiting queue and sending the current short message.
Optionally, the short message module is further configured to:
if the sending state of the short message with the previous serial number is delivery failure, judging whether the current short message strongly depends on the delivery success of the short message with the previous serial number;
if yes, the sending of the current short message is cancelled;
if not, the current short message is put into a waiting queue.
According to another aspect of the embodiments of the present invention, there is also provided an electronic device, including:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any of the embodiments described above.
According to another aspect of the embodiments of the present invention, there is also provided a computer readable medium, on which a computer program is stored, which when executed by a processor implements the method of any of the above embodiments.
One embodiment of the above invention has the following advantages or benefits: the method adopts the technical means that the state identification of the current short message is written into the digit group, the sending state of the short message with the previous serial number is searched from the digit group, and if the sending state of the short message with the previous serial number is successful, the current short message is sent, so the technical problem that the sending sequence of the short message cannot be ensured in the prior art is solved. The embodiment of the invention realizes the strong consistency of the short message sending sequence and the short message sending sequence by using the bit array to carry out the short message state identification. Even for the distributed short messages, the distributed short messages can be globally ordered, and the distributed short messages can be sequentially sent and can be sequentially sent.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
fig. 1 is a schematic diagram of a main flow of a method for sending a short message according to an embodiment of the present invention;
FIG. 2 is a diagram of a system architecture for sending short messages according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a bit array according to an embodiment of the invention;
fig. 4 is a schematic diagram of a main flow of a method for sending a short message according to a reference embodiment of the present invention;
fig. 5 is a schematic diagram of main modules of an apparatus for sending a short message according to an embodiment of the present invention;
FIG. 6 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 7 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
At present, several schemes are generally adopted to realize the sequential transmission of distributed short messages.
1) Ordering with native MQ: in fact, the data are sorted according to the storage level, because the MQ supports the storage of the data sequence according to a certain field, the data acquired during the sending are actually ordered, and the data sent by the short message service provider are ordered.
2) Memory sorting is adopted: the sorting on the single machine can realize local sorting, but is not beneficial to distributed short messages.
3) The short messages are sent according to the sequence: this is only sequential control of the service layer, and it is difficult to ensure that the first-sent short message can be sent first in the distributed system.
All three solutions have a common technical problem: the sending sequence can only be controlled at the moment of sending, and the sending sequence cannot be guaranteed. In order to solve the technical problem, embodiments of the present invention provide a distributed short message sending scheme, which can ensure both sending sequence and arrival sequence.
Fig. 1 is a schematic diagram of a main flow of a method for sending a short message according to an embodiment of the present invention. As an embodiment of the present invention, as shown in fig. 1, the method for sending a short message may include:
step 101, writing the state identifier of the current short message into a bit array.
In the step, a current short message is received, and the state identifier of the current short message is written into a bit array. And because the current short message is not sent, the state identifier of the current short message is to be sent.
Optionally, step 101 may comprise: receiving short message information of a current short message transmitted by a service system, wherein the short message information comprises a service identifier, short message content, a short message serial number and a receiver identifier; determining a bit array corresponding to the service identifier according to the service identifier of the current short message; and determining the bit position occupied by the current short message in the bit array according to the serial number of the current short message, and writing the state identification of the current short message into the bit position. As shown in fig. 2, the system for sending a short message includes a service system, a short message system and a short message service provider, wherein the short message system receives short message information of a current short message sent by the service system, and then writes a status identifier of the current short message into a bit array (Bitmap).
Bitmap: bitmaps, also called raster maps, are images represented using Pixel arrays (Pixel-array/Dot-matrix lattices), and in Redis, bitmaps are implemented using string objects to represent bit arrays.
In the embodiment of the present invention, the business system is required to provide the following information:
1) receiver identification (such as mobile phone number), short message content;
2) unique service identification: the short messages with the sequential sending requirement use the same service identification and are required to be unique;
3) short message sequence number: in the group of short messages, the serial number of the short message is currently.
It should be noted that, in the group of short messages, the content of each short message may be the same or different, and this is not limited in the embodiment of the present invention.
Optionally, in some service scenarios, the service system is further required to provide the following information:
4) strongly depends on the success of the delivery of the previous short message: whether the previous short message is sent continuously or not is judged, if yes, the following short messages are sent in a giving up mode if the previous short message is sent in a failing mode; if not, the former short message is sent continuously no matter the former short message is successfully sent or not.
5) Waiting for delivery timeout time: and waiting for the time-out time of the previous successful delivery, and continuing to send the current short message after the time-out time is exceeded.
Optionally, the status identifier of each short message occupies two bits in the bit array, and each short message occupies the bits in the bit array in sequence from small to large according to the sequence of the short message sequence numbers. Where 00, 01, 10 and 11 represent four different transmission states, respectively.
In the embodiment of the invention, whether the service identifier exists is judged firstly; if yes, indicating that the bit array corresponding to the service identifier exists, searching the corresponding bit array by using the service identifier; if not, indicating that the bit array corresponding to the service identifier does not exist, establishing the bit array corresponding to the service identifier. And then determining the bit positions occupied by the current short messages in the bit array according to the serial numbers of the current short messages, wherein the state identifier of each short message needs to occupy two bit positions in the bit array. As shown in fig. 3, for example, if the sequence number of the current short message is 1, the 1 st and 2 nd bit positions are occupied as the state identification bits, and if the sequence number of the current short message is 3, the 5 th and 6 th bit positions are occupied as the state identification bits, and so on, and the description is omitted. Alternatively, the sequence number (xh) may correspond to: two bits, 2 x xh-1 and 2 x xh, set the state flag.
As another embodiment of the present invention, the two-bit flag means: 00 denotes to be sent, 01 denotes to wait for return delivery status in transmission, 10 denotes to be sent but delivery failed, and 11 denotes to be sent and delivery succeeded. It should be noted that 00, 01, 10, and 11 may also indicate other transmission states, and the embodiment of the present invention is not limited thereto.
Optionally, after the status identifier of the current short message is written into the bit array, the incoming time of the current short message is generated, and the incoming time is directly put into the short message entry object, that is, the incoming time is set as an attribute of the short message.
Step 102, finding out the status identifier of the short message with the previous serial number of the current short message from the digit group, thereby determining the sending status of the short message with the previous serial number.
In this step, the status identifier of the short message with the previous sequence number of the current short message is searched in the bit array in step 101, so as to determine the sending status of the short message with the previous sequence number, such as: one of four states of waiting to return to a delivery state in transmission, having sent but failed to deliver, or having sent and succeeded to deliver is to be sent.
Optionally, step 102 may comprise: positioning two bit positions occupied by the short message with the previous sequence number of the current short message in the bit array according to the previous sequence number of the current short message; and determining the sending state of the short message with the previous serial number according to the state identifications of the two bit positions occupied by the short message with the previous serial number in the bit array. The status identifier corresponding to the short message with the previous sequence number of the current short message can be obtained by a getbit method of Redis, so that whether the short message with the previous sequence number of the current short message is delivered or not is judged.
As shown in fig. 3, if the serial number of the current short message is 2, the state identifier of the short message with serial number 1 in the bit array, that is, the state identifiers of two bits, 2 × 1-1 and 2 × 1, is obtained by the getbit method of Redis.
It should be noted that if the serial number of the current short message is 1, this determination is not needed, but the current short message is directly sent.
And 103, if the sending state of the short message with the previous serial number is successful, sending the current short message.
And if the sending state of the short message with the previous serial number is successfully sent (for example, the state bit identifier is 11), directly sending the current short message to ensure that the short messages are sequentially sent. Optionally, while sending the current short message, modifying the state identifier of the current short message in the bit array to a waiting-to-return delivery state during sending.
Optionally, as shown in fig. 3, after step 103, the method further includes: and receiving the short message receipt code of the current short message returned by the short message service provider, and storing the short message receipt code and the corresponding relation between the service identifier of the current short message and the short message sequence number. The short message system calls a short message service provider to send a short message, the short message service provider selects a channel corresponding to the short message number to send the short message, meanwhile, the short message system receives a short message receipt code returned by the short message service provider, and the short message system stores the short message receipt code and the corresponding relation between the service identification and the short message sequence number of the current short message.
Optionally, storing the short message receipt code and the corresponding relationship between the service identifier of the current short message and the short message sequence number includes: and storing in a key-value mode, taking the short message receipt code as a key, and taking the service identifier and the short message sequence number of the current short message as a value. In the embodiment of the invention, the short message receipt code is used as the key of Redis, and the value is the service identifier of the current short message plus the serial number.
Optionally, after storing the short message receipt code and the corresponding relationship between the service identifier of the current short message and the sequence number of the current short message, the method further includes: receiving a short message delivery state and a short message receipt code returned by a short message service provider; matching out a corresponding service identifier and a short message serial number according to the returned short message receipt code; and updating the state identifier of the bit position occupied by the short message sequence number in the bit array corresponding to the service identifier into successful delivery according to the matched service identifier and the matched short message sequence number. If the short message service provider successfully sends the short message to the short message receiver, the short message service provider can transmit the short message sending state and the short message receipt code back to the short message system, after the short message system obtains the short message sending state and the short message receipt code, the service identification and the serial number of the short message can be found through the short message receipt code, then the bit array where the short message is located is determined according to the service identification, two occupied bit positions of the short message in the bit array are determined according to the serial number, and finally the state identification of the two bit positions is modified into the state identification which is sent and successfully sent.
Optionally, the method further comprises: if the sending state of the short message with the previous serial number is in sending, the current short message is put into a waiting queue; judging whether the sending state of the short message with the previous serial number is successful at preset time intervals; and if so, taking out the current short message from the waiting queue and sending the current short message. If the sending state of the short message with the previous sequence number is in sending, the current short message is put into a waiting queue, and retry is carried out at preset time intervals (namely, whether the sending state of the short message with the previous sequence number is successful is judged), and if the sending state of the short message with the previous sequence number is successful, the current short message is taken out from the waiting queue and sent.
Optionally, after the current short message is put into a waiting queue, the method further includes: calculating the overtime waiting time of the current short message according to the time of the current short message transmitted from a service system and a preset overtime threshold; judging whether the current short message reaches the overtime waiting time or not; and if so, taking out the current short message from the waiting queue and sending the current short message. Retrying at preset intervals after the short message enters the waiting queue, because the incoming time of the short message is recorded in the access object in step 101, the overtime waiting time of the short message can be calculated through the incoming time of the short message and a preset overtime threshold, and if the current time reaches the overtime waiting time of the short message, the short message is taken out from the waiting queue and is directly sent out. If the current time does not reach the timeout waiting time of the short message, the retry is continued. After sending the short message, the sending state of the short message and the storage receipt code are set in the bit array, which is not described again.
Optionally, the method further comprises: if the sending state of the short message with the previous serial number is delivery failure, judging whether the current short message strongly depends on the delivery success of the short message with the previous serial number; if yes, the sending of the current short message is cancelled; if not, the current short message is put into a waiting queue. If the current short message strongly depends on the successful delivery of the short message with the previous sequence number, if the short message with the previous sequence number is sent in the middle of the delivery, the current short message is put into a waiting queue, and if the short message with the previous sequence number is sent in the failure of the delivery, the current short message is cancelled. If the current short message is not successfully sent by the short message strongly dependent on the previous serial number, if the short message with the previous serial number is sent in the middle of sending, the current short message is put into a waiting queue, and if the short message with the previous serial number is failed to be sent, the current short message is put into the waiting queue.
According to the various embodiments described above, it can be seen that the technical means of the present invention searches the sending state of the short message with the previous sequence number from the bit array by writing the state identifier of the present short message into the bit array, and if the sending state of the short message with the previous sequence number is successful, the present short message is sent, so as to solve the technical problem that the sending sequence of the short message cannot be guaranteed in the prior art. The embodiment of the invention realizes the strong consistency of the short message sending sequence and the short message sending sequence by using the bit array to carry out the short message state identification. Even for the distributed short messages, the distributed short messages can be globally ordered, and the distributed short messages can be sequentially sent and can be sequentially sent.
Fig. 4 is a schematic diagram of a main flow of a method for sending a short message according to a reference embodiment of the present invention. As another embodiment of the present invention, as shown in fig. 4, the method for sending a short message may include:
the sequencing module receives short message information of a current short message transmitted by a service system, wherein the short message information comprises a service identifier, short message content, a short message sequence number and a receiver identifier. Then, the sequencing module determines a bit array corresponding to the service identifier according to the service identifier of the current short message, determines the bit occupied by the current short message in the bit array according to the serial number of the current short message, and writes the state identifier of the current short message into the bit. After the state identifier of the current short message is written into the bit array, the incoming time of the current short message is generated, and the incoming time is directly put into a short message input object, namely the incoming time is set as an attribute of the short message.
And the sequencing module searches the state identifier of the short message with the previous sequence number of the current short message from the digit group so as to determine the sending state of the short message with the previous sequence number, and if the sending state of the short message with the previous sequence number is successful, the sending module calls a short message service provider to send the short message. And when the current short message is sent, the sequencing module modifies the state identifier of the current short message in the bit array into a state of waiting for returning to the sending state in the sending process.
The short message service provider selects a channel corresponding to the short message number for sending the short message, meanwhile, the sequencing module receives a short message receipt code returned by the short message service provider, and the sequencing module stores the short message receipt code and the corresponding relation between the service identifier and the short message serial number of the current short message.
If the short message service provider successfully sends the short message to the short message receiver, the short message service provider can transmit the short message sending state and the short message receipt code back to the sequencing module, after the sequencing module obtains the short message sending state and the short message receipt code, the service identification and the serial number of the short message can be found through the short message receipt code, then the bit array where the short message is located is determined according to the service identification, two occupied bit positions of the short message in the bit array are determined according to the serial number, and finally the state identification of the two bit positions is modified into the state identification which is sent and successfully sent.
If the sending state of the short message with the previous sequence number is in sending, the sequencing module puts the current short message into a waiting queue; judging whether the sending state of the short message with the previous serial number is successful at preset time intervals; and if so, taking out the current short message from the waiting queue and sending the current short message.
The sorting module calculates the overtime waiting time of the current short message according to the time of transmitting the current short message from the service system and a preset overtime threshold; judging whether the current short message reaches the overtime waiting time or not; and if so, taking out the current short message from the waiting queue and sending the current short message.
If the sending state of the short message with the previous serial number is delivery failure, the sequencing module judges whether the current short message strongly depends on the delivery success of the short message with the previous serial number; if yes, the sending of the current short message is cancelled; if not, the current short message is put into a waiting queue.
In addition, in a reference embodiment of the present invention, the detailed implementation content of the method for sending a short message is already described in detail in the above-mentioned method for sending a short message, so that the repeated content is not described again.
Fig. 5 is a schematic diagram of main modules of an apparatus for sending a short message according to an embodiment of the present invention, and as shown in fig. 5, the apparatus 500 for sending a short message includes a writing module 501, a status module 502, and a short message module 503. The writing module 501 is configured to write a status identifier of a current short message into a bit array; the status module 502 is configured to find a status identifier of a short message with a previous sequence number of the current short message from the digit group, so as to determine a sending status of the short message with the previous sequence number; the short message module 503 is configured to send the current short message if the sending status of the short message with the previous sequence number is successful.
Optionally, the writing module 501 is further configured to:
receiving short message information of a current short message transmitted by a service system, wherein the short message information comprises a service identifier, short message content, a short message serial number and a receiver identifier;
determining a bit array corresponding to the service identifier according to the service identifier of the current short message;
and determining the bit position occupied by the current short message in the bit array according to the serial number of the current short message, and writing the state identification of the current short message into the bit position.
Optionally, the state identifier of each short message occupies two bits in the bit array, and each short message occupies the bits in the bit array in sequence according to the sequence from small to large of the short message sequence number; where 00, 01, 10 and 11 represent four different transmission states, respectively.
Optionally, the status module 502 is further configured to:
positioning two bit positions occupied by the short message with the previous sequence number of the current short message in the bit array according to the previous sequence number of the current short message;
and determining the sending state of the short message with the previous serial number according to the state identifications of the two bit positions occupied by the short message with the previous serial number in the bit array.
Optionally, the short message module 503 is further configured to:
and after the current short message is sent, receiving a short message receipt code of the current short message returned by a short message service provider, and storing the short message receipt code and the corresponding relation between the service identifier and the short message sequence number of the current short message.
Optionally, the short message module 503 is further configured to:
and storing in a key-value mode, taking the short message receipt code as a key, and taking the service identifier and the short message sequence number of the current short message as a value.
Optionally, the short message module 503 is further configured to:
after storing the short message receipt code and the corresponding relation between the service identification of the current short message and the serial number of the current short message, receiving the short message delivery state and the short message receipt code returned by the short message service provider;
matching out a corresponding service identifier and a short message serial number according to the returned short message receipt code;
and updating the state identifier of the bit position occupied by the short message sequence number in the bit array corresponding to the service identifier into successful delivery according to the matched service identifier and the matched short message sequence number.
Optionally, the short message module 503 is further configured to:
if the sending state of the short message with the previous serial number is in sending, the current short message is put into a waiting queue;
judging whether the sending state of the short message with the previous serial number is successful at preset time intervals; and if so, taking out the current short message from the waiting queue and sending the current short message.
Optionally, the short message module 503 is further configured to:
after the current short message is put into a waiting queue, calculating the overtime waiting time of the current short message according to the time of the current short message transmitted from a service system and a preset overtime threshold;
judging whether the current short message reaches the overtime waiting time or not;
and if so, taking out the current short message from the waiting queue and sending the current short message.
Optionally, the short message module 503 is further configured to:
if the sending state of the short message with the previous serial number is delivery failure, judging whether the current short message strongly depends on the delivery success of the short message with the previous serial number;
if yes, the sending of the current short message is cancelled;
if not, the current short message is put into a waiting queue.
According to the various embodiments described above, it can be seen that the technical means of the present invention searches the sending state of the short message with the previous sequence number from the bit array by writing the state identifier of the present short message into the bit array, and if the sending state of the short message with the previous sequence number is successful, the present short message is sent, so as to solve the technical problem that the sending sequence of the short message cannot be guaranteed in the prior art. The embodiment of the invention realizes the strong consistency of the short message sending sequence and the short message sending sequence by using the bit array to carry out the short message state identification. Even for the distributed short messages, the distributed short messages can be globally ordered, and the distributed short messages can be sequentially sent and can be sequentially sent.
It should be noted that, the detailed implementation contents of the apparatus for sending short messages according to the present invention have been described in detail in the above method for sending short messages, and therefore, the repeated contents are not described again.
Fig. 6 shows an exemplary system architecture 600 of a method or a device for sending a short message to which an embodiment of the present invention can be applied.
As shown in fig. 6, the system architecture 600 may include terminal devices 601, 602, 603, a network 604, and a server 605. The network 604 serves to provide a medium for communication links between the terminal devices 601, 602, 603 and the server 605. Network 604 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use the terminal devices 601, 602, 603 to interact with the server 605 via the network 604 to receive or send messages or the like. The terminal devices 601, 602, 603 may have installed thereon various communication client applications, such as shopping applications, web browser applications, search applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 601, 602, 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 605 may be a server providing various services, such as a background management server (for example only) providing support for shopping websites browsed by users using the terminal devices 601, 602, 603. The background management server may analyze and otherwise process the received data such as the item information query request, and feed back a processing result (for example, target push information, item information — just an example) to the terminal device.
It should be noted that the method for sending a short message provided by the embodiment of the present invention is generally executed by the server 605, and accordingly, the apparatus for sending a short message is generally disposed in the server 605.
It should be understood that the number of terminal devices, networks, and servers in fig. 6 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 7, shown is a block diagram of a computer system 700 suitable for use with a terminal device implementing an embodiment of the present invention. The terminal device shown in fig. 7 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 7, the computer system 700 includes a Central Processing Unit (CPU)701, which can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)702 or a program loaded from a storage section 708 into a Random Access Memory (RAM) 703. In the RAM703, various programs and data necessary for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM703 are connected to each other via a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
The following components are connected to the I/O interface 705: an input portion 706 including a keyboard, a mouse, and the like; an output section 707 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 708 including a hard disk and the like; and a communication section 709 including a network interface card such as a LAN card, a modem, or the like. The communication section 709 performs communication processing via a network such as the internet. A drive 710 is also connected to the I/O interface 705 as needed. A removable medium 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 710 as necessary, so that a computer program read out therefrom is mounted into the storage section 708 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 709, and/or installed from the removable medium 711. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 701.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer programs according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor comprises a writing module, a state module and a short message module, wherein the names of the modules do not form a limit to the modules in a certain condition.
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: writing the state identifier of the current short message into a bit array; finding out the state identification of the short message with the previous sequence number of the current short message from the digit group so as to determine the sending state of the short message with the previous sequence number; and if the sending state of the short message with the previous serial number is successful, sending the current short message.
According to the technical scheme of the embodiment of the invention, because the state identification of the current short message is written into the digit group, the sending state of the short message with the previous serial number is searched from the digit group, and if the sending state of the short message with the previous serial number is successful, the technical means of sending the current short message is adopted, so that the technical problem that the sending sequence of the short message cannot be ensured in the prior art is solved. The embodiment of the invention realizes the strong consistency of the short message sending sequence and the short message sending sequence by using the bit array to carry out the short message state identification. Even for the distributed short messages, the distributed short messages can be globally ordered, and the distributed short messages can be sequentially sent and can be sequentially sent.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims (13)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202010148283.XA CN113365231A (en) | 2020-03-05 | 2020-03-05 | Method and device for sending short message |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202010148283.XA CN113365231A (en) | 2020-03-05 | 2020-03-05 | Method and device for sending short message |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN113365231A true CN113365231A (en) | 2021-09-07 |
Family
ID=77523766
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202010148283.XA Pending CN113365231A (en) | 2020-03-05 | 2020-03-05 | Method and device for sending short message |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN113365231A (en) |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113766437A (en) * | 2020-08-31 | 2021-12-07 | 北京沃东天骏信息技术有限公司 | Short message sending method and device |
| CN115314458A (en) * | 2022-07-05 | 2022-11-08 | 深圳手回科技集团有限公司 | Message pushing method and device, electronic equipment and storage medium |
Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102668516A (en) * | 2011-12-02 | 2012-09-12 | 华为技术有限公司 | Method and apparatus for realizing message passing amid cloud information service |
| CN103037326A (en) * | 2011-09-30 | 2013-04-10 | 重庆重邮信科通信技术有限公司 | Method and device for processing long shot messages |
| CN107656825A (en) * | 2017-09-01 | 2018-02-02 | 上海艾融软件股份有限公司 | Message treatment method, apparatus and system |
-
2020
- 2020-03-05 CN CN202010148283.XA patent/CN113365231A/en active Pending
Patent Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103037326A (en) * | 2011-09-30 | 2013-04-10 | 重庆重邮信科通信技术有限公司 | Method and device for processing long shot messages |
| CN102668516A (en) * | 2011-12-02 | 2012-09-12 | 华为技术有限公司 | Method and apparatus for realizing message passing amid cloud information service |
| CN107656825A (en) * | 2017-09-01 | 2018-02-02 | 上海艾融软件股份有限公司 | Message treatment method, apparatus and system |
Non-Patent Citations (2)
| Title |
|---|
| 张铭,王腾蛟,赵海燕编著: "《数据结构与算法》", 30 June 2008 * |
| 肖竞华,陈建勋主编: "《计算机操作系统原理-Linux实例分析》", 30 September 2008 * |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113766437A (en) * | 2020-08-31 | 2021-12-07 | 北京沃东天骏信息技术有限公司 | Short message sending method and device |
| CN115314458A (en) * | 2022-07-05 | 2022-11-08 | 深圳手回科技集团有限公司 | Message pushing method and device, electronic equipment and storage medium |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN115004673B (en) | Message pushing method, device, electronic equipment and computer readable medium | |
| CN110019211A (en) | The methods, devices and systems of association index | |
| CN110263277B (en) | Page data display method, page data updating device, page data equipment and storage medium | |
| WO2023202276A1 (en) | Domain name resolution request processing method and apparatus, and device, medium and program product | |
| CN111427701A (en) | Workflow engine system and business processing method | |
| CN113076153A (en) | Interface calling method and device | |
| CN113761085A (en) | Method and device for processing order data | |
| CN113365231A (en) | Method and device for sending short message | |
| CN113127561B (en) | Method and device for generating service single number, electronic equipment and storage medium | |
| CN112836201A (en) | Method, apparatus, device and computer-readable medium for multi-platform information exchange | |
| CN114138895B (en) | Data synchronization method and device for multiple data sources, computer equipment and storage medium | |
| CN113238808A (en) | Message pushing method and device | |
| CN110543604A (en) | information processing method and device | |
| CN111200640B (en) | Uploading method based on client and client | |
| CN113076256A (en) | Pressure testing method and device | |
| CN113064678A (en) | Cache configuration method and device | |
| CN109213815B (en) | Method, apparatus, server terminal, and readable medium for controlling execution times | |
| CN113778504B (en) | Publishing method, publishing system and routing device | |
| CN118484129A (en) | Method, device and storage medium for processing message | |
| CN113741796B (en) | A method and device for data persistence of terminal applications | |
| CN112732417B (en) | Method and device for processing application request | |
| CN114911954A (en) | Rich media resource interaction method, device, equipment and storage medium | |
| US8296055B2 (en) | Method and system for positional communication | |
| CN113794744A (en) | Message processing method and related equipment | |
| CN111930696A (en) | File transmission processing method and system based on small program |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| RJ01 | Rejection of invention patent application after publication |
Application publication date: 20210907 |
|
| RJ01 | Rejection of invention patent application after publication |