Information sending method and device, computer device and computer readable storage medium
By generating a message sending identifier and using a distributed lock and the `SET` command in a Redis database, the problem of abnormal personnel repeatedly sending SMS messages was solved, improving user experience and security.
Patent Information
- Application Number
- CN202211379807.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-04
- Publication Date
- 2026-01-16
- Estimated Expiration
- 2042-11-04
AI Technical Summary
In existing technologies, malicious actors can attack SMS sending interfaces using high-concurrency methods, resulting in repeated sending of SMS verification codes and a poor user experience.
By generating a message sending identifier, a distributed lock and the `set` command in a Redis database are used to control the SMS sending process and prevent duplicate sending.
It effectively prevents duplicate SMS messages, improves user experience, reduces SMS sending costs, and prevents SMS bombing by malicious individuals.
Smart Images

Figure CN115967916B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to an information sending method and device, computer equipment and computer readable storage medium. BACKGROUND
[0002] At present, all channels and processes of credit card application need mobile phone verification code, and more and more companies use the SMS service platform to manage all SMS sending businesses in the company. With the continuous development and progress of science and technology, some abnormal personnel will attack the SMS sending interface through abnormal means, send a large number of SMS verification codes to the same mobile phone number, or send verification codes to all mobile phone numbers. Especially in the high-concurrency SMS scenario, it is difficult to prevent the attack on the interface. SUMMARY
[0003] Therefore, the present application aims to overcome the deficiencies in the prior art and provide an information sending method and device, computer equipment and computer readable storage medium applicable to the field of financial technology or other technical fields.
[0004] The present application provides the following technical solutions:
[0005] In a first aspect, the present application provides an information sending method, comprising:
[0006] generating an information sending identifier according to the receiver's mobile phone number and the SMS content;
[0007] adding a distributed lock to the information sending identifier and storing the locked information sending identifier in a Redis database;
[0008] executing a set command set in the Redis database on the information sending identifier to obtain a return result, and if the return result is passed, sending the SMS content to the receiver's mobile phone number.
[0009] Further, the generating an information sending identifier according to the receiver's mobile phone number and the SMS content comprises:
[0010] md5 encrypting the receiver's mobile phone number and the SMS content to obtain an md5 value, and taking the md5 value as the information sending identifier.
[0011] Further, before the adding a distributed lock to the information sending identifier and storing the locked information sending identifier in a Redis database, the method further comprises:
[0012] counting the number of times the receiver's mobile phone number receives the SMS content within a preset time to generate a number of times value;
[0013] The expiration value is generated by counting the time that the receiver's mobile phone receives the short message content exceeding the preset time.
[0014] The number of times, the expiration value and the preset time are integrated to generate a set command set in the Redis database.
[0015] Further, after the set command set in the Redis database is executed on the information sending identifier to obtain a return result, the method further includes:
[0016] If the return result is not passed, an error is reported to a background short message sending interface, and the short message content is not sent to the receiver's mobile phone.
[0017] Further, the information sending method further includes:
[0018] When the number of times exceeds a preset number of times threshold, a short message alarm is triggered to perform black list management on a sender of the short message content.
[0019] Further, the information sending method further includes:
[0020] The preset number of times threshold is stored in a local database.
[0021] It is judged whether the current date is in an active period, if yes, the preset number of times threshold is increased, and if not, the preset number of times threshold is decreased.
[0022] Further, the short message content includes one or more combinations of text, picture, voice and video.
[0023] In a second aspect, an information sending device is provided in the embodiments of the present disclosure, and the device includes:
[0024] An identifier generation module is configured to generate an information sending identifier according to a receiver's mobile phone and short message content.
[0025] An identifier storage module is configured to add a distributed lock to the information sending identifier, and store the locked information sending identifier in a Redis database.
[0026] An information sending module is configured to execute a set command set in the Redis database on the information sending identifier to obtain a return result, and if the return result is passed, send the short message content to the receiver's mobile phone.
[0027] In a third aspect, a computer device is provided in the embodiments of the present disclosure, including a memory and a processor, the memory stores a computer program, and the processor executes the computer program to realize the steps of the information sending method in the first aspect.
[0028] In a fourth aspect, the present disclosure provides a computer readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the information sending method in the first aspect.
[0029] Embodiments of the present application have the following advantages:
[0030] The information sending method provided by the embodiments of the present application generates an information sending identifier according to a receiver's mobile phone number and short message content, adds a distributed lock to the information sending identifier, stores the locked information sending identifier in a Redis database, executes a set command set in the Redis database on the information sending identifier to obtain a return result, and sends the short message content to the receiver's mobile phone number if the return result is passed. Through the above method, the problem that an abnormal person repeatedly sends the same short message to a user in a short time by means of high concurrency to bombard a short message sending interface is solved, the user is prevented from receiving multiple same short messages, and the user experience is improved.
[0031] In order to make the above objectives, characteristics and advantages of the present application more apparent and easy to understand, the following preferred embodiments are described in detail below, and the accompanying drawings are referred to, and the detailed description is as follows. BRIEF DESCRIPTION OF DRAWINGS
[0032] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments, and it should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as a limitation to the scope, and for those skilled in the art, other related drawings can also be obtained without creative labor on the basis of these drawings.
[0033] Figure 1 A flow chart of an information sending method provided by the embodiments of the present application is shown;
[0034] Figure 2 A flow chart of generating a set command provided by the embodiments of the present application is shown;
[0035] Figure 3 A flow chart of another information sending method provided by the embodiments of the present application is shown;
[0036] Figure 4 A structural schematic diagram of an information sending device provided by the embodiments of the present application is shown;
[0037] Figure 5 A hardware architecture schematic diagram of a computer device provided by the embodiments of the present application is shown. DETAILED DESCRIPTION
[0038] Embodiments of the present application are described in detail below with reference to several drawings. The embodiments described below are illustrative only and are not intended to limit the present application, as the present application can be embodied in various forms.
[0039] It should be noted that when an element is referred to as being "on" another element, it can be directly on the other element or intervening elements can also be present. In contrast, when an element is referred to as being "directly on" another element, there are no intervening elements present. It will be understood that the terms "vertical", "horizontal", "left", "right", and the like as used herein are used for explanation purposes only and are not intended to limit the scope of the present application.
[0040] In the present application, unless otherwise explicitly specified and limited, the terms "mounting", "connecting", "connecting", "fixing" and the like should be understood broadly, for example, it can be fixedly connected, or it can be detachably connected, or it can be integrated; it can be mechanically connected, or it can be electrically connected; it can be directly connected, or it can be indirectly connected through an intermediate medium; it can be the internal communication of two elements or the interaction relationship between two elements. For those skilled in the art, the specific meaning of the above terms in the present application can be understood according to the specific circumstances.
[0041] In addition, the terms "first", "second" are only for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Therefore, the features defined as "first", "second" can explicitly or implicitly include one or more of the features. In the description of the present application, the meaning of "multiple" is two or more, unless otherwise explicitly specified and limited.
[0042] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in the description of the specification of the template is only for the purpose of describing specific embodiments and is not intended to limit the present application. The term "and / or" used herein includes any and all combinations of one or more related listed items.
[0043] In the prior art, the setnx method of redis is generally used, but the setnx method cannot set the expiration time, and an expx operation needs to be executed again after the setnx method to release the lock. The two separate commands are atomic operations, and when they are placed together, they are not atomic operations. If the first command is executed, the system is out of order, and the second command is not executed, which may cause a deadlock phenomenon.
[0044] Therefore, the present application aims to overcome the deficiencies in the prior art and provides an information sending method, device, computer equipment and computer readable storage medium.
[0045] Embodiment 1
[0046] As shown in the flowchart of an information sending method in the embodiments of the present application, the information sending method provided by the embodiments of the present application includes the following steps S110-S130: Figure 1 Step S110, generating an information sending identifier according to the receiver's mobile phone number and the short message content.
[0047] Specifically, in the embodiments of the present application, the short message service platform provides a short message sending interface to the background calling, and the background realizes the sending of information by calling the short message sending interface provided by the short message service platform. After receiving the request of sending information through the short message sending interface, the background acquires the short message content (including one or more combinations of text, picture, voice and video) and the receiver's mobile phone number to be sent and saves them into the local database. The information sending identifier is generated by the md5 algorithm, and the receiver's mobile phone number and the short message content are saved as a file in the following manner: receiver's mobile phone number + short message content, such as "12300001234 verification code short message". Then, the saved file is calculated by the md5 algorithm to obtain a 32-bit hexadecimal string (i.e. md5 value), and the md5 value is taken as the information sending identifier. It can be understood that the md5 algorithm is only an example, and other similar encryption algorithms can also be used for implementation, which is not limited here.
[0048] The md5 value of the same file obtained by the md5 algorithm is the same, so the information sending identifier generated by receiving the same short message content and receiver's mobile phone number within a period of time is also the same. Therefore, it can be judged whether the same short message content is repeatedly sent to the same receiver's mobile phone number within a short period of time by judging the information sending identifier (md5 value), and thus the user receiving multiple same short messages is avoided, thereby improving the user experience.
[0049] Step S120, adding a distributed lock to the information sending identifier and storing the locked information sending identifier into the Redis database.
[0050] Further, the information sending identifier is subjected to the distributed lock, and only after the distributed lock is successful, the information sending identifier can be stored into the Redis database. If the distributed lock fails, it indicates that the content in the information sending identifier has been processed by other threads, or the information in the information sending identifier is repeated information.
[0051] Figure 2 As shown, the above distributed lock is implemented by the set command of the Redis database, and the generation steps of the set command are as follows:
[0052] In step S121, the number of times that the receiver's mobile phone receives the short message content within the preset time is counted to generate a number of times value.
[0053] In step S122, the overdue time of the receiver's mobile phone receiving the short message content beyond the preset time is counted to generate an overdue value.
[0054] In step S123, the number of times value, the overdue value, and the preset time are integrated to generate the set command set in the Redis database.
[0055] Specifically, the number of times that the receiver's mobile phone receives the short message content within the preset time and the overdue time of the receiver's mobile phone receiving the short message content beyond the preset time are counted, and the two are integrated to generate the set command set in the Redis database. For example, the number of times that the receiver's mobile phone receives the short message content within the preset time is 8 times, the overdue time of the receiver's mobile phone receiving the short message content beyond the preset time is 120 seconds, and the preset time is 60 seconds, and the set command is (8, 120, 60).
[0056] In this embodiment, by distributing the information sending identifier, the problem of repeated sending of the same short message to the user by multiple short message platform threads is solved, the short message sending cost is reduced, the user receives multiple same short message content is avoided, and the user experience is improved.
[0057] In step S130, the set command set in the Redis database is executed on the information sending identifier to obtain a result. If the return result is passed, the short message content is sent to the receiver's mobile phone.
[0058] Specifically, the corresponding set command set in the Redis database is executed on the information sending identifier, and a return result is obtained. If the return result is passed, it means that the set command execution is successful, indicating that the content in the information sending identifier is distributed, and the time of sending the short message content does not exceed the preset time, and the number of times is within the preset number of times threshold. Next, the short message content is sent to the receiver's mobile phone. If the return result is not passed, it means that the set command execution fails, indicating that the content in the information sending identifier is not distributed, or the time of sending the short message content exceeds the preset time, or the number of times exceeds the preset number of times threshold. At this time, an error is reported to the background short message sending interface, and the short message content is not sent to the receiver's mobile phone.
[0059] The set command is simple and easy to understand, and is not prone to deadlock. The preset time and preset number threshold can be set according to actual conditions, effectively solving the problem that an abnormal person repeatedly sends the same short message content to a user in a short time by means of high concurrency, thereby avoiding the user from receiving multiple identical short messages, and improving the user experience.
[0060] In an optional embodiment, the information sending method further includes:
[0061] When the number of times of receiving the short message content exceeds the preset number threshold, triggering a short message alarm to blacklist the sender of the short message content.
[0062] Further, when the number of times of receiving the short message content by the recipient mobile phone within the preset time exceeds the preset number threshold, it indicates that the recipient mobile phone is subjected to short message bombing by an abnormal person. At this time, a short message alarm is triggered to blacklist the sender of the short message content, and the IP address of the sender is listed in the blacklist, which can effectively prevent other recipient mobile phones from being subjected to short message bombing.
[0063] In an optional embodiment, as shown in Figure 3 The information sending method further includes:
[0064] Step S210: storing the preset number threshold in a local database;
[0065] Step S220: determining whether the current date is in an active period. If yes, the preset number threshold is increased; if no, the preset number threshold is decreased.
[0066] It can be understood that the preset number threshold is stored in the local database and dynamically adjusted through a background management website. It is determined whether the current date is in an active period, that is, whether the current date is in a time period of an active promotion. For example, the time period of the bank's "apply for a credit card to give a gift" activity is from May 1, 2022 to June 1, 2022, so the month from May 1, 2022 to June 1, 2022 is in the active period. If it is in the active period, it indicates that the bank needs to focus on promoting the activity, so the number of information to be sent will increase accordingly, and the preset number threshold can be appropriately increased at this time. If the current date is not in the active period, it indicates that the bank has no activity to promote at this time, so the preset number threshold can be appropriately decreased. Through dynamic adjustment of the preset number threshold, real-time and flexible configuration can be performed according to actual conditions, thereby improving the user experience.
[0067] The embodiments of the present application have the following advantages:
[0068] The information sending method provided in the embodiment of the application comprises the following steps: generating an information sending identifier according to a receiver mobile phone number and short message content; adding a distributed lock to the information sending identifier, and storing the information sending identifier after being locked into a Redis database; executing a set command set in the Redis database on the information sending identifier to obtain a return result, and sending the short message content to the receiver mobile phone number if the return result is passed. Through the above method, the problem that an abnormal person repeatedly sends the same short message to a user in a short time by means of high concurrency to bombard a short message sending interface is solved, the user receives multiple same short messages is avoided, and the user experience is improved.
[0069] Embodiment 2
[0070] As shown in the structure schematic diagram of the information sending device 200 in the embodiment of the application, the device comprises: Figure 4 An identifier generation module 210 is configured to generate an information sending identifier according to a receiver mobile phone number and short message content.
[0071] An identifier storage module 220 is configured to add a distributed lock to the information sending identifier, and store the information sending identifier after being locked into a Redis database.
[0072] An information sending module 230 is configured to execute a set command set in the Redis database on the information sending identifier to obtain a return result, and send the short message content to the receiver mobile phone number if the return result is passed.
[0073] Optionally, the information sending device can further comprise:
[0074] An encryption module is configured to perform md5 encryption on the receiver mobile phone number and the short message content to obtain an md5 value, and use the md5 value as the information sending identifier.
[0075] Optionally, the information sending device can further comprise:
[0076] A first generation module is configured to count the number of times that the receiver mobile phone number receives the short message content within a preset time, and generate a number of times value.
[0077] A second generation module is configured to count an expired time in which the receiver mobile phone number receives the short message content beyond the preset time, and generate an overdue value.
[0078] A set command generation module is configured to integrate the number of times value, the overdue value and the preset time to generate a set command set in the Redis database.
[0079]
[0080] Optionally, the information sending device can further include:
[0081] The error reporting module is configured to report an error to a background short message sending interface and not send the short message content to the receiving party mobile phone number if the return result is not passed.
[0082] Optionally, the information sending device can further include:
[0083] The blacklist management module is configured to trigger short message alarm to manage the sender of the short message content as a black list when the number of times exceeds the preset number of times threshold.
[0084] Optionally, the information sending device can further include:
[0085] The threshold storage module is configured to store the preset number of times threshold in a local database.
[0086] The dynamic adjustment module is configured to determine whether the current date is in an active period, and if so, increase the preset number of times threshold, and if not, decrease the preset number of times threshold.
[0087] Embodiments of the present application have the following advantages:
[0088] The information sending device provided by the embodiments of the present application solves the problem of repeated sending of the same short message to users in a short period of time by abnormal personnel through high-concurrency means to bombard the short message sending interface, avoids the user from receiving multiple same short messages, and improves the user experience.
[0089] Embodiment 3
[0090] Figure 5 A hardware architecture schematic diagram of a computer device provided by the present application is shown, the computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the steps of the information sending method of embodiment 1 when executing the computer program.
[0091] In this embodiment, the computer device 300 is a device capable of automatically performing numerical calculation and / or information processing according to pre-set or stored instructions. For example, it can be a rack server, a blade server, a tower server or a cabinet server (including a standalone server or a server cluster composed of multiple servers) and the like. As shown in the figure, the computer device 300 at least includes but is not limited to a memory 310, a processor 320 and a network interface 330 which can be linked and communicated through a system bus. Among them: Figure 5
[0092] The memory 310 includes at least one type of computer-readable storage media, such as a flash memory, a hard disk, a multimedia card (e.g., SD or DX memory, etc.), a random access memory (RAM), a static random access memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, and the like. In some embodiments, the memory 310 can be an internal memory module of the computer device 300, such as a hard disk or a memory of the computer device 300. In other embodiments, the memory 310 can also be an external memory device of the computer device 300, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, and the like. Of course, the memory 310 can include both an internal memory module and an external memory device of the computer device 300. In this embodiment, the memory 310 is generally used to store an operating system and various application programs installed in the computer device 300, such as program codes of a video playing method, and the like. In addition, the memory 310 can also be used to temporarily store various data that have been output or will be output.
[0093] The processor 320 can be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip in some embodiments. The processor 320 is generally used to control the overall operation of the computer device 300, such as performing control and processing related to data interaction or communication of the computer device 300, and the like. In this embodiment, the processor 320 is used to run program codes or process data stored in the memory 310.
[0094] The network interface 330 can include a wireless network interface or a wired network interface, which is generally used to establish a communication link between the computer device 300 and other computer devices. For example, the network interface 330 is used to connect the computer device 300 with an external terminal through a network, to establish a data transmission channel and a communication link between the computer device 300 and the external terminal, and the like. The network can be an Intranet, the Internet, a Global System of Mobile communication (GSM), a Wideband Code Division Multiple Access (WCDMA), a 4G network, a 5G network, Bluetooth, Wi-Fi, and the like wireless or wired network.
[0095] It should be noted that, Figure 5 Only the computer device with the components 310-330 is shown, but it should be understood that all the shown components are not required to be implemented, and more or fewer components can be alternatively implemented.
[0096] In the present embodiment, the information sending method stored in the memory 310 can also be divided into one or more program modules, and executed by one or more processors (the processor 320 in the present embodiment) to complete the present application.
[0097] Embodiment 4
[0098] The present embodiment also provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the steps of the information sending method in the embodiments.
[0099] In this embodiment, the computer readable storage medium includes a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a random access memory (RAM), a static random access memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the computer readable storage medium can be an internal storage unit of the computer device, such as a hard disk or a memory of the computer device. In other embodiments, the computer readable storage medium can also be an external storage device of the computer device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device. Of course, the computer readable storage medium can also include both the internal storage unit and the external storage device of the computer device. In this embodiment, the computer readable storage medium is generally used to store an operating system and various application software installed on the computer device. In addition, the computer readable storage medium can also be used to temporarily store various data that have been output or will be output.
[0100] In all examples shown and described herein, any specific values should be interpreted as merely exemplary and not as a limitation, and thus other examples of the example embodiments can have different values.
[0101] It should be noted that like reference numerals and letters refer to like items in the several views of the drawings, and as such definitions further need not be repeated and explained in subsequent views.
[0102] The above-described embodiments are merely illustrative of several embodiments of the present application, and the description is relatively specific and detailed, but should not be understood as limiting the scope of the present application. It should be noted that for those skilled in the art, several modifications and improvements can be made without departing from the concept of the present application, and these are within the scope of the present application.
Claims
1. An information transmission method characterized by comprising: The method comprises the following steps: Splicing a receiver mobile phone number and a short message content into a string according to the format of "receiver mobile phone number + short message content", and performing MD5 encryption on the spliced string to obtain an MD5 value, and taking the MD5 value as an information sending identifier; Counting the number of times that the receiver mobile phone number receives the short message content within a preset time to generate a number of times value; Counting the overdue time that the receiver mobile phone number receives the short message content beyond the preset time to generate an overdue value; Integrating the number of times value, the overdue value and the preset time to generate a set command set in a Redis database; Adding a distributed lock to the information sending identifier, and storing the locked information sending identifier into the Redis database; Executing the set command set in the Redis database on the information sending identifier to obtain a return result, if the return result is passed, sending the short message content to the receiver mobile phone number; if the return result is not passed, the set command execution fails, and an error is reported to a background short message sending interface, and the short message content is not sent to the receiver mobile phone number.
2. The information transmission method according to claim 1, characterized by, The method further comprises: When the number of times value exceeds a preset number of times threshold, triggering a short message alarm to perform black list management on a sender of the short message content.
3. The information transmission method according to claim 2, characterized by, The method further comprises: Storing the preset number of times threshold in a local database; Judging whether the current date is in an active period, if yes, increasing the preset number of times threshold; if no, decreasing the preset number of times threshold.
4. The information transmission method according to claim 1, characterized by, The short message content comprises one or more combinations of text, picture, voice and video.
5. An information transmitting apparatus characterized by comprising: The device comprises: An identifier generation module for splicing a receiver mobile phone number and a short message content into a string according to the format of "receiver mobile phone number + short message content", and performing MD5 encryption on the spliced string to obtain an MD5 value, and taking the MD5 value as an information sending identifier; A first generation module for counting the number of times that the receiver mobile phone number receives the short message content within a preset time to generate a number of times value; A second generation module for counting the overdue time that the receiver mobile phone number receives the short message content beyond the preset time to generate an overdue value; A set command generation module for integrating the number of times value, the overdue value and the preset time to generate a set command set in a Redis database; An identifier storage module for adding a distributed lock to the information sending identifier, and storing the locked information sending identifier into the Redis database; An information sending module for executing the set command set in the Redis database on the information sending identifier to obtain a return result, if the return result is passed, sending the short message content to the receiver mobile phone number; An error reporting module for reporting an error to a background short message sending interface if the return result is not passed, and not sending the short message content to the receiver mobile phone number.
6. A computer device, comprising: An information sending method is provided, comprising: a computer readable storage medium storing a computer program, wherein the computer program is executed by a processor to implement the steps of the information sending method of any one of claims 1-4.
7. A computer readable storage medium characterized in that, The computer readable storage medium stores a computer program, wherein the computer program is executed by a processor to implement the steps of the information sending method of any one of claims 1-4.
Citation Information
Patent Citations
Short message issuing duplicate eliminating method and system
CN113301516A
Information sending method and device based on distributed lock, and storage medium
CN113794998A