CN106936688B - Notification sending method and device - Google Patents

Notification sending method and device Download PDF

Info

Publication number
CN106936688B
CN106936688B CN201511021406.9A CN201511021406A CN106936688B CN 106936688 B CN106936688 B CN 106936688B CN 201511021406 A CN201511021406 A CN 201511021406A CN 106936688 B CN106936688 B CN 106936688B
Authority
CN
China
Prior art keywords
notification
sending
sent
message queue
threads
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
CN201511021406.9A
Other languages
Chinese (zh)
Other versions
CN106936688A (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.)
Beijing Gridsum Technology Co Ltd
Original Assignee
Beijing Gridsum 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 Beijing Gridsum Technology Co Ltd filed Critical Beijing Gridsum Technology Co Ltd
Priority to CN201511021406.9A priority Critical patent/CN106936688B/en
Publication of CN106936688A publication Critical patent/CN106936688A/en
Application granted granted Critical
Publication of CN106936688B publication Critical patent/CN106936688B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L51/00User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
    • H04L51/21Monitoring or handling of messages
    • H04L51/224Monitoring or handling of messages providing notification on incoming messages, e.g. pushed notifications of received messages
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/12Avoiding congestion; Recovering from congestion

Abstract

The application discloses a notification sending method and device. Wherein, the method comprises the following steps: acquiring notifications to be sent from a message queue, wherein all the notifications to be sent are pre-added to the message queue; judging whether the number of sending threads is smaller than the maximum concurrency degree or not, wherein the sending threads are threads for executing notification sending operation; and when the number of the sending threads is judged to be less than the maximum concurrency degree, creating a new sending thread, and sending a notification to be sent through the new sending thread. The method and the device solve the technical problem that the notification transmission is blocked due to the fact that the number of the notifications transmitted in parallel is too large in the related technology.

Description

Notification sending method and device
Technical Field
The present application relates to the field of data processing, and in particular, to a notification sending method and apparatus.
Background
Many existing systems (e.g., website data analysis systems) have a function of sending mails, for example, periodic reports are configured in the system by a user, the system runs the reports at a fixed time every day, queries data in a database, outputs the data to a report template, generates a report, and finally sends the report to a specified user through a mail. Each system is usually configured with a plurality of periodic reports, which are executed in parallel.
In the case of a very large number of reports, for example, up to thousands of reports, when the reports are executed concurrently, hundreds of reports may be required to send mails at the same time. The concurrency of sending mails to each mailbox by the mail server is limited, and is usually very low, for example, only 10 mails can be sent at the same time, which causes a great amount of blocking of sending report mails, and also causes overtime after a period of time, and retries after overtime, and if a great amount of report mails are retried, the burden of the mail server is further increased, a vicious circle is involved, and the performance of the mail server is further lowered. In addition, short messages, WeChat messages, and the like also have the above-described problems when high concurrency is required.
An effective solution is not provided at present for the problem of notification transmission blockage caused by excessive notification quantity transmitted in parallel in the related art.
Disclosure of Invention
The application mainly aims to provide a notification sending method and a notification sending device, so as to solve the problem that the notification sending is blocked due to the fact that the number of notifications sent in parallel is too large in the related art.
In order to achieve the above object, according to an aspect of the present application, a notification transmission method is provided. The method comprises the following steps: acquiring notifications to be sent from a message queue, wherein all the notifications to be sent are pre-added to the message queue; judging whether the number of sending threads is smaller than the maximum concurrency degree or not, wherein the sending threads are threads for executing notification sending operation; and when the number of the sending threads is judged to be less than the maximum concurrency degree, creating a new sending thread, and sending a notification to be sent through the new sending thread.
Further, when it is determined that the number of sending threads is not less than the maximum concurrency degree, the method further includes: and waiting for a first preset time, and judging whether the number of the sending threads is less than the maximum concurrency degree again.
Further, when it is determined that the number of sending threads is less than the maximum concurrency degree, a new sending thread is created, and after the notification to be sent is sent through the new sending thread, the method further includes: detecting whether the notification to be sent is abnormal or not; and when the abnormity of the notification to be sent is detected, the notification to be sent is added to the message queue again.
Further, when it is determined that the number of sending threads is less than the maximum concurrency degree, a new sending thread is created, and after the notification to be sent is sent through the new sending thread, the method further includes: detecting whether the notification to be sent is abnormal or not; when the abnormity of the notification to be sent is detected, judging whether the sending times of the notification to be sent reaches a preset value; when the sending times of the to-be-sent notification are judged to be not equal to a preset value, adding 1 to the sending times of the to-be-sent notification, and adding the to-be-sent notification to the message queue again; and when the sending times of the to-be-sent notification is judged to reach a preset value, recording the to-be-sent notification, and outputting abnormal information.
Further, before obtaining the notification to be sent from the message queue, the method further includes: detecting the state of an operation switch, wherein the state of the operation switch comprises an opening state and a closing state, the opening state is used for indicating to execute notification sending operation, and the closing state is used for indicating to stop executing the notification sending operation; and when the operation switch is detected to be in an on state, judging whether the message queue is empty, wherein when the message queue is judged not to be empty, obtaining a notification to be sent from the message queue, and when the message queue is judged to be empty, waiting for a second preset time, and judging whether the message queue is empty again.
Further, after all the notifications to be sent are added to the message queue, the method further includes: judging whether the message queue is empty; and setting the state of the operation switch to be in a closing state when the message queue is judged to be empty.
In order to achieve the above object, according to another aspect of the present application, a notification transmission apparatus is provided. The device includes: the device comprises an acquisition unit, a message queue and a message sending unit, wherein the acquisition unit is used for acquiring the to-be-sent notifications from the message queue, and all the to-be-sent notifications are pre-added to the message queue; the device comprises a first judging unit, a second judging unit and a third judging unit, wherein the first judging unit is used for judging whether the number of sending threads is smaller than the maximum concurrency degree or not, and the sending threads are threads for executing notification sending operation; and the sending unit is used for creating a new sending thread when the number of the sending threads is judged to be less than the maximum concurrency degree, and sending the notification to be sent through the new sending thread.
Further, the apparatus further comprises: and the second judging unit is used for waiting for the first preset time and judging whether the number of the sending threads is less than the maximum concurrency degree again when judging that the number of the sending threads is not less than the maximum concurrency degree.
Further, the apparatus further comprises: the first detection unit is used for detecting whether the notification to be sent is abnormal or not; the third judging unit is used for judging whether the sending times of the notification to be sent reach a preset value or not when the fact that the notification to be sent is abnormal is detected; the adding unit is used for adding 1 to the sending times of the notification to be sent when the sending times of the notification to be sent is judged not to reach the preset value, and adding the notification to be sent to the message queue again; and the output unit is used for recording the notification to be sent and outputting abnormal information when judging that the sending times of the notification to be sent reaches a preset value.
Further, the apparatus further comprises: the second detection unit is used for detecting the state of the running switch, wherein the state of the running switch comprises an on state and an off state, the on state is used for indicating to execute the notification sending operation, and the off state is used for indicating to stop executing the notification sending operation; and the fourth judging unit is used for judging whether the message queue is empty or not when the running switch is detected to be in the on state, wherein the to-be-sent notification is acquired from the message queue when the message queue is judged not to be empty, and the message queue is judged to be empty again by waiting for a second preset time.
The method comprises the steps that the to-be-sent notifications are obtained from a message queue, wherein all the to-be-sent notifications are added to the message queue in advance; judging whether the number of sending threads is smaller than the maximum concurrency degree or not, wherein the sending threads are threads for executing notification sending operation; and when the number of the sending threads is judged to be smaller than the maximum concurrency degree, a new sending thread is created, and the notification to be sent is sent through the new sending thread.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this application, illustrate embodiments of the application and, together with the description, serve to explain the application and are not intended to limit the application. In the drawings:
fig. 1 is a flowchart of a notification transmission method according to an embodiment of the present application;
fig. 2 is a flowchart of a notification transmission method according to yet another embodiment of the present application; and
fig. 3 is a schematic diagram of a notification transmission apparatus according to an embodiment of the present application.
Detailed Description
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only partial embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and claims of this application and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It should be understood that the data so used may be interchanged under appropriate circumstances such that embodiments of the application described herein may be used. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
According to an embodiment of the present application, a notification transmission method is provided. Fig. 1 is a flowchart of a notification transmission method according to an embodiment of the present application, and as shown in fig. 1, the method includes steps S102 to S106 as follows:
step S102, obtaining the notification to be sent from the message queue, wherein all the notifications to be sent are added to the message queue in advance.
The to-be-sent notification in the embodiments of the present application may be a mail, a short message, qq information, a wechat information, and the like, and all the embodiments of the present application are described below with a mail to be sent as an example.
According to the embodiment of the application, when the notification needs to be sent, the notification to be sent is added to the message queue in advance for queuing. Specifically, taking an example that a website data analysis system sends a periodic report to a user at regular time, when the website data analysis system needs to send the periodic report to the user, querying data in a database, then outputting the data to a report template to generate a report, and generating a mail to be sent according to the report and adding the mail to be sent to a message queue; when the report forms need to be sent to a plurality of users at the same time, the report forms corresponding to the users are respectively generated, a plurality of mails to be sent are respectively generated according to the report forms, and the mails to be sent are all added into a message queue for queuing.
According to the embodiment of the application, after the to-be-sent notifications are all added to the message queue in advance, all the to-be-sent notifications are sequentially acquired from the message queue and sent.
Step S104, judging whether the number of sending threads is less than the maximum concurrency degree, wherein the sending threads are threads for executing notification sending operation.
The maximum concurrency degree in the embodiment of the present application refers to the maximum number of notifications that can be sent in parallel, and optionally, the value of the maximum concurrency degree may be set according to the concurrency degree of the notifications sent by the notification server, for example, when sending a mail, the concurrency degree of the mail sent by the mail server is 10, the value of the maximum concurrency degree may be set to 10, so that the mail sender may be utilized maximally, and the mail sending efficiency may be improved.
Specifically, the number of sending threads may be counted by setting a counter, or an empty sending thread set may be created in advance, and the number of elements in the sending thread set is limited to the maximum concurrency, after a sending thread is created each time, the sending thread is added to the sending thread set, and after the sending thread completes notification sending, the sending thread is deleted from the sending thread set, so that the number of the current sending threads may be obtained quickly by counting the number of sending threads in the sending thread set.
According to the embodiment of the application, whether a new sending thread can be created to send the notification is determined by judging whether the number of the sending threads reaches the maximum concurrency degree, so that the notification sending blockage caused by excessive notifications sent in parallel can be avoided.
And step S106, when the number of the sending threads is judged to be less than the maximum concurrency degree, a new sending thread is created, and the notice to be sent is sent through the new sending thread.
Specifically, taking sending a mail as an example for explanation, when it is determined that the number of sending threads is less than the maximum concurrency degree, it is determined that the current mail server is not in the maximum load state, at this time, a new sending thread may be created, and the mail to be sent, which is currently acquired from the message queue, is sent out through the new sending thread, and when it is determined that the number of sending threads is not less than the maximum concurrency degree, it is determined that the current mail server is in the maximum load state, and in order to avoid operating the mail server to crash, at this time, a new sending thread should not be created to send the mail. Optionally, when it is determined that the number of sending threads is not less than the maximum concurrency degree, the method further includes: and waiting for a first preset time, and judging whether the number of the sending threads is less than the maximum concurrency degree again.
The sending thread automatically releases the resources when the notification sending is completed, so that the number of the sending threads is updated in real time, when the number of the sending threads is judged not to be smaller than the maximum concurrency degree at present, the sending thread can wait for a first preset time (for example, wait for 5 seconds), judge whether the number of the sending threads is smaller than the maximum concurrency degree again, and repeat the above process until the number of the sending threads is smaller than the maximum concurrency degree.
The method comprises the steps that the to-be-sent notifications are obtained from a message queue, wherein all the to-be-sent notifications are added to the message queue in advance; judging whether the number of sending threads is smaller than the maximum concurrency degree or not, wherein the sending threads are threads for executing notification sending operation; and when the number of the sending threads is judged to be smaller than the maximum concurrency degree, a new sending thread is created, and the notification to be sent is sent through the new sending thread.
Preferably, in order to avoid the problem of missed notification due to abnormal notification transmission, when the number of the transmission threads is determined to be less than the maximum concurrency degree, a new transmission thread is created, and after the notification to be sent is sent through the new transmission thread, the method further includes: detecting whether the notification to be sent is abnormal or not; and when the abnormity of the notification to be sent is detected, the notification to be sent is added to the message queue again.
Because each time of sending the notification is not necessarily successful, in order to avoid the problem of missed sending of the notification due to abnormal sending of the notification, in the embodiment of the application, after the notification is sent through the sending thread, whether the sending of the notification to be sent is abnormal is detected, for example, whether the notification to be sent is successfully sent to the recipient address is detected, when the sending of the notification to be sent is detected to be abnormal, the notification to be sent is added to the message queue again to be queued again for sending again, and the sending thread corresponding to the notification to be sent with abnormal sending is deleted. It should be noted that, when it is detected that the notification to be sent is successfully sent, the sending thread corresponding to the notification to be sent may be directly released.
According to the embodiment of the application, the notification to be sent can be added into the sending queue again to be sent again when the notification to be sent is abnormal every time, so that the problem of notification missing caused by abnormal notification sending can be avoided.
Preferably, in order to avoid the problem of missed notification due to abnormal notification transmission, when the number of the transmission threads is determined to be less than the maximum concurrency degree, a new transmission thread is created, and after the notification to be sent is sent through the new transmission thread, the method further includes: detecting whether the notification to be sent is abnormal or not; when the abnormity of the notification to be sent is detected, judging whether the sending times of the notification to be sent reaches a preset value; when the sending times of the to-be-sent notification are judged to be not equal to a preset value, adding 1 to the sending times of the to-be-sent notification, and adding the to-be-sent notification to the message queue again; and when the sending times of the to-be-sent notification is judged to reach a preset value, recording the to-be-sent notification, and outputting abnormal information.
Due to the existence of some notifications, even if the notification is sent for multiple times or the notification fails to be sent, for example, the sending address is wrong, and at this time, endless repeated sending cannot solve the problem, but occupies the resources of the notification server, and affects the efficiency of the notification server in sending the notification. In the embodiment of the application, the number of times of sending the notification is limited, when it is detected that there is an abnormality in sending the notification to be sent, it is first determined whether the number of times of sending the notification to be sent reaches a preset value, for example, the preset value is set to 3, and if the number of times of sending the notification to be sent does not reach the preset value, the notification to be sent is added to the message queue again, and the number of times of sending the notification to be sent is added by 1; if the sending times of the to-be-sent notification reach a preset value, the to-be-sent notification is recorded, and abnormal information is output, so that an operator can analyze the reason for the failure of sending the to-be-sent notification according to the abnormal information, and can send the to-be-sent notification manually, on one hand, the to-be-sent notification which is sent abnormally can be prevented from occupying notification server resources for a long time, and on the other hand, the problem of notification missing can be completely avoided.
It should be noted that, in the embodiment of the present application, when there is an abnormality in each transmission of the to-be-transmitted notification, the abnormality information may be recorded, for example, in a log, and the abnormality information of each time is added to the abnormality set corresponding to the to-be-transmitted notification, and when the number of times of transmission of the to-be-transmitted notification reaches a preset value, all the abnormalities in the abnormality set are combined and output.
Preferably, before acquiring the notification to be sent from the message queue, the method further includes: detecting the state of an operation switch, wherein the state of the operation switch comprises an opening state and a closing state, the opening state is used for indicating to execute notification sending operation, and the closing state is used for indicating to stop executing the notification sending operation; and when the operation switch is detected to be in an on state, judging whether the message queue is empty, wherein when the message queue is judged not to be empty, obtaining a notification to be sent from the message queue, and when the message queue is judged to be empty, waiting for a second preset time, and judging whether the message queue is empty again.
In order to facilitate control of sending of the notification, an operation switch is provided in the embodiment of the present application, and the sending operation of the notification is executed only when the operation switch is in an on state.
In the embodiment of the application, before obtaining a notification to be sent from a message queue and sending the notification, the state of an operation switch is detected, when the operation switch is detected to be in an on state, the notification can be sent at the moment, and whether the message queue is empty is continuously judged, wherein when the message queue is judged not to be empty, the notification to be sent is obtained from the message queue, and when the message queue is judged to be empty, a second preset time, for example, 10 seconds, is waited to judge whether the message queue is empty again; when the operation switch is detected to be in the off state, the operation switch may be turned on to send a notification, or may be turned off directly. It should be noted that the system may be configured to continuously add the notification to be sent to the message queue within a preset time period, so that when the operation switch is in the on state, the system has not yet added the notification to be sent to the message queue, that is, the message queue is empty, and at this time, it may wait for a second preset time to re-determine whether the message queue is empty.
Preferably, after all the notifications to be sent are added to the message queue, the method further comprises: judging whether the message queue is empty; and setting the state of the operation switch to be in a closing state when the message queue is judged to be empty.
Specifically, after all notifications to be sent are added to the message queue, the embodiment of the present application determines whether the message queue is empty to finish sending the notifications, specifically, when it is determined that the message queue is not empty, the notifications to be sent are sequentially taken from the message queue to be sent, and when it is determined that the message queue is not empty, that is, all notifications to be sent that need to be sent in the current time period are sent, at this time, the state of the operation switch may be set to be in an off state to finish sending the notifications, so that idle running of the program can be avoided, and system resources are occupied.
Fig. 2 is a flowchart of a notification transmission method according to another embodiment of the present application, as shown in fig. 2, the method includes the following steps:
step S201, the operation switch is turned on.
In step S202, a set of sending threads is created.
The number of elements in the set of send threads is the number specified by the maximum concurrency.
In the embodiment of the present application, after the sending thread set is created in step S202, circular scanning is started by the background thread, and the scanning steps of each time are as follows, step S203 to step S219:
step S203, determine whether the operation switch is on.
I.e. whether the switch is allowed to be in an on state. And executing the step S204 when the permission switch is judged to be opened, otherwise, ending.
Step S204, judge whether the message queue is empty.
Specifically, in the embodiment of the present application, a notification entity may be predefined, where the notification entity includes notification information, sending times and an exception set, where the notification information includes information such as a sending address and a notification (that is, specific sending content), the sending times refers to the sending times of the notification to be sent, and the exception set is used to record an exception of the notification to be sent. When the notification needs to be sent, the notification entity is added to the message queue for queuing.
When the message queue is judged to be empty, the embodiment of the application shows that no notification entity needs to be sent in the current message queue, and step S205 is executed; when the message queue is determined not to be empty, it indicates that there is a notification entity in the current message queue to send, and step S206 is executed.
Step S205, wait 10 seconds.
In step S206, a notification entity is retrieved.
Step S207, determine whether the number of sending threads in the sending thread set is less than the maximum concurrency.
Specifically, when it is determined that the number of sending threads in the sending thread set is not less than the maximum concurrency degree, step S208 is executed, that is, the step S waits for 5 seconds, and it is determined again whether the number of sending threads in the sending thread set is less than the maximum concurrency degree; when it is determined that the number of sending threads in the sending thread set is less than the maximum concurrency degree, step S209 is performed.
Step S208, wait 5 seconds.
In step S209, a new transmission thread is created.
Step S210, add a new sending thread to the sending thread set.
Step S211, a notification is sent.
I.e. to start sending notifications according to the notification information.
In step S212, it is determined whether there is an abnormality.
That is, whether or not there is an abnormality in the transmission notification, for example, a transmission failure or the like is determined. When it is determined that there is a transmission abnormality, step S213 is executed, otherwise step S219 is executed.
In step S213, it is determined whether the number of transmission times reaches the maximum number of transmission times.
When it is determined that the transmission count has reached the maximum transmission count, step S214 is executed, and when it is determined that the transmission count has not reached the maximum transmission count, step S216 is executed.
Step S214, combining the exceptions in the exception set of the notification entity into a new exception and throwing the new exception.
In step S215, an abnormality is recorded in the log.
In step S216, the number of transmissions is increased by 1.
Step S217, add the exception to the exception set of the notification entity.
Step S218, the notification entity is added to the message queue again.
In step S219, the sending thread is deleted from the sending thread set.
That is, after the transmission is completed, the transmitting thread is deleted from the thread set.
It should be noted that, in the embodiment of the present application, when the background thread performs circular scanning, it is circularly determined whether the message queue is empty, when it is determined that the message queue is empty, the operation switch is turned off, and after the subsequent background scanning thread performs one cycle, it is checked that the operation switch is turned off, and the scanning thread exits the cycle.
Preferably, in order to facilitate the program call, the embodiment of the present application may define a notification manager in advance, where the following members are defined: a notification context, the context containing common configurations needed to send notifications; maximum degree of concurrency; notifying the entity queue; sending a thread set; whether to operate the switch; and sending a notification method, wherein the parameters are notification entities, and the method adds the notification entities into a notification entity queue for queuing.
From the above description, it can be seen that the concurrency of mail sending of a general mail server is very low, which is far from meeting the requirement, and high concurrency of mails is needed in many places.
It should be noted that the steps illustrated in the flowcharts of the figures may be performed in a computer system such as a set of computer-executable instructions and that, although a logical order is illustrated in the flowcharts, in some cases, the steps illustrated or described may be performed in an order different than presented herein.
According to another aspect of the embodiments of the present application, a notification transmission apparatus is provided, which may be used to execute the notification transmission method of the embodiments of the present application, and the notification transmission method of the embodiments of the present application may also be executed by the notification transmission apparatus of the embodiments of the present application.
Fig. 3 is a schematic diagram of a notification transmission apparatus according to an embodiment of the present application, and as shown in fig. 3, the apparatus includes: an acquisition unit 10, a first judgment unit 20 and a transmission unit 30.
An obtaining unit 10, configured to obtain the to-be-sent notification from the message queue, where all the to-be-sent notifications are pre-added to the message queue.
A first judging unit 20, configured to judge whether the number of sending threads is less than a maximum concurrency degree, where the sending threads are threads for performing a notification sending operation.
A sending unit 30, configured to create a new sending thread when it is determined that the number of sending threads is smaller than the maximum concurrency degree, and send a notification to be sent through the new sending thread.
The method comprises the steps that a to-be-sent notification is obtained from a message queue through an obtaining unit 10, wherein all the to-be-sent notifications are added to the message queue in advance; the first judgment unit 20 judges whether the number of sending threads, which are threads for performing notification sending operation, is less than the maximum concurrency degree; and when the sending unit 30 determines that the number of the sending threads is smaller than the maximum concurrency degree, a new sending thread is created, and the notification to be sent is sent through the new sending thread.
Optionally, the apparatus further comprises: and the second judging unit is used for waiting for the first preset time and judging whether the number of the sending threads is less than the maximum concurrency degree again when judging that the number of the sending threads is not less than the maximum concurrency degree.
Preferably, the apparatus further comprises: the first detection unit is used for detecting whether the notification to be sent is abnormal or not; the third judging unit is used for judging whether the sending times of the notification to be sent reach a preset value or not when the fact that the notification to be sent is abnormal is detected; the adding unit is used for adding 1 to the sending times of the notification to be sent when the sending times of the notification to be sent is judged not to reach the preset value, and adding the notification to be sent to the message queue again; and the output unit is used for recording the notification to be sent and outputting abnormal information when judging that the sending times of the notification to be sent reaches a preset value.
Preferably, the apparatus further comprises: the second detection unit is used for detecting the state of the running switch, wherein the state of the running switch comprises an on state and an off state, the on state is used for indicating to execute the notification sending operation, and the off state is used for indicating to stop executing the notification sending operation; and the fourth judging unit is used for judging whether the message queue is empty or not when the running switch is detected to be in the on state, wherein the to-be-sent notification is acquired from the message queue when the message queue is judged not to be empty, and the message queue is judged to be empty again by waiting for a second preset time.
The notification sending device comprises a processor and a memory, the acquisition unit, the first judgment unit, the sending unit and the like are stored in the memory as program units, and the processor executes the program units stored in the memory to realize corresponding functions.
The processor comprises a kernel, and the kernel calls the corresponding program unit from the memory. The kernel may set one or more, sending notifications by adjusting kernel parameters.
The memory may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.
The present application further provides a computer program product adapted to perform program code for initializing the following method steps when executed on a data processing device: acquiring notifications to be sent from a message queue, wherein all the notifications to be sent are pre-added to the message queue; judging whether the number of sending threads is smaller than the maximum concurrency degree or not, wherein the sending threads are threads for executing notification sending operation; and when the number of the sending threads is judged to be less than the maximum concurrency degree, creating a new sending thread, and sending a notification to be sent through the new sending thread.
The above-mentioned serial numbers of the embodiments of the present application are merely for description and do not represent the merits of the embodiments.
In the above embodiments of the present application, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed technology can be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units may be a logical division, and in actual implementation, there may be another division, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
The foregoing is only a preferred embodiment of the present application and it should be noted that those skilled in the art can make several improvements and modifications without departing from the principle of the present application, and these improvements and modifications should also be considered as the protection scope of the present application.

Claims (5)

1. A notification transmission method, comprising:
acquiring notifications to be sent from a message queue, wherein all the notifications to be sent are pre-added to the message queue;
judging whether the number of sending threads is smaller than the maximum concurrency degree or not, wherein the sending threads are threads for executing notification sending operation; and
when the number of the sending threads is judged to be smaller than the maximum concurrency degree, a new sending thread is created, and the notification to be sent is sent through the new sending thread;
when it is determined that the number of the sending threads is smaller than the maximum concurrency degree, a new sending thread is created, and after the notification to be sent is sent through the new sending thread, the method further includes: detecting whether the notification to be sent is abnormal or not; when the condition that the notification to be sent is abnormal is detected, the notification to be sent is added to the message queue again;
when the number of the sending threads is judged to be smaller than the maximum concurrency degree, a new sending thread is created, and after the notification to be sent is sent through the new sending thread, the method further comprises the following steps: detecting whether the notification to be sent is abnormal or not; when the condition that the to-be-sent notification is abnormal is detected, judging whether the sending frequency of the to-be-sent notification reaches a preset value or not; when the sending times of the to-be-sent notification are judged to be not equal to the preset value, adding 1 to the sending times of the to-be-sent notification, and adding the to-be-sent notification to the message queue again; when the sending times of the to-be-sent notification reach the preset value, recording the to-be-sent notification, and outputting abnormal information;
when the to-be-sent notification is detected to be abnormal in sending, adding the to-be-sent notification into the message queue again for queuing again for sending again, and deleting a sending thread corresponding to the to-be-sent notification with abnormal sending;
when the to-be-sent notification is sent abnormally, recording abnormal information, adding the abnormal information to an abnormal set corresponding to the to-be-sent notification, and combining and outputting all the abnormal information in the abnormal set when the sending times of the to-be-sent notification reach a preset value;
before obtaining the notification to be sent from the message queue, the method further includes: detecting the state of an operation switch, wherein the state of the operation switch comprises an on state and an off state, the on state is used for indicating to execute notification sending operation, and the off state is used for indicating to stop executing the notification sending operation; and when the running switch is detected to be in the on state, judging whether the message queue is empty, wherein when the message queue is judged not to be empty, the to-be-sent notification is obtained from the message queue, and when the message queue is judged to be empty, waiting for a second preset time, and judging whether the message queue is empty again.
2. The method of claim 1, wherein upon determining that the number of sending threads is not less than the maximum degree of concurrency, the method further comprises: and waiting for a first preset time, and judging whether the number of the sending threads is less than the maximum concurrency degree again.
3. The method of claim 1, wherein after adding all pending notifications to the message queue, the method further comprises:
judging whether the message queue is empty or not; and
and when the message queue is judged to be empty, setting the state of the operation switch to be the closing state.
4. A notification transmission apparatus, comprising:
the device comprises an acquisition unit, a sending unit and a sending unit, wherein the acquisition unit is used for acquiring the to-be-sent notifications from a message queue, and all the to-be-sent notifications are pre-added to the message queue;
the device comprises a first judging unit, a second judging unit and a third judging unit, wherein the first judging unit is used for judging whether the number of sending threads is smaller than the maximum concurrency degree or not, and the sending threads are threads for executing notification sending operation; and
a sending unit, configured to create a new sending thread when it is determined that the number of sending threads is smaller than the maximum concurrency degree, and send the notification to be sent through the new sending thread;
a first detection unit, configured to detect whether there is an abnormality in sending the notification to be sent;
a third determining unit, configured to determine whether the number of times of sending the notification to be sent reaches a preset value when it is detected that there is an abnormality in sending the notification to be sent;
an adding unit, configured to add 1 to the number of sending times of the to-be-sent notification when it is determined that the number of sending times of the to-be-sent notification does not reach the preset value, and add the to-be-sent notification to the message queue again; and
the output unit is used for recording the notification to be sent and outputting abnormal information when the sending times of the notification to be sent is judged to reach the preset value;
when it is determined that the number of the sending threads is smaller than the maximum concurrency degree, creating a new sending thread, and sending the notification to be sent through the new sending thread, the method further includes: detecting whether the notification to be sent is abnormal or not; when the condition that the notification to be sent is abnormal is detected, the notification to be sent is added to the message queue again;
the device further comprises: the second detection unit is used for detecting the state of the running switch, wherein the state of the running switch comprises an on state and an off state, the on state is used for indicating to execute the notification sending operation, and the off state is used for indicating to stop executing the notification sending operation; and a fourth judging unit, configured to judge whether the message queue is empty when it is detected that the operation switch is in the on state, wherein, when it is judged that the message queue is not empty, the to-be-sent notification is obtained from the message queue, and when it is judged that the message queue is empty, a second preset time is waited to judge whether the message queue is empty again.
5. The apparatus of claim 4, further comprising: and a second judging unit, configured to wait for a first preset time when it is judged that the number of the sending threads is not less than the maximum concurrency degree, and judge whether the number of the sending threads is less than the maximum concurrency degree again.
CN201511021406.9A 2015-12-30 2015-12-30 Notification sending method and device Active CN106936688B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201511021406.9A CN106936688B (en) 2015-12-30 2015-12-30 Notification sending method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201511021406.9A CN106936688B (en) 2015-12-30 2015-12-30 Notification sending method and device

Publications (2)

Publication Number Publication Date
CN106936688A CN106936688A (en) 2017-07-07
CN106936688B true CN106936688B (en) 2020-11-24

Family

ID=59442392

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201511021406.9A Active CN106936688B (en) 2015-12-30 2015-12-30 Notification sending method and device

Country Status (1)

Country Link
CN (1) CN106936688B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108494668A (en) * 2018-04-03 2018-09-04 北京京东尚科信息技术有限公司 A kind of method and apparatus executing email processing jobs
CN109039732B (en) * 2018-07-26 2021-07-23 中国建设银行股份有限公司 Message processing system and message processing method
CN110730168B (en) * 2019-09-29 2022-06-14 佛山市兴颂机器人科技有限公司 Communication control method and device and server equipment
CN111245707A (en) * 2020-01-08 2020-06-05 北京小米移动软件有限公司 Mail transmission method, device, electronic equipment and storage medium
CN114884906A (en) * 2022-03-23 2022-08-09 晨贝(天津)技术有限公司 Failure retry notification method and device based on quick recovery

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100347675C (en) * 2004-06-29 2007-11-07 北京大学 Property optimizing method for applying server
CN104281489B (en) * 2013-07-12 2017-11-21 上海携程商务有限公司 Multithreading requesting method and system under SOA framework
CN104462194A (en) * 2014-10-28 2015-03-25 北京国双科技有限公司 Service data processing method, device and server
CN104407847B (en) * 2014-10-29 2019-05-07 中国建设银行股份有限公司 A kind of method and device of batch processing
CN104572277B (en) * 2014-12-17 2018-04-27 大唐移动通信设备有限公司 A kind of thread flow control method and device

Also Published As

Publication number Publication date
CN106936688A (en) 2017-07-07

Similar Documents

Publication Publication Date Title
CN106936688B (en) Notification sending method and device
CN106548402B (en) Resource transfer monitoring method and device
CN108737218B (en) Automatic verification method and device for message push arrival rate
CN109800131B (en) Monitoring processing method and device of Linux server, computer equipment and storage medium
CN104994080B (en) Information processing method and system and electronic equipment
WO2017201666A1 (en) Message reply reminding method for electronic social software, and device therefor
CN111212390A (en) Message queue processing method, device and equipment
CN108366098B (en) Data interaction method and device for network nodes
CN112395156A (en) Fault warning method and device, storage medium and electronic equipment
CN106571971B (en) Method, device and system for detecting vacant website
CN111064656A (en) Data management method, device, system, storage medium and electronic equipment
CN107465652B (en) Operation behavior detection method, server and system
CN109559121B (en) Transaction path call exception analysis method, device, equipment and readable storage medium
CN111082986A (en) Alarm notification method and device
CN112398725B (en) Group message prompting method, system, computer equipment and storage medium
CN112969151B (en) Short message monitoring method, device and equipment
CN106055429B (en) A kind of information processing method and device
CN116382952A (en) Exception handling method, device and system
CN106708706B (en) Alarm information processing method and device for task program abnormity
WO2021242687A1 (en) Computer-implemented methods and systems for pre-analysis of emails for threat detection
CN112631808A (en) Data synchronization method and device, electronic equipment and storage medium
CN114466009A (en) Data processing method, edge super-fusion terminal, cloud terminal and readable storage medium
CN113347045A (en) Alarm message processing method and device
CN114979056B (en) E-mail processing method and device, storage medium and electronic equipment
CN110430118B (en) Bill mail managing method, apparatus, computer device and computer readable 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
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 100083 No. 401, 4th Floor, Haitai Building, 229 North Fourth Ring Road, Haidian District, Beijing

Applicant after: Beijing Guoshuang Technology Co.,Ltd.

Address before: 100086 Cuigong Hotel, 76 Zhichun Road, Shuangyushu District, Haidian District, Beijing

Applicant before: Beijing Guoshuang Technology Co.,Ltd.

GR01 Patent grant
GR01 Patent grant