Data pushing method and device, electronic equipment and storage medium
By delaying and resending failed push tasks, and dynamically adjusting the number of business thread startups, the problem of task accumulation caused by data push link problems is solved, and the reliability and efficiency of data push are significantly improved.
Patent Information
- Application Number
- CN202411525942.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-29
- Publication Date
- 2025-01-21
AI Technical Summary
In the prior art, various problems may arise in the data push link, which causes the push device to be unable to send push data to the target device, which in turn leads to a large number of unprocessed push tasks accumulated in the push device, affecting the reliability of data push.
Repeat the failed push task by delaying and re -issuing, and dynamically adjust the number of business threads based on the number of push tasks to avoid task accumulation.
Effectively improve the reliability of data push, prevent push task accumulation, and ensure the stability and efficiency of data push.
Smart Images

Figure CN119336547A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data push, and in particular to a data push method, device, electronic equipment and storage medium. Background Art
[0002] With the development of Internet technology, Internet application products continue to innovate, and microservice and modular application products continue to emerge. Such application products untie the coupling between different modules, but also bring data isolation between modules, and rely heavily on data push to achieve data synchronization between modules. Therefore, how to improve the reliability of data push is an important part of ensuring the reliable operation of modular application products.
[0003] In the related art, various problems may occur in the data push link, causing the push device to be unable to send push data to the target device, which in turn causes a large number of unprocessed push tasks to accumulate in the push device, affecting the reliability of data push. Summary of the invention
[0004] The purpose of the present invention is to provide a data push method, device, electronic device and storage medium, which can retry failed push tasks by delaying and retransmitting, and dynamically adjust the number of business threads started according to the number of accumulated push tasks to avoid task accumulation, thereby effectively improving the reliability of data push.
[0005] In order to solve the above technical problems, the present invention provides a data push method, comprising:
[0006] The service thread retrieves the push task information from the task cache, assembles the push data according to the push task information, and sends the push data to the target device;
[0007] When the service thread determines that the push data fails to be sent, it delays and waits for a preset time and then resends the push data to the target device; when it determines that the push data is sent successfully, it retrieves the next push task from the task cache;
[0008] The thread management module determines the number of service threads to be started according to the number of pushed tasks in the task cache, and starts a corresponding number of service threads according to the number of service threads to be started.
[0009] Optionally, assembling the push data according to the push task information and sending the push data to the target device includes:
[0010] The service thread obtains service data and target device information from the push task information;
[0011] Querying a preset data format configuration and a preset push mode configuration corresponding to the target device information;
[0012] The business data is assembled into push data according to the preset data format configuration, and the push data is sent to the target device according to the preset push mode configuration.
[0013] Optionally, the resending the push data to the target device includes:
[0014] The service thread determines whether the target device information corresponds to multiple preset push mode configurations;
[0015] If the target device information corresponds to multiple preset push mode configurations, the currently used preset push mode configuration is switched to the next set of preset push mode configurations corresponding to the target device information, and the push data is resent to the target device according to the switched preset push mode configurations;
[0016] If the target device information does not correspond to multiple preset push mode configurations, the push data is resent to the target device according to the currently used preset push mode configuration.
[0017] Optionally, it also includes:
[0018] The business thread queries the preset database configuration corresponding to the target device information; when it is determined that the push data fails to be sent, a push failure log is generated according to the failure cause, and the push failure log is sent to the back-end database for storage according to the preset database configuration;
[0019] When it is determined that the push data is sent successfully, a push success log is generated, and the push success log is sent to the back-end database for storage according to the preset database configuration.
[0020] Optionally, before resending the push data to the target device, the method further includes:
[0021] The business thread accumulates the number of sending retries corresponding to the pushed data, and determines whether the number of sending retries reaches a preset retry upper limit;
[0022] If the preset retry upper limit is not reached, entering the step of resending the push data to the target device;
[0023] If the preset retry upper limit number has been reached, a preset alarm message indicating that the push task execution has failed is output.
[0024] Optionally, the thread management module determines the number of service thread startups according to the number of pushed tasks in the task cache, and starts a corresponding number of service threads according to the number of service thread startups, including:
[0025] The thread management module determines the number of push tasks currently stored in the task cache;
[0026] Determine a target numerical interval in which the number of push tasks is located in a plurality of continuous preset numerical intervals; wherein each of the preset numerical intervals is provided with a corresponding preset number of thread startups;
[0027] The preset thread startup number corresponding to the target numerical interval is used as the business thread startup number, and a corresponding number of business threads are started according to the business thread startup number.
[0028] Optionally, it also includes:
[0029] The thread management module determines the number of historical push tasks corresponding to the task cache at multiple adjacent historical moments;
[0030] If the number of historical push tasks increases one by one, the preset number of thread startups corresponding to the next numerical interval adjacent to the target numerical interval is used as the number of business thread startups;
[0031] If the number of historical push tasks decreases one by one, the preset thread startup number corresponding to the previous numerical interval adjacent to the target numerical interval is used as the business thread startup number.
[0032] The present invention also provides a data push system, comprising:
[0033] The service thread is used to retrieve the push task information from the task cache, assemble the push data according to the push task information, and send the push data to the target device; when it is determined that the push data fails to be sent, delay and wait for a preset time and then resend the push data to the target device; when it is determined that the push data is sent successfully, retrieve the next push task from the task cache;
[0034] The thread management module is used to determine the number of service threads to be started according to the number of pushed tasks in the task cache, and start a corresponding number of service threads according to the number of service threads to be started.
[0035] The present invention also provides an electronic device, comprising:
[0036] Memory for storing computer programs;
[0037] A processor is used to implement the data push method as described above when executing the computer program.
[0038] The present invention also provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are loaded and executed by a processor, the data push method as described above is implemented.
[0039] The present invention provides a data push method, comprising: a business thread takes out push task information from a task cache, assembles push data according to the push task information, and sends the push data to a target device; when the business thread determines that the push data fails to be sent, the business thread delays and waits for a preset time and then resends the push data to the target device; when it determines that the push data is sent successfully, the next push task is taken out from the task cache; a thread management module determines the number of business threads to be started according to the number of push tasks in the task cache, and starts a corresponding number of business threads according to the number of business threads to be started.
[0040] It can be seen that the present invention includes a business thread and a thread management module, wherein the business thread takes out the push task information from the task cache, assembles the push data according to the push task information, and sends the push data to the target device. Subsequently, when the business thread determines that the push data fails to be sent, it delays and waits for a preset time and then resends the push data to the target device, and when it determines that the push data is sent successfully, it takes out the next push task from the task cache. That is, when it is determined that the push data fails to be sent, the business thread can try to resend the push data to the target device by delaying, waiting and retrying. The thread management module determines the number of business thread startups according to the number of push tasks in the task cache, and starts the corresponding number of business threads according to the number of business thread startups. In other words, the business thread can try to re-push the push data by delaying, waiting and resending, and the thread management module can start the corresponding number of business threads according to the number of push tasks in the task cache to avoid the accumulation of push tasks. Through the mutual cooperation of the two, the reliability of data push can be effectively improved. The present invention also provides a data push system, an electronic device and a computer-readable storage medium, which have the above-mentioned beneficial effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0042] Figure 1 A flow chart of a data push method provided by an embodiment of the present invention;
[0043] Figure 2 A schematic diagram of a data push process provided by an embodiment of the present invention;
[0044] Figure 3 A structural block diagram of a data push system provided by an embodiment of the present invention;
[0045] Figure 4 The present invention provides a structural block diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0047] With the development of Internet technology, Internet application products continue to innovate, and microservice and modular application products continue to emerge. Such application products untie the coupling between different modules, but also bring data isolation between modules, and rely heavily on data push to achieve data synchronization between modules. Therefore, how to improve the reliability of data push is an important part of ensuring the reliable operation of modular application products.
[0048] In the related art, various problems may occur in the data push link, resulting in the inability of the push device to send push data to the target device, which in turn causes a large number of unprocessed push tasks to accumulate in the push device, affecting the reliability of data push. In view of this, in order to solve the technical problem of how to improve the reliability of data push, the present invention can provide a data push method, which can retry failed push tasks by delaying and retransmitting, and can dynamically adjust the number of service thread startups according to the number of accumulated push tasks to avoid task accumulation, thereby effectively improving the reliability of data push.
[0049] Please refer to Figure 1 , Figure 1 A flowchart of a data push method provided by an embodiment of the present invention. The method is applied to a data push system, which may be composed of a business thread and a thread management module. A task cache may also be set in the system to store all pending push tasks. The method may include:
[0050] S101. The service thread retrieves push task information from the task cache, assembles push data according to the push task information, and sends the push data to a target device.
[0051] In this embodiment, the business thread is the execution processing subject of the push task. After startup, the business thread can retrieve the push task information from the task cache, and assemble and send the push data according to the push task information. Among them, the push data is the data to be pushed and sent to the target device, and the target device is the receiving subject of the push data. It should be noted that the target device in this embodiment can be either a physical device (such as a user terminal) or a virtual machine device (such as a microservice).
[0052] Furthermore, this embodiment does not limit what content is included in the push task information, for example, it may include the business data to be pushed and the target device information. Among them, the relationship between the business data and the push data is: the push data is obtained by assembling the business data according to a given data format. The target device information is the relevant information of the target device, such as the target device name, communication information, etc. Further, in order to improve the flexibility of data push, each target device can be configured with a corresponding preset data format configuration, preset push mode configuration, etc. Among them, the preset data format configuration is used to specify the data format of the push data, for example, it is required to assemble the business data into JSON format data (JavaScript Object Notation) or TXT format data, and to specify the specific field name, field data type, etc. in the push data. The preset push mode configuration is used to specify the transmission protocol used to transmit the push data, such as FTP (File Transfer Protocol), HTTP (Hypertext Transfer Protocol), RPC (Remote Procedure Call), etc. The business thread can query the corresponding preset data format configuration and preset push method configuration according to the target device information, assemble the business data into push data according to the preset data format configuration, and send the push data to the target device according to the preset push method configuration.
[0053] Based on this, assembling the push data according to the push task information and sending the push data to the target device may include:
[0054] Step 11: The service thread obtains service data and target device information from the push task information;
[0055] Step 12: Query the preset data format configuration and preset push mode configuration corresponding to the target device information;
[0056] Step 13: Assemble the business data into push data according to the preset data format configuration, and send the push data to the target device according to the preset push mode configuration.
[0057] It should be noted that this embodiment does not limit the specific data format configuration and push mode configuration, and can be set according to actual application requirements. It is worth pointing out that by selecting the data format to be pushed and configuring the data source to be pushed, the background uses the configured format to process the program to select the data source and assemble it into the configured format. In addition, the push mode configuration can be used to determine which push strategy the program executes, and subsequent methods can be expanded. Just write the corresponding strategy and add the method to the configuration page to execute the method.
[0058] S102: When the service thread determines that the push data fails to be sent, it delays and waits for a preset time and then resends the push data to the target device; when it determines that the push data is sent successfully, it retrieves the next push task from the task cache.
[0059] In this step, after sending the push data to the target device, the business thread can determine whether the push is successful. The business thread can determine whether the push is successful based on whether the target device has feedback and the specific feedback value. Furthermore, if it is determined that the push data is sent successfully, the business thread can take out the next push task from the task cache; if it is determined that the push data fails to be sent, the business thread can delay waiting for a preset period of time and then resend the push data to the target device. The reason for setting the delay mechanism is that considering that the communication link may be blocked, if you try to push again without waiting, it is easy to further aggravate the blocking state of the communication link. Therefore, this embodiment can wait for a period of time for the communication link to return to normal, so as to increase the possibility of successful push.
[0060] Furthermore, if data can be pushed between this system and the target device through multiple push methods, that is, multiple preset push method configurations can be set for the target device, after the waiting is over, the business thread can switch the currently used preset push method configuration to the next preset push method configuration supported by the target device, so as to retry the push in different ways.
[0061] Based on this, the resending of the push data to the target device may include:
[0062] Step 21: The business thread determines whether the target device information corresponds to multiple preset push mode configurations;
[0063] Step 22: If the target device information corresponds to multiple preset push mode configurations, the currently used push mode configuration is switched to the next set of preset push mode configurations corresponding to the target device information, and the push data is resent to the target device according to the switched preset push mode configurations;
[0064] Step 23: If the target device information does not correspond to multiple preset push mode configurations, the push data is resent to the target device according to the currently used preset push mode configuration.
[0065] For example, if the target device supports FTP, HTTP, and RPC push methods at the same time, FTP can be used for the first push. If FTP push fails, HTTP push can be switched to push. If HTTP still fails, RPC push can be switched to push.
[0066] Furthermore, considering that the success or failure of data push is not felt by the user, which easily leads to the user not being clear about the specific data push situation, which is not conducive to troubleshooting, the present embodiment can also save the specific results of data push in the form of logs to the backend database. Specifically, a corresponding preset database configuration can be set for the target device. Subsequently, whether it is determined that the push data fails to be sent or succeeds, the corresponding results can be formed into a log, and the log is stored in the backend database according to the above preset database configuration.
[0067] Based on this, the method may further include:
[0068] Step 31: the service thread queries a preset database configuration corresponding to the target device information;
[0069] Step 32: when it is determined that the push data fails to be sent, a push failure log is generated according to the failure cause, and the push failure log is sent to a backend database for storage according to the preset database configuration;
[0070] Step 33: When it is determined that the push data is sent successfully, a push success log is generated, and the push success log is sent to the back-end database for storage according to the preset database configuration.
[0071] It should be noted that the above preset database configuration can also be adjusted as needed. For example, it can be used to connect to MySQL database, Redis cache database, Elasticsearch big data database or Kafka message queue.
[0072] Finally, for the push data that cannot be pushed successfully after repeated retries, this embodiment can set a retry limit. If it is determined that the number of push data sending retries has reached the preset retry limit, the retry is stopped and a preset alarm message indicating that the push task execution failed is displayed.
[0073] Based on this, before resending the push data to the target device, the method may further include:
[0074] Step 41: The business thread accumulates the number of sending retries corresponding to the pushed data, and determines whether the number of sending retries reaches a preset retry upper limit;
[0075] Step 42: If the preset retry upper limit is not reached, entering the step of resending the push data to the target device;
[0076] Step 43: If the preset retry upper limit number has been reached, output a preset alarm message indicating that the push task execution has failed.
[0077] It should be noted that the present embodiment does not limit the specific value of the preset upper limit of the number of retries, and it can be set according to actual application requirements.
[0078] S103. The thread management module determines the number of service threads to be started according to the number of pushed tasks in the task cache, and starts a corresponding number of service threads according to the number of service threads to be started.
[0079] In this embodiment, it is considered that when the number of push tasks increases sharply or the push tasks fail in batches, it is easy to cause excessive push tasks to accumulate in the task cache, which is not conducive to the efficient processing of push tasks. To this end, this embodiment can also set a thread management module, which can detect the number of push tasks in the task cache and adjust the number of service thread startups according to the number of push tasks to ensure that there are sufficient service threads to process push tasks in parallel, reduce the number of task accumulation, and thus improve the reliability of data push.
[0080] It should be noted that this embodiment does not limit how to determine the number of business thread startups based on the number of push tasks. For example, multiple continuous preset numerical intervals can be set for the number of push tasks, and a corresponding preset number of thread startups can be set for each preset numerical interval. The larger the numerical value corresponding to the preset numerical interval, the more blocked push tasks there are, and the larger the corresponding preset number of thread startups; the smaller the numerical value corresponding to the preset numerical interval, the smaller the corresponding preset number of thread startups. Furthermore, the thread management module can determine the target data interval where the current number of push tasks is located in these multiple preset data intervals, and use the preset number of thread startups corresponding to the target numerical interval as the business thread startup number.
[0081] Based on this, the thread management module determines the number of service thread startups according to the number of pushed tasks in the task cache, and starts a corresponding number of service threads according to the number of service thread startups, which may include:
[0082] Step 41: The thread management module determines the number of push tasks currently stored in the task cache;
[0083] Step 42: determining a target numerical interval in which the number of push tasks is located in a plurality of continuous preset numerical intervals; wherein each of the preset numerical intervals is provided with a corresponding preset number of thread startups;
[0084] Step 43: taking the preset thread startup number corresponding to the target numerical interval as the business thread startup number, and starting a corresponding number of business threads according to the business thread startup number.
[0085] It should be noted that the present embodiment does not limit the specific preset value interval and the number of the intervals, which can be set according to actual application requirements.
[0086] In addition, the present embodiment can also adjust the number of business thread startups in advance according to the change in the values corresponding to the push task data at multiple adjacent historical moments, so as to ensure that the number of business threads is adjusted accordingly according to the change trend of the push task data. Specifically, the thread management module determines the number of historical push tasks corresponding to the task cache at multiple adjacent historical moments. If these historical push task numbers increase one by one, the preset number of thread startups corresponding to the subsequent numerical interval adjacent to the target numerical interval where the current number of push tasks is located can be used as the number of business thread startups to ensure that the business threads have redundant processing capabilities. If the number of historical push tasks decreases one by one, the preset number of thread startups corresponding to the previous numerical interval adjacent to the target numerical interval can be used as the number of business thread startups to avoid wasting business thread resources.
[0087] Based on this, the method may further include:
[0088] Step 51: The thread management module determines the number of historical push tasks corresponding to the task cache at multiple adjacent historical moments;
[0089] Step 52: If the number of historical push tasks increases one by one, the preset thread startup number corresponding to the next numerical interval adjacent to the target numerical interval is used as the business thread startup number;
[0090] Step 53: If the number of historical push tasks decreases one by one, the preset thread startup number corresponding to the previous numerical interval adjacent to the target numerical interval is used as the business thread startup number.
[0091] Based on the above embodiment, the present invention includes a service thread and a thread management module, wherein the service thread takes out the push task information from the task cache, assembles the push data according to the push task information, and sends the push data to the target device. Subsequently, when the service thread determines that the push data fails to be sent, it delays and waits for a preset time and then resends the push data to the target device, and when it determines that the push data is successfully sent, it takes out the next push task from the task cache. That is, when it is determined that the push data fails to be sent, the service thread can try to resend the push data to the target device by delaying, waiting and retrying. The thread management module determines the number of service thread startups according to the number of push tasks in the task cache, and starts the corresponding number of service threads according to the number of service thread startups. In other words, the service thread can try to re-push the push data by delaying, waiting and resending, and the thread management module can start the corresponding number of service threads according to the number of push tasks in the task cache to avoid the accumulation of push tasks. Through the cooperation between the two, the reliability of data push can be effectively improved.
[0092] Based on the above embodiment, the above data push method is introduced below based on a specific schematic diagram. Figure 2 , Figure 2 This is a schematic diagram of a data push process provided by an embodiment of the present invention. The present invention can provide a data push device to cooperate with the business thread and thread management module. The device specifically involves two modules and several sub-modules:
[0093] Push module: This module combines the configuration of the template configuration module, queries the rules and pushes the corresponding data
[0094] Template configuration module: This module is managed uniformly through platform configuration and consists of various configuration sub-modules. It realizes format diversification by configuring different data formats; configures push methods to adapt to different push methods; persists push results so that users can clearly know whether the results are successful; push process compensation mechanism and push interruption compensation mechanism to prevent data interruption and loss.
[0095] Data format submodule: The diversity of data formats leads to the diversity of pushed data. This module selects data for push by adapting to different data formats, such as json format data, txt text file type data, etc. By selecting the data format to be pushed and configuring the data source to be pushed, the background uses the configured format to perform program processing to select the data source and assemble it into the configured format.
[0096] Push method submodule: By configuring the push method, you can decide which push strategy the program will execute, such as ftp method, http method, rpc method, etc. Subsequent methods can be expanded. You only need to write the corresponding strategy and add the method to the configuration page to execute it.
[0097] Push result persistence submodule: configure the push result persistence method to persist the push results. For example, save them into MySQL database, Redis cache database, Elasticsearch big data database, Kafka message queue, etc. to achieve diversity, adapt to different user scenarios, and give formal users the choice of on-site environment.
[0098] Compensation mechanism module: The real network is full of uncertainty. There are more or less failures in a complete push link. Therefore, this module provides a compensation mechanism. The mechanism is as follows: 1. Retry mechanism. Through the configured number of retries, the push is initiated again only when the current push fails. When the number of retries is exceeded, the push result is persisted to inform the user of the push failure; 2. Delay mechanism. When monitoring a large number of push request blockages, a large number of push tasks and the accumulation of tasks caused by the above-mentioned retry mechanism may cause thread blockage and affect the operation of the entire environment. Therefore, the delay mechanism is born. The delay mechanism is derived from the retry mechanism, but it is different from the retry mechanism. The delay mechanism does not quickly start the request again, but caches the current request parameter information in the cache (such as redis and other caching methods), and then initiates the cache request at a specific time. However, this mechanism has real-time problems. If there is a real-time requirement for push data, this mechanism is not suitable for opening; 3. Dynamic thread mechanism. Based on the effectiveness problem in the above delay mechanism, the dynamic thread mechanism is introduced. The implementation principle of this mechanism is to dynamically open the working thread according to the number of tasks in real time when tasks are piled up, and dynamically and automatically adapt the number of threads to handle the piled up tasks. Under this mechanism, task congestion is effectively handled, and at the same time, the push task also has efficient real-time performance; 4. Automatic conversion push strategy mechanism. Users can configure the automatic conversion push strategy to open this mechanism. Based on the above retry mechanism, after multiple pushes, in addition to informing the user that the push failed, this mechanism can automatically convert the push strategy and open the notification again to push the task.
[0099] The data push system, electronic device and computer-readable storage medium provided in the embodiments of the present invention are introduced below. The data push system, electronic device and computer-readable storage medium described below can correspond to the data push method described above.
[0100] Please refer to Figure 3 , Figure 3A structural block diagram of a data push system provided by an embodiment of the present invention, the system may include:
[0101] The service thread 301 is used to retrieve the push task information from the task cache, assemble the push data according to the push task information, and send the push data to the target device; when it is determined that the push data fails to be sent, delay and wait for a preset time and then resend the push data to the target device; when it is determined that the push data is sent successfully, retrieve the next push task from the task cache;
[0102] The thread management module 302 is used to determine the number of service threads to be started according to the number of pushed tasks in the task cache, and start a corresponding number of service threads according to the number of service threads to be started.
[0103] It should be noted that there may be multiple service threads 301 .
[0104] Optionally, the service thread 301 may also be used to:
[0105] Acquire business data and target device information from the push task information;
[0106] Querying a preset data format configuration and a preset push mode configuration corresponding to the target device information;
[0107] The business data is assembled into push data according to the preset data format configuration, and the push data is sent to the target device according to the preset push mode configuration.
[0108] Optionally, the service thread 301 may also be used to:
[0109] Determining whether the target device information corresponds to multiple preset push mode configurations;
[0110] If the target device information corresponds to multiple preset push mode configurations, the currently used push mode configuration is switched to the next set of preset push mode configurations corresponding to the target device information, and the push data is resent to the target device according to the switched preset push mode configurations;
[0111] If the target device information does not correspond to multiple preset push mode configurations, the push data is resent to the target device according to the currently used preset push mode configuration.
[0112] Optionally, the service thread 301 may also be used to:
[0113] Querying a preset database configuration corresponding to the target device information;
[0114] When it is determined that the push data fails to be sent, a push failure log is generated according to the failure cause, and the push failure log is sent to the back-end database for storage according to the preset database configuration;
[0115] When it is determined that the push data is sent successfully, a push success log is generated, and the push success log is sent to the back-end database for storage according to the preset database configuration.
[0116] Optionally, the service thread 301 may also be used to:
[0117] Accumulate the number of sending retries corresponding to the pushed data, and determine whether the number of sending retries reaches a preset upper limit of retries;
[0118] If the preset retry upper limit is not reached, entering the step of resending the push data to the target device;
[0119] If the preset retry upper limit number has been reached, a preset alarm message indicating that the push task execution has failed is output.
[0120] Optionally, the thread management module 302 may also be used to:
[0121] Determine the number of push tasks currently stored in the task cache;
[0122] Determine a target numerical interval in which the number of push tasks is located in a plurality of continuous preset numerical intervals; wherein each of the preset numerical intervals is provided with a corresponding preset number of thread startups;
[0123] The preset thread startup number corresponding to the target numerical interval is used as the business thread startup number, and a corresponding number of business threads are started according to the business thread startup number.
[0124] Optionally, the thread management module 302 may also be used to:
[0125] Determine the number of historical push tasks corresponding to the task cache at multiple adjacent historical moments;
[0126] If the number of historical push tasks increases one by one, the preset number of thread startups corresponding to the next numerical interval adjacent to the target numerical interval is used as the number of business thread startups;
[0127] If the number of historical push tasks decreases one by one, the preset thread startup number corresponding to the previous numerical interval adjacent to the target numerical interval is used as the business thread startup number.
[0128] Please refer to Figure 4 , Figure 4This is a structural block diagram of an electronic device provided by an embodiment of the present invention. The embodiment of the present invention provides an electronic device 40, including a processor 41 and a memory 42; wherein the memory 42 is used to store a computer program; and the processor 41 is used to execute the data push method provided by the above embodiment when executing the computer program. For example, the processor 41 is used to implement the above service thread and thread management module.
[0129] For the specific process of the above data push method, please refer to the corresponding content provided in the above embodiments, which will not be repeated here.
[0130] Furthermore, the memory 42 as a carrier for storing resources may be a read-only memory, a random access memory, a magnetic disk or an optical disk, etc., and the storage method may be temporary storage or permanent storage.
[0131] In addition, the electronic device 40 also includes a power supply 43, a communication interface 44, an input / output interface 45 and a communication bus 46; wherein the power supply 43 is used to provide working voltage for each hardware device on the electronic device 40; the communication interface 44 can create a data transmission channel between the electronic device 40 and external devices, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present invention, and is not specifically limited here; the input / output interface 45 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0132] An embodiment of the present invention further provides a computer program product, including a computer program / instruction, which implements the data push method described in the above embodiment when executed by a processor.
[0133] Since the embodiments of the computer program product part correspond to the embodiments of the data push method part, please refer to the description of the embodiments of the data push method part for the embodiments of the computer program product part, which will not be repeated here.
[0134] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the data push method described in the above embodiment is implemented.
[0135] Since the embodiments of the computer-readable storage medium part correspond to the embodiments of the data push method part, the embodiments of the storage medium part refer to the description of the embodiments of the data push method part, which will not be repeated here.
[0136] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0137] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0138] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0139] The above is a detailed introduction to a data push method, device, electronic device and storage medium provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present invention, several improvements and modifications can be made to the present invention, and these improvements and modifications also fall within the scope of protection of the present invention.
Claims
1. A data push method, characterized in that: include: The service thread retrieves the push task information from the task cache, assembles the push data according to the push task information, and sends the push data to the target device; When the service thread determines that the push data fails to be sent, it delays and waits for a preset time and then resends the push data to the target device; when it determines that the push data is sent successfully, it retrieves the next push task from the task cache; The thread management module determines the number of service threads to be started according to the number of pushed tasks in the task cache, and starts a corresponding number of service threads according to the number of service threads to be started.
2. The data push method according to claim 1, characterized in that: The assembling the push data according to the push task information and sending the push data to the target device includes: The service thread obtains service data and target device information from the push task information; Querying a preset data format configuration and a preset push mode configuration corresponding to the target device information; The business data is assembled into push data according to the preset data format configuration, and the push data is sent to the target device according to the preset push mode configuration.
3. The data push method according to claim 2, characterized in that: The resending the push data to the target device comprises: The service thread determines whether the target device information corresponds to multiple preset push mode configurations; If the target device information corresponds to multiple preset push mode configurations, the currently used push mode configuration is switched to the next set of preset push mode configurations corresponding to the target device information, and the push data is resent to the target device according to the switched preset push mode configurations; If the target device information does not correspond to multiple preset push mode configurations, the push data is resent to the target device according to the currently used preset push mode configuration.
4. The data push method according to claim 2, characterized in that: Also includes: The service thread queries a preset database configuration corresponding to the target device information; When it is determined that the push data fails to be sent, a push failure log is generated according to the failure cause, and the push failure log is sent to the back-end database for storage according to the preset database configuration; When it is determined that the push data is sent successfully, a push success log is generated, and the push success log is sent to the back-end database for storage according to the preset database configuration.
5. The data push method according to claim 1, characterized in that: Before resending the push data to the target device, the method further includes: The business thread accumulates the number of sending retries corresponding to the pushed data, and determines whether the number of sending retries reaches a preset retry upper limit; If the preset retry upper limit is not reached, entering the step of resending the push data to the target device; If the preset retry upper limit number has been reached, a preset alarm message indicating that the push task execution has failed is output.
6. The data push method according to any one of claims 1 to 5, characterized in that: The thread management module determines the number of service thread startups according to the number of pushed tasks in the task cache, and starts a corresponding number of service threads according to the number of service thread startups, including: The thread management module determines the number of push tasks currently stored in the task cache; Determine a target numerical interval in which the number of push tasks is located in a plurality of continuous preset numerical intervals; wherein each of the preset numerical intervals is provided with a corresponding preset number of thread startups; The preset thread startup number corresponding to the target numerical interval is used as the business thread startup number, and a corresponding number of business threads are started according to the business thread startup number.
7. The data push method according to claim 6, characterized in that: Also includes: The thread management module determines the number of historical push tasks corresponding to the task cache at multiple adjacent historical moments; If the number of historical push tasks increases one by one, the preset number of thread startups corresponding to the next numerical interval adjacent to the target numerical interval is used as the number of business thread startups; If the number of historical push tasks decreases one by one, the preset thread startup number corresponding to the previous numerical interval adjacent to the target numerical interval is used as the business thread startup number.
8. A data push system, characterized in that: include: The service thread is used to retrieve the push task information from the task cache, assemble the push data according to the push task information, and send the push data to the target device; when it is determined that the push data fails to be sent, delay and wait for a preset time and then resend the push data to the target device; when it is determined that the push data is sent successfully, retrieve the next push task from the task cache; The thread management module is used to determine the number of service threads to be started according to the number of pushed tasks in the task cache, and start a corresponding number of service threads according to the number of service threads to be started.
9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the data push method as described in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are loaded and executed by the processor, the data push method according to any one of claims 1 to 7 is implemented.