CN113645578B - Method and device for preventing repeated sending of information and storage medium - Google Patents

Method and device for preventing repeated sending of information and storage medium Download PDF

Info

Publication number
CN113645578B
CN113645578B CN202110989101.6A CN202110989101A CN113645578B CN 113645578 B CN113645578 B CN 113645578B CN 202110989101 A CN202110989101 A CN 202110989101A CN 113645578 B CN113645578 B CN 113645578B
Authority
CN
China
Prior art keywords
information sending
information
identifier
state
identification
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.)
Active
Application number
CN202110989101.6A
Other languages
Chinese (zh)
Other versions
CN113645578A (en
Inventor
李铁擎
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Dewu Information Technology Co ltd
Original Assignee
Shanghai Dewu Information Technology Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Shanghai Dewu Information Technology Co ltd filed Critical Shanghai Dewu Information Technology Co ltd
Priority to CN202110989101.6A priority Critical patent/CN113645578B/en
Publication of CN113645578A publication Critical patent/CN113645578A/en
Application granted granted Critical
Publication of CN113645578B publication Critical patent/CN113645578B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W4/00Services specially adapted for wireless communication networks; Facilities therefor
    • H04W4/12Messaging; Mailboxes; Announcements
    • H04W4/14Short messaging services, e.g. short message services [SMS] or unstructured supplementary service data [USSD]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W24/00Supervisory, monitoring or testing arrangements
    • H04W24/02Arrangements for optimising operational condition

Abstract

The invention discloses a method, a device and a storage medium for preventing repeated sending of information, wherein the method comprises the following steps: receiving an application information sending identification message, generating an information sending identification according to the service type and the mobile phone number of a receiver, returning the information sending identification, and setting the information sending identification to be in a first state; receiving an information sending request message, and setting an information sending identifier as a second state; and adding a distributed lock to the information sending identifier, and if the distributed lock is successfully added and the information sending identifier is in a second state, sending the information to the mobile phone number of the receiver. The embodiment of the invention solves the problem that the service layer sends the short message repeatedly and sends the same short message to the user, reduces the cost for sending the short message, and avoids the user from receiving a plurality of same short messages, thereby improving the user experience.

Description

Method and device for preventing repeated sending of information and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for preventing repeated transmission of information, and a storage medium.
Background
More and more companies establish own short message service platforms for processing huge short message sending tasks in the companies. Since each short message has a price, controlling the sending amount of the short message is also a strategy that needs to be implemented by the short message service platform, and one of the difficult problems is the situation of the repeated sending of the short message, which mainly occurs when a service party repeatedly calls a short message sending interface of the short message service platform. If no effective repeated verification mechanism exists, the short message service platform cannot distinguish whether the content of the short message is sent, and an effective interception mechanism is not available for interception. Therefore, the same mobile phone number receives a plurality of same contents because the service layer repeatedly sends the short messages, which not only causes economic loss, but also affects user experience.
Disclosure of Invention
The invention mainly aims to provide a method, a device and a storage medium for preventing repeated sending of information, and aims to solve the problem that a service party repeatedly calls a short message sending interface of a short message service platform to cause repeated sending of short messages in the prior art.
In order to achieve the above object, the present invention provides a method for preventing repeated transmission of information, the method comprising the steps of:
receiving application information sending identification information, wherein the application information sending identification information comprises a service type and a receiver mobile phone number; generating an information sending identifier according to the service type and the mobile phone number of the receiver, returning the information sending identifier, and setting the information sending identifier to be in a first state;
receiving an information sending request message, wherein the information sending request message comprises the information sending identification, the mobile phone number of the receiver and information, and the information sending identification is set to be in a second state;
adding a distributed lock to the information sending identifier; if the distributed lock is added successfully and the information sending identifier is in the second state, sending the information to the mobile phone number of the receiver; and if the distributed lock is added unsuccessfully or the information sending identifier is not in the second state, not sending the information to the mobile phone number of the receiver.
Optionally, the information sending identifier is generated by:
allocating an identifier to the mobile phone number of the receiver and the service type, wherein the identifier is used as the information sending identifier;
and storing the corresponding relation between the mobile phone number of the receiving party, the service type and the information sending identifier.
Optionally, after receiving the application information sending identification message, the method further includes the following steps:
judging whether the corresponding information sending identification exists according to the service type and the mobile phone number of the receiver;
if the information sending identification exists, further judging the state of the information sending identification; if the information sending identifier is in the first state, returning the information sending identifier; if the information sending identification is not in the first state, the information sending identification is not returned;
and if the information sending identification does not exist, generating the information sending identification according to the service type and the mobile phone number of the receiver, returning the information sending identification, and setting the information sending identification to be in a first state.
Optionally, after receiving the information sending request message, the method further includes the following steps:
judging whether the information sending identification carried in the information sending request message exists;
if the information exists, the state of the information sending identifier is further judged; if the information sending identifier is in the first state, storing the information sending request message and setting the information sending identifier to be in the second state; if the information sending identification is not in the first state, discarding the information sending request message;
if not, the information transmission request message is discarded.
Optionally, the method further comprises the steps of:
and after the short message sending interface provided by the short message service provider is called to successfully send the information, setting the information sending identifier as a third state.
Optionally, the method further comprises the steps of:
setting effective duration for the information sending identification according to the service type;
and deleting the information sending identification after the effective duration is expired.
Optionally, the adding a distributed lock to the information sending identifier includes:
storing the information sending identification into a Redis database by using a setnx command of the Redis database;
if the storage is successful, indicating that the adding of the distributed lock is successful; if the store fails, it indicates that the addition of the distributed lock failed.
In addition, to achieve the above object, the present invention also provides an apparatus for preventing information from being repeatedly transmitted, the apparatus including:
the system comprises a creating unit, a receiving unit and a sending unit, wherein the creating unit is used for receiving an application information sending identification message, and the application information sending identification message comprises a service type and a receiver mobile phone number; generating an information sending identifier according to the service type and the mobile phone number of the receiver, returning the information sending identifier, and setting the information sending identifier to be in a first state;
a receiving unit, configured to receive an information sending request message, where the information sending request message includes the information sending identifier, the receiver mobile phone number, and information, and sets the information sending identifier to be in a second state;
the sending unit is used for adding a distributed lock to the information sending identifier; if the distributed lock is added successfully and the information sending identifier is in the second state, sending the information to the mobile phone number of the receiver; and if the distributed lock is failed to be added or the information sending identifier is not in the second state, the information is not sent to the mobile phone number of the receiver.
In addition, to achieve the above object, the present invention also provides an electronic device, including: a memory, a processor, and an information repeat-transmission prevention program stored on the memory and executable on the processor, the information repeat-transmission prevention program configured to implement the steps of the information repeat-transmission prevention method as described above.
Furthermore, to achieve the above object, the present invention also proposes a computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the steps of preventing the information repetition transmission method as described above.
The invention distributes the unique information sending identification to the information sending and carries out distributed locking on the information sending identification, solves the problem that the service layer repeatedly calls the short message sending interface provided by the short message service platform to repeatedly send the same short message to the user, reduces the short message sending cost, and avoids the user from receiving a plurality of same short messages, thereby improving the user experience.
Drawings
Fig. 1 is a schematic flow chart of a method for preventing repeated transmission of information according to the present invention.
Fig. 2 is a schematic flow chart of creating an information transmission identifier according to the present invention.
Fig. 3 is another schematic flow chart of the method for preventing repeated transmission of information according to the present invention.
Fig. 4 is a schematic flow chart of preventing duplicate application information transmission identification provided by the present invention.
Fig. 5 is a schematic flow chart of preventing repeated transmission of information transmission requests according to the present invention.
Fig. 6 is a block diagram of the device for preventing the repeated transmission of information according to the present invention.
Fig. 7 is a schematic structural diagram of an electronic device according to the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
In order to make the technical problems, technical solutions and advantageous effects to be solved by the present invention clearer and clearer, the present invention is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
In the following description, suffixes such as "module", "component", or "unit" used to denote elements are used only for facilitating the explanation of the present invention, and have no specific meaning in itself. Thus, "module", "component" or "unit" may be used mixedly.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order.
In one embodiment, as shown in fig. 1, the present invention provides a method for preventing repeated transmission of information, the method including:
step 101, receiving application information sending identification information, wherein the application information sending identification information comprises a service type and a receiver mobile phone number; and generating an information sending identifier according to the service type and the mobile phone number of the receiver, returning the information sending identifier, and setting the information sending identifier to be in a first state.
In the embodiment of the application, for example, in the user registration process, the application layer, such as the user registration module, needs to send the registration verification code to the mobile phone number provided by the user during registration to verify the authenticity of the mobile phone number of the user. Therefore, the application layer needs to call an API interface provided by the short message service platform to send the short message of the registration verification code.
In order to prevent the application layer from repeatedly calling an API (application programming interface) provided by the short message service platform to send the short message, the application layer needs to apply for a unique information sending identifier from the short message service platform before sending the short message. And only after the information sending identification is successfully acquired, allowing the subsequent short message sending to the user.
The application layer sends an application information sending identification message to the short message service platform, and the application layer carries the service type and the mobile phone number of a receiver, and the following table is shown:
type of service User registration
Receiver mobile phone number 13800880xxx
The service type is set according to the specific service requirement of the application layer, such as: user registration, arrearage reminding, express notice and the like. Each service type corresponds to a short message content; if the service types are different, the content of the short message is also different. The same service can not be repeatedly sent to the user within a period of time (for example, when the user registers, the registration verification code can not be repeatedly sent to the user within 60 seconds), and the same short message content can not be sent to the same user.
After receiving the application information sending identification message, the short message service platform acquires the service type and the mobile phone number of the receiver in the message. And then, creating a globally unique information sending identifier according to the service type and the mobile phone number of the receiver. Creating an information sending identification flow, as shown in fig. 2:
step 1011, allocating an identifier to the mobile phone number of the receiving party and the service type, where the identifier is used as the information sending identifier.
After receiving the application information sending identification message, the short message service platform uses the service type, the mobile phone number of the receiving party and the current timestamp to form a text message, then MD5 calculation is carried out on the text message to obtain a 32-bit 16-system character string (namely an MD5 value), and the MD5 value is used as an information sending identification. Such as: MD5 calculations were performed on the text content "1 +13800880123+ 1629892732683" to obtain MD5 values as shown in the following table.
Text content 1+13800880123+1629892732683
MD5 value de8d03692a1eac4a7a1694c410387f10
The short message service platform can also adopt other methods to distribute an identifier.
Step 1012, storing the corresponding relationship between the mobile phone number of the receiving party, the service type and the information sending identification.
And storing the mobile phone number and the service type of the receiver and the information sending identifier distributed to the mobile phone number and the service type of the receiver in a relational database (such as a mysql database). The receiving party mobile phone number and the service type are combined into a unique index of the database table, namely only one piece of corresponding information sending identification data exists between the corresponding service type and the receiving party mobile phone number in the database. As in the following table:
type of service 1
Receiver mobile phone number 13800880123
Information transmission identifier de8d03692a1eac4a7a1694c410387f10
The database is inquired through the service type and the mobile phone number of the receiver, and the corresponding information sending identification can be inquired.
And 1013, setting effective duration for the information sending identification according to the service type.
The service layer sets how long the same short message content is allowed to be sent to the user triggering the service according to different service types. For example, the registration service needs 60 seconds later to allow the user to send the registration verification code again; the arrearage reminding service can only send the arrearage reminding short message once within 1 day.
And the short message service platform sets effective duration for the corresponding information sending identification according to different service types. The effective duration is the duration of the service allowing repeated short message sending. The short message service platform configures a service type valid duration configuration table corresponding to the service type, such as:
type of service Duration of validity
Registration service 60 seconds
Arrearage reminder 24 hours
The short message service platform sets effective time length for the information sending identification, acquires the effective time length according to the service type corresponding to the information sending identification, and then sets the effective time length as the effective time length of the information sending identification.
Figure BDA0003231839970000061
Figure BDA0003231839970000071
And 1014, deleting the information sending identifier after the effective duration expires.
After the short message service platform sets effective duration for the information sending identification, a timer is started, and the effective duration is used as the overtime duration of the timer. And after the timer is overtime, deleting the corresponding information sending identification. After the information sending identification is deleted, the short message service platform allows the service layer to apply for the information sending identification again according to the same service type and the mobile phone number of the receiver, namely, the short message service platform allows the mobile phone number to send the same short message content again.
And after the short message service platform creates the message sending identifier, returning the message sending identifier to the application layer. When the application layer subsequently resends the short message, the information is needed to be used for sending the identification. Meanwhile, the state of the information sending identifier is set to be a first state, such as: an initial state.
Type of service 1
Receiver mobile phone number 13800880123
Information transmission identifier de8d03692a1eac4a7a1694c410387f10
Duration of validity 60 seconds
Status of state Initial state
102, receiving an information sending request message, wherein the information sending request message comprises the information sending identification, the mobile phone number of the receiver and information, and setting the information sending identification to be in a second state.
The application layer allows the sending of the short message only after receiving the information sending identification returned by the short message service platform; and if the information sending identification returned by the short message service platform is not received, the short message is not allowed to be sent to the user. After receiving the information sending identification returned by the short message service platform, the application layer constructs an information sending request message carrying the information sending identification, the mobile phone number of the receiver and the information. The information can be short message content, and also can be short message template id and corresponding parameter content. Such as:
Figure BDA0003231839970000072
in this embodiment, the information includes: short messages, multimedia messages, video messages, and the like.
After receiving the information sending request message, the short message service platform stores the message into a message queue. The message queue can be a self-realized message queue in the short message service platform, such as a first-in first-out message queue; or message queue middleware provided by a third party, such as Kafka, RabbitMQ, rocktmq and the like. The message queue has a high data processing throughput, such as ten thousand or one hundred thousand. Therefore, when the service layer sends a large amount of information sending request messages at the same time in the service peak period, the message queue can also be stored in time. After storing the large amount of information sending request messages into the message queue, the short message service platform can gradually acquire the information sending request messages from the message queue according to the service processing capacity of the short message service platform, and then send corresponding information (short messages, multimedia messages or video short messages) to corresponding mobile phone numbers.
Then the short message service platform sets the state of the information sending identification carried in the message to a second state, such as: a status to be sent.
Type of service 1
Receiver mobile phone number 13800880123
Information transmission identifier de8d03692a1eac4a7a1694c410387f10
Duration of validity 60 seconds
Status of state State to be sent
103, adding a distributed lock to the information sending identifier; if the distributed lock is added successfully and the information sending identifier is in the second state, sending the information to the mobile phone number of the receiver; and if the distributed lock is failed to be added or the information sending identifier is not in the second state, the information is not sent to the mobile phone number of the receiver.
The short message service platform can use interfaces provided by a plurality of short message service providers to send short messages, so a plurality of threads or processes can be started to send the short messages; or when only one short message service provider is provided, a plurality of threads or processes can be started to call the interface provided by the short message service provider to send the short message.
Each thread or process acquires information from a message queue (such as RabbitMQ message queue middleware) step by step according to the service processing capacity of the thread or process and sends request messages. After the information sending request message is acquired, the information, the mobile phone number of the receiver and the information sending identification are taken out from the message. Such as:
Figure BDA0003231839970000081
Figure BDA0003231839970000091
after obtaining the information sending request message, the thread or process of the short message service platform sending the short message needs to perform distributed locking on the message, and the corresponding information in the message can be sent only after the distributed locking is successful. If the distributed lock fails, this indicates that the information has been processed by other threads, or that the information is duplicate information.
The distributed lock of the short message service platform is realized through a setnx command of a Redis database. The setnx command is as follows: SET key value.
The key is an information sending identifier in the information sending request message, and the value is a random value. Such as:
set de8d03692a1eac4a7a1694c410387f10 123456
the set command of the Redis database can be successfully executed only if the key value does not exist. Therefore, after a thread A successfully executes the set command with the key value de8d03692a1eac4a7a1694c410387f10, other threads (such as thread B) can not execute the set command with the key value de8d03692a1eac4a7a1694c410387f 10. Therefore, the distributed lock function for the information transmission request message can be realized by using the information transmission identity as the key value of the set command.
And after the thread A acquires the information sending request message, using the information sending identifier in the message as a key value of the set command, and executing the set command. If the execution is successful, it indicates that no thread processes the information sending request message before, that is, the thread A obtains the distributed lock of the information sending request message, and sends the information, such as sending a short message to a mobile phone number of a receiver, after obtaining the distributed lock of the information. Other threads can not obtain the distributed lock of the information sending request message any more, and the information sending request message can not be processed.
And after the distributed thread lock is successful, further judging the state of the information sending identifier, and allowing to call an API (application programming interface) provided by the short message service platform to send the short message to the corresponding mobile phone number as long as the state of the information sending identifier is in a to-be-sent state (namely a second state). If the state of the information sending identifier is not the state to be sent, it indicates that the short message corresponding to the information sending identifier is processed or invalid, and the information sending request message corresponding to the information sending identifier needs to be discarded.
In the embodiment, the problem that the same short message is repeatedly sent to the user due to the fact that the service layer repeatedly calls the short message sending interface provided by the short message service platform is solved by distributing the unique information sending identifier to the information sending and carrying out distributed locking on the information sending identifier, the short message sending cost is reduced, the user is prevented from receiving a plurality of same short messages, and therefore user experience is improved.
In one embodiment, FIG. 3 provides a flowchart of the step of FIG. 1 after sending the information and then identifying the information as sent.
And step 104, after calling a short message sending interface provided by a short message service provider to send the information successfully, setting the information sending identifier as a third state.
And after the short message service platform successfully sends the short message, setting the information sending identification corresponding to the short message to be in a third state, such as a sent state. After the state of the information sending identifier is set to be the sent state, the short message service platform does not process the information sending request message corresponding to the information sending identifier. After receiving the information sending request message sent by the service layer, the short message service platform directly discards the information sending request message if the state corresponding to the information sending identification carried by the message is the sent state.
In this embodiment, the short message service platform sets the successfully sent message sending identifier to a sent state, so as to prevent the short message service platform from repeatedly processing the message sending request message, thereby improving the processing capability of the short message service platform, reducing the cost for sending the short message, and preventing the user from receiving an abnormal short message, thereby improving the user experience.
In one embodiment, FIG. 4 provides a flow chart for preventing duplicate application information transmission identification.
Step 201, judging whether the corresponding information sending identification exists according to the service type and the mobile phone number of the receiving party.
The application layer can repeatedly apply for the information sending identification in certain scenes, and if the application layer does not timely receive the information sending identification returned by the short message service platform, the application layer can apply for the information sending identification to the short message service platform again.
After receiving the application information sending identification message sent by the application layer, the short message service platform uses the service type and the receiver mobile phone number carried in the message to inquire the database and obtains the information sending identification corresponding to the service type and the receiver mobile phone number. Such as:
type of service 1
Receiver mobile phone number 13800880123
Step 202, if the information sending identification exists, the state of the information sending identification is further judged; if the information sending identifier is in the first state, returning the information sending identifier; and if the information sending identifier is not in the first state, the information sending identifier is not returned.
If the service type and the mobile phone number of the receiver carried in the message are used for inquiring the database, the corresponding information sending identification is obtained. Such as using
Type of service 1
Receiver mobile phone number 13800880123
Querying a database to obtain the following information sending identifiers:
information transmission identifier de8d03692a1eac4a7a1694c410387f10
And then judging the state corresponding to the information sending identification. If the corresponding state is the first state, such as the initial state, it indicates that the application layer does not use the information sending identifier to send the information sending request message to the short message service platform. Therefore, the information sending identification needs to be returned to the application layer.
If the corresponding state is not the first state (e.g., initial state), it is the other state, e.g., sent state. The message sending request message is sent to the short message service platform by the application layer through the message sending identifier without returning the message sending identifier to the application layer.
And 203, if the information sending identifier does not exist, generating the information sending identifier according to the service type and the mobile phone number of the receiver, returning the information sending identifier, and setting the information sending identifier to be in a first state.
If the service type and the mobile phone number of the receiver carried in the message are used for inquiring the database, the corresponding information sending identification is not obtained. Such as use
Type of service 1
Receiver mobile phone number 13800880123
And querying the database, wherein no information sending identification is obtained. It indicates that the information sending identifier corresponding to the service type and the mobile phone number of the receiving party is deleted or the application layer applies for the information sending identifier for the service type and the mobile phone number of the receiving party for the first time.
The short message service platform uses the flow as shown in fig. 2 to create an information sending identifier for the service type and the mobile phone number of the receiving party. As shown in the following table:
Figure BDA0003231839970000111
Figure BDA0003231839970000121
and the short message service platform returns the created information sending identification to the application layer.
In this embodiment, the short message service platform prevents the application layer from repeatedly applying for the information transmission identifier by inquiring whether the service type and the mobile phone number of the receiver have the corresponding information transmission identifier and judging the state. Therefore, messages processed by the short message service platform are reduced, and the processing capacity of the short message service platform is improved.
In one embodiment, FIG. 5 provides a flow chart for preventing duplicate transmission of information transmission requests.
Step 301, determining whether the information sending identifier carried in the information sending request message already exists.
The application layer can repeatedly send the information sending request message in certain scenes, and if the application layer does not timely receive a short message sending completion message returned by the short message service platform, the application layer can send an information sending application message to the short message service platform again.
After receiving the information sending request message sent by the application layer, the short message service platform queries the database by using the information sending identification carried in the message. Such as:
information transmission identifier de8d03692a1eac4a7a1694c410387f10
Step 302, if existing, further judging the state of the information sending identifier; if the information sending identifier is in the first state, storing the information sending request message and setting the information sending identifier to be in the second state; and if the information sending identifier is not in the first state, discarding the information sending request message.
If the information sending identification exists, the information sending identification is applied. And then further judging the state of the information sending identifier, if the state is the first state, if so, indicating that the information corresponding to the information sending identifier is not sent, processing the information sending request message, storing the information sending request message into a message queue, and taking out the message from the queue by a subsequent short message service platform for short message sending. And meanwhile, setting the state of the information sending identifier to be a second state, such as a state to be sent, which indicates that the short message service platform has processed the information sending request message corresponding to the information sending identifier.
If the state corresponding to the information sending identifier is not the first state (such as the initial state), it indicates that the short message service platform has processed the information sending request message corresponding to the information sending identifier, and the message is directly discarded without processing the message again.
Step 303, if not, discarding the information sending request message.
If the information sending identification carried in the information sending request message can not be inquired in the database of the short message service platform, the information sending identification is invalid, and the application layer does not apply for the information sending identification from the short message service platform or the valid duration of the information sending identification is expired.
The short message service platform does not process the information sending request message corresponding to the invalid information sending identification, and directly discards the message.
In this embodiment, the short message service platform prevents the application layer from repeatedly sending the information sending request message by inquiring whether the information sending identifier carried in the sending request message exists and judging the state. Therefore, messages processed by the short message service platform are reduced, and the processing capacity of the short message service platform is improved.
In addition, an embodiment of the present invention further provides an apparatus for preventing information from being repeatedly transmitted, where, with reference to fig. 6, the apparatus for preventing information from being repeatedly transmitted includes:
the system comprises a creating unit, a receiving unit and a sending unit, wherein the creating unit is used for receiving an application information sending identification message, and the application information sending identification message comprises a service type and a receiver mobile phone number; generating an information sending identifier according to the service type and the mobile phone number of the receiver, returning the information sending identifier, and setting the information sending identifier to be in a first state;
a receiving unit, configured to receive an information sending request message, where the information sending request message includes the information sending identifier, the receiver mobile phone number, and information, and sets the information sending identifier to be in a second state;
the sending unit is used for adding a distributed lock to the information sending identifier; if the distributed lock is added successfully and the information sending identifier is in the second state, sending the information to the mobile phone number of the receiver; and if the distributed lock is failed to be added or the information sending identifier is not in the second state, the information is not sent to the mobile phone number of the receiver.
In the embodiment, the problem that the same short message is repeatedly sent to the user due to the fact that the service layer repeatedly calls the short message sending interface provided by the short message service platform is solved by distributing the unique information sending identifier to the information sending and carrying out distributed locking on the information sending identifier, the short message sending cost is reduced, the user is prevented from receiving a plurality of same short messages, and therefore user experience is improved.
It should be noted that each unit in the apparatus may be configured to implement each step in the method, and achieve the corresponding technical effect, which is not described herein again.
Referring to fig. 7, fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
As shown in fig. 7, the electronic device may include: a processor 1001, such as a CPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface, a wireless interface. The network interface 1004 may optionally include standard wired interfaces, wireless interfaces (e.g., WI-FI, 4G, 5G interfaces). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (e.g., a magnetic disk memory). The memory 1005 may alternatively be a storage device separate from the processor 1001.
Those skilled in the art will appreciate that the configuration shown in fig. 7 does not constitute a limitation of the electronic device, and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
As shown in fig. 7, a memory 1005, which is a kind of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and a program for preventing information from being repeatedly transmitted.
In the electronic apparatus shown in fig. 7, the network interface 1004 is mainly used for data communication with an external network; the user interface 1003 is mainly used for receiving input instructions of a user; the electronic device calls the information repeat transmission prevention program stored in the memory 1005 by the processor 1001, and performs the following operations:
receiving application information sending identification information, wherein the application information sending identification information comprises a service type and a receiver mobile phone number; generating an information sending identifier according to the service type and the mobile phone number of the receiver, returning the information sending identifier, and setting the information sending identifier to be in a first state;
receiving an information sending request message, wherein the information sending request message comprises the information sending identification, the mobile phone number of the receiver and information, and the information sending identification is set to be in a second state;
adding a distributed lock to the information sending identifier; if the distributed lock is added successfully and the information sending identifier is in the second state, sending the information to the mobile phone number of the receiver; and if the distributed lock is failed to be added or the information sending identifier is not in the second state, the information is not sent to the mobile phone number of the receiver.
Optionally, the information sending identifier is generated by:
allocating an identifier to the mobile phone number of the receiver and the service type, wherein the identifier is used as the information sending identifier;
and storing the corresponding relation between the mobile phone number of the receiver, the service type and the information sending identifier.
Optionally, after receiving the application information sending identification message, the method further includes the following steps:
judging whether the corresponding information sending identification exists according to the service type and the mobile phone number of the receiver;
if the information sending identification exists, further judging the state of the information sending identification; if the information sending identifier is in the first state, returning the information sending identifier; if the information sending identification is not in the first state, the information sending identification is not returned;
if the information sending identification does not exist, the information sending identification is generated according to the service type and the mobile phone number of the receiver, the information sending identification is returned, and the information sending identification is set to be in a first state.
Optionally, after receiving the information sending request message, the method further includes the following steps:
judging whether the information sending identification carried in the information sending request message exists;
if the information exists, the state of the information sending identifier is further judged; if the information sending identifier is in the first state, storing the information sending request message and setting the information sending identifier to be in the second state; if the information sending identification is not in the first state, discarding the information sending request message;
if not, the information transmission request message is discarded.
Optionally, the method further comprises the steps of:
and after the short message sending interface provided by the short message service provider is called to successfully send the information, setting the information sending identifier as a third state.
Optionally, the method further comprises the steps of:
setting effective duration for the information sending identification according to the service type;
and deleting the information sending identification after the effective duration is expired.
Optionally, the adding a distributed lock to the information sending identifier includes:
storing the information sending identification into a Redis database by using a setnx command of the Redis database;
if the storage is successful, indicating that the adding of the distributed lock is successful; if the store fails, it indicates that the adding of the distributed lock failed.
In the embodiment, the problem that the same short message is repeatedly sent to the user due to the fact that the service layer repeatedly calls the short message sending interface provided by the short message service platform is solved by distributing the unique information sending identifier to the information sending and carrying out distributed locking on the information sending identifier, the short message sending cost is reduced, the user is prevented from receiving a plurality of same short messages, and therefore user experience is improved.
Furthermore, an embodiment of the present invention further provides a computer-readable storage medium, where a program for preventing information from being repeatedly transmitted is stored on the computer-readable storage medium, and when the program for preventing information from being repeatedly transmitted is executed by a processor, the program for preventing information from being repeatedly transmitted implements the following operations:
receiving application information sending identification information, wherein the application information sending identification information comprises a service type and a receiver mobile phone number; generating an information sending identifier according to the service type and the mobile phone number of the receiver, returning the information sending identifier, and setting the information sending identifier to be in a first state;
receiving an information sending request message, wherein the information sending request message comprises the information sending identification, the mobile phone number of the receiver and information, and the information sending identification is set to be in a second state;
adding a distributed lock to the information sending identifier; if the distributed lock is added successfully and the information sending identifier is in the second state, sending the information to the mobile phone number of the receiver; and if the distributed lock is failed to be added or the information sending identifier is not in the second state, the information is not sent to the mobile phone number of the receiver.
Optionally, the information sending identifier is generated by:
allocating an identifier to the mobile phone number of the receiver and the service type, wherein the identifier is used as the information sending identifier;
and storing the corresponding relation between the mobile phone number of the receiver, the service type and the information sending identifier.
Optionally, after receiving the application information sending identification message, the method further includes the following steps:
judging whether the corresponding information sending identification exists according to the service type and the mobile phone number of the receiver;
if the information sending identification exists, further judging the state of the information sending identification; if the information sending identifier is in the first state, returning the information sending identifier; if the information sending identification is not in the first state, the information sending identification is not returned;
and if the information sending identification does not exist, generating the information sending identification according to the service type and the mobile phone number of the receiver, returning the information sending identification, and setting the information sending identification to be in a first state.
Optionally, after receiving the information sending request message, the method further includes the following steps:
judging whether the information sending identification carried in the information sending request message exists;
if the information exists, the state of the information sending identifier is further judged; if the information sending identifier is in the first state, storing the information sending request message and setting the information sending identifier to be in the second state; if the information sending identification is not in the first state, discarding the information sending request message;
if not, the information transmission request message is discarded.
Optionally, the method further comprises the steps of:
and after the short message sending interface provided by the short message service provider is called to successfully send the information, setting the information sending identifier as a third state.
Optionally, the method further comprises the steps of:
setting effective duration for the information sending identification according to the service type;
and deleting the information sending identification after the effective duration is expired.
Optionally, the adding a distributed lock to the information sending identifier includes:
storing the information sending identification into a Redis database by using a setnx command of the Redis database;
if the storage is successful, indicating that the adding of the distributed lock is successful; if the store fails, it indicates that the addition of the distributed lock failed.
In the embodiment, the problem that the same short message is repeatedly sent to a user due to the fact that a service layer repeatedly calls a short message sending interface provided by a short message service platform is solved by distributing the unique information sending identification to the information sending and carrying out distributed locking on the information sending identification, the short message sending cost is reduced, the user is prevented from receiving a plurality of same short messages, and therefore user experience is improved.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, a controller, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. A method for preventing repeated transmission of information, the method comprising the steps of:
receiving application information sending identification information, wherein the application information sending identification information comprises a service type and a receiver mobile phone number; generating an information sending identifier according to the service type and the mobile phone number of the receiver, returning the information sending identifier, and setting the information sending identifier to be in a first state;
receiving an information sending request message, wherein the information sending request message comprises the information sending identification, the mobile phone number of the receiver and information, and the information sending identification is set to be in a second state;
adding a distributed lock to the information sending identifier; if the distributed lock is added successfully and the information sending identifier is in the second state, sending the information to the mobile phone number of the receiver; and if the distributed lock is failed to be added or the information sending identifier is not in the second state, the information is not sent to the mobile phone number of the receiver.
2. The method of claim 1, wherein the information transmission identifier is generated by:
allocating an identifier to the mobile phone number of the receiver and the service type, wherein the identifier is used as the information sending identifier;
and storing the corresponding relation between the mobile phone number of the receiver, the service type and the information sending identifier.
3. The method according to claim 2, wherein after receiving the application information sending identification message, the method further comprises the following steps:
judging whether the corresponding information sending identification exists according to the service type and the mobile phone number of the receiver;
if the information sending identification exists, further judging the state of the information sending identification; if the information sending identifier is in the first state, returning the information sending identifier; if the information sending identification is not in the first state, the information sending identification is not returned;
and if the information sending identification does not exist, generating the information sending identification according to the service type and the mobile phone number of the receiver, returning the information sending identification, and setting the information sending identification to be in a first state.
4. The method of claim 1, wherein after receiving the information transmission request message, the method further comprises the steps of:
judging whether the information sending identification carried in the information sending request message exists;
if the information exists, the state of the information sending identifier is further judged; if the information sending identifier is in the first state, storing the information sending request message and setting the information sending identifier to be in the second state; if the information sending identification is not in the first state, discarding the information sending request message;
if not, the information transmission request message is discarded.
5. The method according to claim 1, characterized in that the method further comprises the steps of:
and after the short message sending interface provided by the short message service provider is called to send the information successfully, setting the information sending identifier as a third state.
6. The method of claim 1, further comprising the steps of:
setting effective duration for the information sending identification according to the service type;
and deleting the information sending identification after the effective duration is expired.
7. The method of claim 1, wherein adding a distributed lock to the information sending identity comprises:
storing the information sending identification into a Redis database by using a setnx command of the Redis database;
if the storage is successful, indicating that the adding of the distributed lock is successful; if the store fails, it indicates that the addition of the distributed lock failed.
8. An apparatus for preventing duplicate transmission of information, the apparatus comprising:
the system comprises a creating unit, a receiving unit and a sending unit, wherein the creating unit is used for receiving an application information sending identification message, and the application information sending identification message comprises a service type and a receiver mobile phone number; generating an information sending identifier according to the service type and the mobile phone number of the receiver, returning the information sending identifier, and setting the information sending identifier to be in a first state;
a receiving unit, configured to receive an information sending request message, where the information sending request message includes the information sending identifier, the receiver mobile phone number, and information, and sets the information sending identifier to be in a second state;
the sending unit is used for adding a distributed lock to the information sending identifier; if the distributed lock is added successfully and the information sending identifier is in the second state, sending the information to the mobile phone number of the receiver; and if the distributed lock is failed to be added or the information sending identifier is not in the second state, the information is not sent to the mobile phone number of the receiver.
9. An electronic device, characterized in that the electronic device comprises: a memory, a processor, and an information repeat-prevention-method program stored on the memory and executable on the processor, the information repeat-prevention-method program configured to implement the steps of the information repeat-prevention-method according to any one of claims 1 to 7.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the step of preventing the information repetitive transmission method of any one of claims 1 to 7.
CN202110989101.6A 2021-08-26 2021-08-26 Method and device for preventing repeated sending of information and storage medium Active CN113645578B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110989101.6A CN113645578B (en) 2021-08-26 2021-08-26 Method and device for preventing repeated sending of information and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110989101.6A CN113645578B (en) 2021-08-26 2021-08-26 Method and device for preventing repeated sending of information and storage medium

Publications (2)

Publication Number Publication Date
CN113645578A CN113645578A (en) 2021-11-12
CN113645578B true CN113645578B (en) 2022-06-10

Family

ID=78424027

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110989101.6A Active CN113645578B (en) 2021-08-26 2021-08-26 Method and device for preventing repeated sending of information and storage medium

Country Status (1)

Country Link
CN (1) CN113645578B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114553815A (en) * 2022-01-29 2022-05-27 北京金堤科技有限公司 Method and device for processing message

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20050013305A (en) * 2003-07-28 2005-02-04 엘지전자 주식회사 Method for controlling a transmission of the SMS message
CN101674549A (en) * 2008-09-08 2010-03-17 中国移动通信集团上海有限公司 Method and device sending short messages in groups
CN102340580A (en) * 2010-07-16 2012-02-01 希姆通信息技术(上海)有限公司 Mobile phone and method for preventing repeated sending of mobile phone by using same
CN104113830A (en) * 2014-07-29 2014-10-22 广东能龙教育股份有限公司 Large-scale short message resend-preventing method based on message digest 5 algorithm (MD5) and distributed cache
CN105893395A (en) * 2015-01-26 2016-08-24 阿里巴巴集团控股有限公司 Message re-checking method and system of distributed transaction
CN108073560A (en) * 2017-11-01 2018-05-25 深圳市金立通信设备有限公司 SMS processing method, server and computer-readable medium
CN113301516A (en) * 2021-03-31 2021-08-24 北京思特奇信息技术股份有限公司 Method and system for rejecting duplicate messages during short message sending

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101854747B (en) * 2009-04-01 2013-09-11 中兴通讯股份有限公司 Method and system for transmitting non-3GPP2 (3rd Generation Partnership Project 2) message in HRPD (High Rate Packet Data) system

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20050013305A (en) * 2003-07-28 2005-02-04 엘지전자 주식회사 Method for controlling a transmission of the SMS message
CN101674549A (en) * 2008-09-08 2010-03-17 中国移动通信集团上海有限公司 Method and device sending short messages in groups
CN102340580A (en) * 2010-07-16 2012-02-01 希姆通信息技术(上海)有限公司 Mobile phone and method for preventing repeated sending of mobile phone by using same
CN104113830A (en) * 2014-07-29 2014-10-22 广东能龙教育股份有限公司 Large-scale short message resend-preventing method based on message digest 5 algorithm (MD5) and distributed cache
CN105893395A (en) * 2015-01-26 2016-08-24 阿里巴巴集团控股有限公司 Message re-checking method and system of distributed transaction
CN108073560A (en) * 2017-11-01 2018-05-25 深圳市金立通信设备有限公司 SMS processing method, server and computer-readable medium
CN113301516A (en) * 2021-03-31 2021-08-24 北京思特奇信息技术股份有限公司 Method and system for rejecting duplicate messages during short message sending

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
新业务环境挑战下短信业务感知提升方案研究;赵存等;《互联网天地》;20131215(第12期);全文 *

Also Published As

Publication number Publication date
CN113645578A (en) 2021-11-12

Similar Documents

Publication Publication Date Title
CN111045806A (en) Method and system for realizing delay message queue
CN113645578B (en) Method and device for preventing repeated sending of information and storage medium
CN112398726A (en) Receipt information processing method, system and storage medium for push message
US20070050447A1 (en) Method and device arrangement for managing a client/server environment
CN110389976B (en) Multi-interface data scheduling method and device
CN113794998B (en) Information sending method and device based on distributed lock and storage medium
CN106550021B (en) Push method and device for push message
CN101510872B (en) Remote customer dialing authentication service client terminal, server and transmission/acceptance method
CN113794999B (en) Short message distribution method, device and storage medium
CN110719145B (en) Method and device for sending read receipt and computer readable storage medium
CN108428182B (en) Development platform device, method for acquiring policy number, and computer-readable storage medium
CN110971535B (en) Communication congestion control method, device, equipment and storage medium
CN113076380B (en) Data synchronization method, device, system, equipment and storage medium
CN110493735B (en) Short message processing method and device
CN114331465A (en) Commodity tracing method and device based on block chain, terminal equipment and storage medium
CN103678614A (en) Information processing method for unlocking industry security administration
CN110837427B (en) Method for preventing cache breakdown based on queue sorting task mechanism
CN113596105A (en) Content acquisition method, edge node and computer-readable storage medium
CN114221925A (en) Message pushing method and device, electronic equipment and storage medium
CN111901472A (en) Incoming call enhanced display method, server and user terminal
CN111309744A (en) Object processing method and device, electronic equipment and computer readable storage medium
CN113138862A (en) Message processing method, server, device, system and storage medium
CN111193789A (en) Subscription information pushing method and device, computer equipment and readable storage medium
CN110727554A (en) Data monitoring method, device and system
CN115334466B (en) Message sending method and device, electronic equipment and storage medium

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
GR01 Patent grant
GR01 Patent grant