Message pushing method, device and equipment and computer storage medium
By introducing maximum concurrent push count, maximum cache size, and backpressure strategy into the HTTP push method, combined with a pull compensation mechanism, the problems of data loss and memory overflow caused by insufficient processing capacity of the receiving end are solved, and stable data push and integrity are guaranteed.
Patent Information
- Application Number
- CN202311705029.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-11
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2043-12-11
AI Technical Summary
Existing HTTP push methods are prone to insufficient processing capacity at the receiving end when faced with large amounts of data, leading to data loss or memory overflow at the receiving end. Furthermore, existing delayed queue methods have not effectively solved the problem of peak message push.
The system employs a maximum concurrent push count, a maximum cache size, and a backpressure strategy. The backpressure mechanism controls the data push rate, and the pull compensation mechanism synchronizes data discarded by the IoT platform to ensure data integrity.
It effectively prevents the avalanche problem caused by weak processing capabilities at the receiving end, and ensures data integrity through a pull compensation mechanism, thereby improving the reliability and efficiency of message push.
Smart Images

Figure CN118827647B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of Internet of Things, and particularly relates to a message pushing method and device, equipment and a computer storage medium. BACKGROUND
[0002] Internet of Things (IoT) is a new generation of information technology, which is an important part of the Internet of Things, and is an extension and expansion of the Internet. It combines various information sensing devices with networks to form a huge network, and realizes the interconnection of people, machines and things at any time and any place. The Internet of Things platform is a platform for Internet of Things application developers to quickly develop, deploy and manage applications. Developers do not need to consider the expansion of the underlying infrastructure, data management and collection, communication protocols, communication security and other issues, which reduces the development cost and greatly shortens the development time. The Internet of Things platform has terminal access, terminal management, message pushing, data distribution and other general basic capabilities.
[0003] Among them, data distribution mainly has two modes of pulling and pushing. The pulling mode is initiated by the receiving end to the Internet of Things platform, and the pushing mode is the Internet of Things platform actively pushing data to the receiving end. These two ways have advantages and disadvantages. The pulling mode is initiated by the receiving end, so the rate can be controlled, but the receiving end needs to constantly initiate polling requests. If the polling frequency is too high, the resource consumption is high, and if the polling frequency is low, the message may not be timely. The pushing mode is initiated by the Internet of Things platform, and the message is pushed after receiving the message, which is timely, but there may be situations such as data loss due to low processing rate of the receiving end or memory overflow of the receiving end. Because HTTP message pushing has the advantages of standard transmission protocol and support for various major development languages, it is currently the mainstream message pushing method of the Internet of Things platform.
[0004] The existing HTTP pushing method generally reports the message to the Internet of Things platform by the device, stores it in a unified message queue, and the pushing program consumes data from the message queue to push. If the pushing fails, it will be discarded or discarded after retry. However, the inventors found in the process of implementing the present application that direct discarding can lead to incomplete data, and at the same time, the data volume can be doubled due to the constant pushing of failed data and the constant arrival of new data, which can cause the receiving end to "avalanche" and other problems.
[0005] In one prior art, after a message arrives, the information reported by the device is allocated to a preset time-delay push queue according to the current push rate and push time delay of the URL address, and then pushed to the URL address through asynchronous HTTP post and multi-thread mode. However, the inventor found in the process of implementing the scheme of the present application that this mode actually only delays the push time, and does not solve the problem of peak message push. When a large number of messages suddenly arrive, if it is found that the processing capacity of the receiving end corresponding to the current URL is not enough, the scheme will put these messages into the delay queue. However, at this time, the push rate and push time delay of the current URL are calculated according to the push results in the past period of time, so the sudden reported batch of data will get approximately the same calculation results, and thus be put into the same delay queue. When the delay time arrives, this batch of data will also be processed almost simultaneously, so it still causes great pressure to the receiving end. SUMMARY
[0006] The embodiments of the present application provide a message push method, device, equipment and computer storage medium, so as to effectively solve the technical problem that the large amount of push data causes too much pressure to the receiving end.
[0007] In a first aspect, the embodiments of the present application provide a message push method, applied to a server, and the method comprises the following steps.
[0008] Obtaining a configuration rule, the configuration rule comprising a maximum concurrent push number, a cache maximum value and a back pressure strategy, wherein the maximum concurrent push number is the maximum concurrent push number when pushing messages to the receiving end, the cache maximum value is the maximum number of messages that can be cached after the message push fails, and the back pressure strategy is used to indicate the processing mode after the current cache message number reaches the cache maximum value;
[0009] Receiving messages to be pushed to the receiving end and assigning a unique identifier to each message;
[0010] Judging whether a push permission is obtained;
[0011] If the push permission is obtained, pushing the message set to the receiving end, wherein the message set comprises one or more of the following data: the latest message, the message in the cache, the identifier of the specified message, and the specified message comprises the message that has been discarded and unknown to the receiving end;
[0012] If the push permission is not obtained, judging whether the current cache message number has reached the cache maximum value, if not, storing the message in the message set as the message that fails to push, and if yes, processing according to the back pressure strategy.
[0013] In a second aspect, the embodiments of the present application provide a message push method, applied to a receiving end, and the method comprises the following steps.
[0014] receiving a message set pushed by the server, wherein the message set includes an identifier of a specified message, and the specified message includes a message that has been discarded by the server and unknown to the receiving end;
[0015] sending a request to the server, wherein the request includes the identifier of the specified message;
[0016] receiving the specified message sent by the server.
[0017] In a third aspect, an embodiment of the present application provides a message pushing device applied to a server, and the device comprises:
[0018] a configuration rule obtaining module, configured to obtain a configuration rule, wherein the configuration rule includes a maximum concurrent pushing number, a maximum cache value, and a back pressure strategy, the maximum concurrent pushing number is a maximum concurrent pushing number when pushing messages to a receiving end, the maximum cache value is a maximum number of messages that can be cached after a message pushing failure, and the back pressure strategy is used to indicate a processing manner after a current number of cached messages reaches the maximum cache value;
[0019] a message receiving module, configured to receive messages to be pushed to the receiving end and assign a unique identifier to each message;
[0020] a pushing module, configured to determine whether a pushing permission is obtained; if the pushing permission is obtained, the pushing module pushes a message set to the receiving end, wherein the message set includes one or more of the following data: a latest message, a message in the cache, and an identifier of a specified message, and the specified message includes a message that has been discarded and unknown to the receiving end; if the pushing permission is not obtained, the pushing module determines whether a current number of cached messages has reached the maximum cache value; if the current number of cached messages has not reached the maximum cache value, the pushing module stores the messages in the message set as messages of a pushing failure in the cache; and if the current number of cached messages has reached the maximum cache value, the pushing module processes according to the back pressure strategy.
[0021] In a fourth aspect, an embodiment of the present application provides a message pushing device applied to a receiving end, and the device comprises:
[0022] a message receiving module, configured to receive a message set pushed by the server, wherein the message set includes an identifier of a specified message, and the specified message includes a message that has been discarded by the server and unknown to the receiving end; and receive the specified message sent by the server;
[0023] a message pulling module, configured to send a request to the server, wherein the request includes the identifier of the specified message.
[0024] In a fifth aspect, an embodiment of the present application provides a terminal device, and the device comprises a processor and a memory storing computer program instructions.
[0025] The processor executes the computer program instructions to implement the message pushing method in the first aspect, or implement the message pushing method in the second aspect.
[0026] In a sixth aspect, an embodiment of the present application provides a computer storage medium, and computer program instructions are stored on the computer storage medium, and the computer program instructions are executed by a processor to implement the message pushing method in the first aspect or the message pushing method in the second aspect.
[0027] In a seventh aspect, an embodiment of the present application provides a computer program product, and instructions in the computer program product are executed by a processor of an electronic device to enable the electronic device to execute the message pushing method in the first aspect or the message pushing method in the second aspect.
[0028] The message pushing method, device, equipment and computer storage medium provided by the embodiments of the present application can be applied to a server, and the method comprises the following steps: obtaining a configuration rule, the configuration rule comprising a maximum concurrent pushing number, a cache maximum value and a back pressure strategy, wherein the maximum concurrent pushing number is a maximum concurrent pushing number when pushing a message to a receiving end, the cache maximum value is a maximum number of messages that can be cached after a message pushing failure, and the back pressure strategy is used to indicate a processing manner after a current cache message number reaches the cache maximum value; receiving a message to be pushed to the receiving end and assigning a unique identifier to each message; determining whether a pushing permission is obtained; if the pushing permission is obtained, pushing a message set to the receiving end, wherein the message set comprises one or more of the following data: a latest message, a message in the cache, and an identifier of a specified message, and the specified message comprises a message that has been discarded and unknown to the receiving end; if the pushing permission is not obtained, determining whether the current cache message number has reached the cache maximum value, if not, storing the latest message as a message of a pushing failure in the cache, and if yes, processing according to the back pressure strategy. The embodiments of the present application control the rate of data pushing through the back pressure mechanism, which can effectively prevent problems such as avalanche caused by weak processing capacity of the receiving end. In addition, the data discarded by the Internet of Things platform is synchronized through the pull compensation mechanism, so that the receiving end can pull the discarded message as needed after receiving the identifier of the discarded message, to ensure the integrity of the data. BRIEF DESCRIPTION OF DRAWINGS
[0029] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments of the present application. Those skilled in the art can obtain other drawings according to these drawings without any creative effort.
[0030] Figure 1 is a schematic diagram of a framework structure that can implement the message pushing method provided by the embodiments of the present application;
[0031] Figure 2 is a flowchart of the message pushing method applied to a server provided by the embodiments of the present application;
[0032] Figure 3 is a schematic diagram of an HTTP push system in a specific application example;
[0033] Figure 4 is an HTTP push flowchart in a specific application example;
[0034] Figure 5 is a flowchart of a message push method applied to a receiving end provided by an embodiment of the present application;
[0035] Figure 6 is a schematic diagram of a message push device applied to a server provided by an embodiment of the present application;
[0036] Figure 7 is a schematic diagram of a message push device applied to a receiving end provided by an embodiment of the present application;
[0037] Figure 8 is a schematic diagram of a hardware structure of a terminal device related to an embodiment of the present application. DETAILED DESCRIPTION
[0038] The features and exemplary embodiments of various aspects of the present application will be described below in detail, in order to make the purposes, technical solutions and advantages of the present application more clear and apparent, the present application will be further described in detail below in combination with the drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, but not to limit the present application. The present application can be implemented without some of these specific details by those skilled in the art. The following description of the embodiments is only to provide a better understanding of the present application by showing examples of the present application.
[0039] It should be noted that, in this document, relational terms such as first and second and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any such actual relationship or order between such entities or actions. Moreover, the terms "comprises", "comprising", or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without more limitations, an element defined by the statement "comprising" does not exclude the existence of additional identical elements in the process, method, article, or apparatus that includes the element.
[0040] To solve the prior art problems, the embodiments of the present application provide a message pushing method, device and equipment and computer storage medium. First, the framework to which the message pushing method provided by the embodiments of the present application can be applied is exemplified.
[0041] As shown in Figure 1 The framework can include a server 20 and an electronic device 10, wherein the electronic device 10 can be, for example, a mobile terminal, a personal computer or a wearable device, etc., which is not specifically limited here.
[0042] The electronic device 10 can have a communication module, which can be a 5G, 4G or WiFi type communication module, and can be used to realize the communication between the electronic device 10 and the server 20. For example, the electronic device 10 can send its software and hardware data to the server 20, and the server 20 can send messages to the electronic device. The server 20 can receive the data sent by the electronic device 10 and process the data.
[0043] Taking an Internet of Things platform as an example, after a device connects to the Internet of Things platform, it will report device data, and the Internet of Things platform generally provides data distribution capability. Data distribution is divided into pull mode and push mode, and since the push mode has better timeliness and HTTP protocol is widely used, general Internet of Things platforms will provide HTTP push function. HTTP push is initiated by the Internet of Things platform, and its defect is that the processing capability of the data receiving end can be weak, resulting in a large number of push failures, thereby causing memory leakage or avalanche problems.
[0044] Figure 2 is a flowchart of a message pushing method applied to a server provided by the embodiments of the present application. The method can include:
[0045] In step S201, a configuration rule is obtained, the configuration rule including a maximum concurrent pushing number, a cache maximum value and a back pressure strategy, wherein the maximum concurrent pushing number is the maximum concurrent pushing number when pushing messages to the receiving end, the cache maximum value is the maximum number of messages that can be cached after the message pushing fails, and the back pressure strategy is used to indicate the processing mode after the current cache message number reaches the cache maximum value.
[0046] Back pressure is a control mechanism that maintains the balance between data generation rate and consumption rate. When the data generation rate exceeds the consumption rate, it can cause data loss or system crash. Back pressure can prevent data consumers from being "overwhelmed" and coordinate the relationship between consumers and producers.
[0047] As an example, in combination with some application scenarios, the back pressure strategy can specifically include:
[0048] Error mode: no longer process new received messages and notify the receiving end.
[0049] Drop mode: all newly received messages will be discarded, and the identity of the discarded message is recorded;
[0050] Retention mode: the earliest message in the cached message will be discarded, and the identity of the discarded message is recorded.
[0051] The back pressure strategy can be pre-configured as one of the modes, and when the back pressure strategy is triggered, it is processed according to the configured mode. If the back pressure strategy is not configured, a default configuration can be used, such as being configured as one of the retention modes.
[0052] The specific back pressure strategy is not limited in the embodiment, and those skilled in the art can select and design according to different needs and different scenarios, and the selection and design used herein do not deviate from the spirit and protection scope of the present application.
[0053] In step S202, messages to be pushed to the receiving end are received and each message is assigned a unique identity.
[0054] In step S203, it is determined whether a push permission is obtained.
[0055] For example, the permission can be a token, and the token needs to be obtained before the push can be performed.
[0056] In step S204, if the push permission is obtained, the message set is pushed to the receiving end, wherein the message set includes one or more of the following data: the latest message, the message in the cache, the identity of the specified message, and the specified message includes the discarded message and the receiving end is unaware of the message.
[0057] The cache is used to store the discarded messages. There can be some messages discarded, and the receiving end is unaware of this. The identity of these discarded messages can be recorded and then combined into the message set.
[0058] It is easy to understand that if there is no identity of the discarded message at present, the message set can not include the identity of the specified message. If there are too many identities of the discarded message at present, they can be combined in the message set for several times, and the embodiment does not limit this. If there are still messages in the cache after the latest message is pushed, the messages in the cache can be continuously pushed.
[0059] In step S205, if the push permission is not obtained, it is determined whether the number of cached messages has reached the maximum value of the cache. If not, the message in the message set is stored in the cache as a push failed message, and if so, it is processed according to the back pressure strategy.
[0060] In other words, if the push fails because no push permission is obtained, the push is handled according to the back pressure strategy if the cache is full at this time, and the failed message is stored in the cache if the cache is not full at this time.
[0061] It is easy to understand that the message in the cache that fails to be pushed again can not be stored in the cache repeatedly.
[0062] In the embodiment or some other embodiments of the application, the method can further include:
[0063] After the message set is pushed to the receiving end, it is determined whether the push is successful;
[0064] If the push is not successful, the message in the message set is put into the cache as a failed message;
[0065] If the push is successful, the message set is continued to be composed according to the message in the cache and the identifier of the specified message and is pushed.
[0066] In addition, in some embodiments, the server can also store each message and the identifier of the message, that is, the method can further include:
[0067] After the message to be pushed to the receiving end is received and each message is given a unique identifier, each message and the identifier of the message are stored;
[0068] The request sent by the receiving end is received, and the request includes the identifier of the specified message;
[0069] According to the request, the specified message is read from the stored message and is sent to the receiving end.
[0070] In this way, the receiving end (consumer) can pull the previously discarded message according to the need of the receiving end by using the message query interface, so as to ensure the integrity of the data.
[0071] In addition, in order to prevent the situation that the failed message cannot be pushed because no new message arrives subsequently, in some scenarios, the method can further include:
[0072] The identifier of the failed message in the cache is sent to the receiving end periodically.
[0073] The server can start a timer to detect periodically, and the failed message identifier is pushed. The receiving end can pull the previously failed message by using the message query interface according to the need of the receiving end, so as to ensure the integrity of the data.
[0074] The following further describes the scheme of the application by taking push as HTTP push and the server as an Internet of Things platform, in combination with a specific application scenario. Of course, the following application scenario is only exemplary, and in actual applications, it can also be applicable to other application scenarios.
[0075] In the embodiment, the rate of data push is controlled by a back pressure mechanism, and the discarded data of the Internet of Things platform is synchronized by a pull compensation mechanism. The HTTP push system of the Internet of Things platform supporting the back pressure mechanism can be composed of three parts, as shown in Figure 3 Figure 3 which is a schematic diagram of the HTTP push system in a specific application example.
[0076] The HTTP push system of the Internet of Things platform supporting the back pressure mechanism can be composed of three parts: a device, an Internet of Things platform, and a data receiving end.
[0077] Device: The Internet of Things device connects the access service of the Internet of Things platform and reports device data.
[0078] Internet of Things platform: The configuration service is used to configure push rules, addresses, back pressure strategies, etc.; the access service is used to receive the data reported by the device; the message middleware Kafka is used to cache device data; the push service consumes data from Kafka and pushes data according to the back pressure strategy; Redis is used to cache device data for each rule, a list of discarded message IDs, and other information.
[0079] Data receiving end: passively receives the data pushed by the Internet of Things platform, and can also actively pull the discarded messages according to the discarded message ID (or message identifier, message number) through a pull interface.
[0080] The HTTP push method of the Internet of Things platform supporting the back pressure mechanism can mainly be divided into three steps of push rule configuration, data push, and message pull compensation.
[0081] i) Rule configuration
[0082] Compared with the common HTTP push system, when performing the HTTP push instance, in addition to configuring the push rule and the URL, the maximum number of concurrent push, the cache maximum value, the back pressure strategy, and the push timeout time can also be configured.
[0083] In order to support the back pressure strategy, compared with the traditional HTTP push interface, the HTTP push interface of the present scheme can carry additional parameters:
[0084] 1) Push rule state (for example, Disable or Enable).
[0085] 2) List of discarded message numbers.
[0086] 3) The push interface can contain the push rule state, the list of discarded message numbers, and the data to be pushed, or only one or any two of them.
[0087] The back pressure strategy supports the following modes:
[0088] 1) Error mode: When the number of cached messages is greater than or equal to the maximum cache value, the current rule is set to the Disable state, and no new message is processed except the data being processed, unless the customer manually sets the rule state to the Enable state. At the same time, when the Internet of Things platform pushes data, it passes the push rule state information, i.e., notifies the receiving end that the current rule has been disabled.
[0089] 2) Discard mode: When the number of cached messages is greater than or equal to the maximum cache value, the newly arrived messages are discarded, but the message numbers of the discarded messages are recorded. The message numbers of the discarded messages are carried to the receiving end at the next data push. Since there are many discarded messages and it may not be convenient to carry all the message numbers of the discarded messages at one time, a separate push request can be initiated, in which only the list of message numbers of the discarded messages is carried.
[0090] 3) Retention mode: This mode is similar to the discard mode, except that the oldest cached message is discarded instead of the newly arrived message.
[0091] The configured timeout time is used to set a timeout for the push, and if the receiving end does not return within the specified timeout time, the push is considered to have failed.
[0092] For example, if the user does not configure, the Internet of Things platform can default the maximum number of concurrent connections to 10, the number of cached messages to 128, the back pressure strategy to retain the latest message, and the timeout time to 5 seconds.
[0093] ii) Data push
[0094] The Internet of Things platform supports the HTTP push method with a back pressure mechanism. The specific implementation process can be seen in Figure 4 , which is an HTTP push flowchart in a specific application example. Figure 4
[0095] The steps can be as follows:
[0096] Step 1: Configure the rule. After the user configures the rule, the Internet of Things platform creates a corresponding number of tokens for each rule according to the configured maximum number of concurrent connections. Through the configured maximum number of concurrent connections, the push rate can be limited to prevent the consumer from being unable to process and causing a memory overflow and system crash.
[0097] Step 2: Receive device data. The device reports data to the IoT platform access service.
[0098] Step 3: Add message number. The device access service of the IoT platform receives device data and generates a unique identifier (i.e., number, ID) for each message. In subsequent operations, data can be queried by this unique identifier. Then send the message to the message queue Kafka.
[0099] Step 4: Consume data from the message queue. The data push service of the IoT platform obtains data from the message queue, and then finds the push rule that this data satisfies. The storage service of the IoT platform also consumes data from the message queue and stores it in the database. At the same time, an interface is exposed for querying data by message identifier, and the consumer can actively obtain discarded messages using this interface.
[0100] Step 5: Get the corresponding rule of the data.
[0101] If the push rule is in the disabled state, discard the message, otherwise go to Step 6.
[0102] Step 6: Get token. The IoT platform obtains a token corresponding to the rule.
[0103] Determine if the acquisition is successful.
[0104] If the acquisition is successful, go to Step 7, otherwise go to Step 10.
[0105] Step 7: Combine and push the push message. The IoT platform checks whether there are any unreported failed messages for the current push rule. If there are, take a certain number of failed messages, for example, 100 by default, and combine these messages with the data to be pushed and push them to the URL address corresponding to the rule.
[0106] Determine if the push is successful.
[0107] If the push is successful, go to Step 8, otherwise go to Step 9.
[0108] Through the identifier of the failed message, the consumer can pull the failed push message according to its own needs using the message query interface, ensuring the integrity of the data.
[0109] Step 8: If the push is successful, check whether there are any messages to be processed in the cache corresponding to the current rule. If there are, take one to continue pushing, otherwise return the token;
[0110] Step 9: If the push fails or times out, the token needs to be returned, and the current message number and the message number carried in the message are placed in the failed message queue (added to the failed list) again, waiting for the next data push.
[0111] To prevent the situation that the failed message cannot be notified due to no new message arriving subsequently, the Internet of Things platform can start a timer to detect and push the failed message number in a timely manner.
[0112] Step 10: If the token acquisition fails, it is detected whether the cache is full. If not, the message is stored in the cache. Otherwise, the current back pressure strategy is detected. If the back pressure strategy is the error mode, go to Step 11; if the back pressure strategy is the discard mode, go to Step 12; if the back pressure strategy is the keep mode, go to Step 13.
[0113] Different back pressure strategy mechanisms can achieve different effects. The default strategy is the keep mode, in which the latest message is kept, so as to ensure that the data processed at the consumer end is the latest data, and the HTTP push is timely.
[0114] Step 11: Set the current rule state to disabled, and no longer process subsequent messages, unless manually enabled by the user.
[0115] Step 12: Discard the current message, and record the number of the discarded message.
[0116] Step 13: Discard the oldest message in the cache, and store the current message in the cache, and record the number of the discarded message.
[0117] iii) Data pull compensation
[0118] As a compensation mechanism, the Internet of Things platform provides a message pull interface, and the receiving end can pull the lost message through the pull interface at any time after receiving the message number of the discarded message, so as to ensure the integrity of the data. In each pushed message, a list of lost messages can be carried, and the receiving end can pull the lost messages as needed.
[0119] The embodiment controls the rate of data push through the back pressure mechanism, which can effectively prevent the problem of avalanche caused by weak processing capacity of the receiving end. In addition, the pull compensation mechanism is used to synchronize the discarded data of the Internet of Things platform, so that the receiving end can pull the discarded message as needed after receiving the identifier of the discarded message, so as to ensure the integrity of the data.
[0120] The embodiment of the application further provides a message push method applied to a receiving end. Figure 5 As shown in the figure, Figure 5is a flowchart of a message pushing method applied to a receiving end provided by an embodiment of the present application.
[0121] The method can include:
[0122] In step S501, a message set pushed by a server is received, wherein the message set includes an identifier of a specified message, and the specified message includes a message that has been discarded by the server and unknown to the receiving end.
[0123] In step S502, a request is sent to the server, wherein the request includes the identifier of the specified message.
[0124] In step S503, the specified message sent by the server is received.
[0125] In this way, the receiving end can pull the previously discarded message according to its own needs by using the message query interface, thereby ensuring the integrity of the data.
[0126] In the embodiment or some other embodiments of the present application, the method can further include:
[0127] periodically receiving an identifier of a message previously failed to be pushed by the server sent by the server;
[0128] sending a request to the server, wherein the request includes the identifier of the message previously failed to be pushed;
[0129] receiving the message previously failed to be pushed sent by the server.
[0130] In this way, the situation that the failed message cannot be pushed due to no new message arriving subsequently can be prevented. The server side can start a timer to detect and push the identifier of the failed message periodically, and the receiving end can pull the previously failed message according to its own needs by using the message query interface, thereby ensuring the integrity of the data.
[0131] An embodiment of the present application further provides a message pushing device applied to a server. Referring to Figure 6 as shown in the figure, Figure 6 is a schematic diagram of a message pushing device applied to a server provided by an embodiment of the present application.
[0132] The device includes:
[0133] A configuration rule acquisition module 601 is configured to acquire a configuration rule, wherein the configuration rule includes a maximum concurrent pushing number, a maximum cache value, and a back pressure strategy, the maximum concurrent pushing number is a maximum concurrent pushing number when pushing a message to a receiving end, the maximum cache value is a maximum number of messages that can be cached after a message pushing failure, and the back pressure strategy is used to indicate a processing manner after a current number of cached messages reaches the maximum cache value.
[0134] The message receiving module 602 is configured to receive messages to be pushed to the receiving end and assign a unique identifier to each message.
[0135] The pushing module 603 is configured to determine whether a pushing permission is obtained. If the pushing permission is obtained, the message set is pushed to the receiving end, wherein the message set comprises one or more of the following data: the latest message, the message in the cache, and the identifier of the specified message, wherein the specified message comprises a message that has been discarded and unknown to the receiving end. If the pushing permission is not obtained, it is determined whether the number of messages in the cache has reached the maximum value of the cache. If the number of messages in the cache has not reached the maximum value of the cache, the message in the message set is stored in the cache as a message of pushing failure. If the number of messages in the cache has reached the maximum value of the cache, the message set is processed according to the back pressure strategy.
[0136] It should be noted that the message pushing device corresponds to the message pushing method applied to the server, and all implementation manners in the method embodiments are applicable to the device embodiments, and the same technical effects can be achieved.
[0137] The application also provides a message pushing device applied to a receiving end. Referring to FIG. 7, Figure 7 Figure 7 is a schematic diagram of the message pushing device applied to the receiving end according to an embodiment of the application.
[0138] The device can include:
[0139] The message receiving module 701 is configured to receive a message set pushed by a server, wherein the message set comprises an identifier of a specified message, and the specified message comprises a message that has been discarded by the server and unknown to the receiving end; and receive the specified message sent by the server.
[0140] The message pulling module 702 is configured to send a request to the server, wherein the request comprises the identifier of the specified message.
[0141] It should be noted that the message pushing device corresponds to the message pushing method applied to the receiving end, and all implementation manners in the method embodiments are applicable to the device embodiments, and the same technical effects can be achieved.
[0142] Figure 8 FIG. 8 shows a hardware structure schematic diagram of a terminal device according to an embodiment of the application.
[0143] The terminal device can include a processor 1001 and a memory 1002 storing computer program instructions.
[0144] Specifically, the processor 1001 can include a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or can be configured to implement one or more integrated circuits that embody the embodiments of the present application.
[0145] The memory 1002 can include mass storage for data or instructions. As an example and not by way of limitation, the memory 1002 can include a hard disk drive (HDD), a floppy disk drive, flash memory, an optical disc (e.g., a compact disc (CD) or a digital versatile disc (DVD)), a solid-state drive (SSD), a USB drive, or a combination of two or more of these. Where appropriate, the memory 1002 can include removable or non-removable (or fixed) media, where appropriate. The memory 1002 can be internal or external to the integrated gateway disaster recovery device. In particular embodiments, the memory 1002 is non-volatile, solid-state memory.
[0146] In particular embodiments, the memory 1002 can include read-only memory (ROM), random access memory (RAM), a disk storage medium device, an optical storage medium device, a flash memory device, electrical, optical, or other physical / tangible memory storage devices. Thus, in general, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., a memory device) encoded with software that, when executed (by one or more processors), is operable to perform operations described with reference to the methods according to an aspect of the present disclosure.
[0147] The processor 1001 implements any one of the message pushing methods in the above embodiments by reading and executing computer program instructions stored in the memory 1002.
[0148] In one example, the terminal device can further include a communication interface 1003 and a bus 1010. As shown, the processor 1001, the memory 1002, the communication interface 1003 are connected through the bus 1010 and complete communication between each other. Figure 8
[0149] The communication interface 1003 is mainly used to realize the communication between each module, device, unit and / or equipment in the embodiments of the present application.
[0150] Bus 1010 includes a hardware, software, or both that couples components of the online data traffic metering device to each other. As an example without limitation, a bus can include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand (IB) interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or another suitable bus or a combination of two or more of these. Where appropriate, bus 1010 can include one or more buses. Although the example embodiments described and illustrated herein relate to a particular bus configuration, the application contemplates any suitable bus or interconnect.
[0151] In addition, in combination with the message pushing method in the above-mentioned embodiments, the embodiments of the present application can provide a computer storage medium for implementation. The computer storage medium has computer program instructions stored thereon; the computer program instructions are executed by a processor to implement any of the message pushing methods in the above-mentioned embodiments.
[0152] It needs to be made clear that the present application is not limited to the specific configurations and processes described above and shown in the drawings. For the sake of brevity, detailed descriptions of well-known methods are omitted herein. In the above-mentioned embodiments, several specific steps are described and shown as examples. However, the method processes of the present application are not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between steps, after understanding the spirit of the present application.
[0153] The functional blocks shown in the above structural block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a functional card, etc. When implemented in software, the elements of the present application are program or code segments used to perform the required tasks. The program or code segments can be stored in a machine-readable medium or transmitted through a data signal carried in a carrier wave over a transmission medium or communication link. The "machine-readable medium" can include any medium capable of storing or transmitting information. Examples of the machine-readable medium include an electronic circuit, a semiconductor memory device, a ROM, a flash memory, an erasable ROM (EROM), a floppy disk, a CD-ROM, an optical disk, a hard disk, an optical fiber medium, a radio frequency (RF) link, etc. The code segments can be downloaded via a computer network such as the Internet, an intranet, etc.
[0154] It should also be noted that the example embodiments mentioned in the present application describe some methods or systems based on a series of steps or devices. However, the present application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiments, or in an order different from the embodiments, or several steps can be performed simultaneously.
[0155] The computer program instructions can also be loaded onto a computer, other programmable data processing apparatus, or other processing device to cause a series of operational steps to be performed on the computer, other programmable apparatus or other processing device to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide processes for implementing the functions / acts specified in the flowchart and / or block diagram block or blocks.
[0156] The above is merely specific implementation of the present application, and those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described system, module and unit can refer to the corresponding process in the foregoing method embodiments, which will not be described herein. It should be understood that the protection scope of the present application is not limited to this, and any person skilled in the art can easily think of various equivalent modifications or replacements within the technical range disclosed in the present application, and these modifications or replacements shall be covered within the protection scope of the present application.
Claims
1. A message push method, applied to a server, characterized in that, The method includes: Obtain configuration rules, which include maximum concurrent push count, maximum cache value, and backpressure strategy. The maximum concurrent push count is the maximum number of concurrent pushes when pushing messages to the receiving end. The maximum cache value is the maximum number of messages that can be cached after a message push failure. The backpressure strategy is used to indicate the processing method after the current number of cached messages reaches the maximum cache value. Receive messages that will be pushed to the receiving end and assign a unique identifier to each message; Determine whether push notification permission has been granted; If push permission is granted, a set of messages is pushed to the receiving end, wherein the set of messages includes one or more of the following data: latest messages, cached messages, and identifiers of specified messages, wherein the specified messages include messages that have been discarded and the receiving end is unaware of them; If push permission is not obtained, it is determined whether the current number of cached messages has reached the maximum cache value. If not, the messages in the message set are stored in the cache as push failure messages. If the limit is reached, the backpressure strategy is applied.
2. The method according to claim 1, characterized in that, The back pressure strategy includes: Error mode: No longer process newly received messages and notify the receiving end; Discard mode: All newly received messages will be discarded, and the identifier of the discarded message will be recorded; Retention mode: The oldest message in the cache will be discarded, and the identifier of the discarded message will be recorded.
3. The method according to claim 1, characterized in that, The method further includes: After pushing the message set to the receiving end, determine whether the push was successful; If the push fails, the messages in the aforementioned message set will be placed in the cache as push failure messages; If the push is successful, the message set will be further composed based on the messages in the cache and the identifier of the specified message and then pushed.
4. The method according to claim 1, characterized in that, The method further includes: After receiving the message to be pushed to the receiving end and assigning a unique identifier to each message, store each message and its identifier; Receive a request from the receiving end, wherein the request includes an identifier of the specified message; According to the request, the specified message is read from the stored messages and sent to the receiving end.
5. The method according to claim 1, characterized in that, The method further includes: Periodically send an identifier of a failed push message in the cache to the receiving end.
6. The method according to claim 1, characterized in that, The push notification is an HTTP push notification, and the server is used for an IoT platform.
7. A message push method, applied at a receiving end, characterized in that, The method includes: The receiver receives a set of messages pushed by the server, wherein the set of messages includes an identifier for a specified message, and the specified message includes messages that have been discarded by the server and for which the receiver is unaware. Send a request to the server, the request including an identifier of the specified message; Receive the specified message sent by the server; The server obtains configuration rules, which include a maximum concurrent push count, a maximum cache value, and a backpressure strategy. The maximum concurrent push count is the maximum number of concurrent pushes when pushing messages to the receiving end. The maximum cache value is the maximum number of messages that can be cached after a message push failure. The backpressure strategy is used to indicate the processing method after the current number of cached messages reaches the maximum cache value. The server receives messages to be pushed to the receiving end and assigns a unique identifier to each message. The server determines whether it has obtained push permission; If the server obtains push permission, it pushes a set of messages to the receiving end, wherein the set of messages includes one or more of the following data: latest messages, cached messages, and identifiers of specified messages, wherein the specified messages include messages that have been discarded and the receiving end is unaware of them; If the server does not obtain push permission, it determines whether the current number of cached messages has reached the maximum cache value. If it has not reached the maximum cache value, the messages in the message set are stored in the cache as push failure messages. If the maximum cache value has been reached, the backpressure strategy is applied.
8. The method according to claim 7, characterized in that, The method further includes: Periodically receive an identifier from the server indicating a previous push failure message from the server; Send a request to the server, the request including an identifier of the previously failed push message; Receive the message from the server that the previous push failed.
9. A message push device, applied to a server, characterized in that, The device includes: The configuration rule acquisition module is used to acquire configuration rules, which include the maximum concurrent push count, the maximum cache value, and the back pressure strategy. The maximum concurrent push count is the maximum number of concurrent pushes when pushing messages to the receiving end. The maximum cache value is the maximum number of messages that can be cached after a message push failure. The back pressure strategy is used to indicate the processing method after the current number of cached messages reaches the maximum cache value. The message receiving module is used to receive messages that will be pushed to the receiving end and assign a unique identifier to each message; The push module is used to determine whether push permission is obtained. If push permission is obtained, a message set is pushed to the receiving end. The message set includes one or more of the following data: latest messages, cached messages, and identifiers of specified messages. The specified messages include messages that have been discarded and the receiving end is unaware of them. If push permission is not obtained, it is determined whether the current number of cached messages has reached the maximum cache value. If it has not reached the maximum cache value, the messages in the message set are stored in the cache as push failure messages. If it has reached the maximum cache value, the backpressure strategy is applied.
10. A message push device, applied at a receiving end, characterized in that, The device includes: A message receiving module is used to receive a set of messages pushed by a server, wherein the set of messages includes an identifier for a specified message, and the specified message includes a message that has been discarded by the server and the receiving end is unaware of it; and to receive the specified message sent by the server; A message retrieval module is used to send a request to the server, the request including an identifier of the specified message; The server obtains configuration rules, which include a maximum concurrent push count, a maximum cache value, and a backpressure strategy. The maximum concurrent push count is the maximum number of concurrent pushes when pushing messages to the receiving end. The maximum cache value is the maximum number of messages that can be cached after a message push failure. The backpressure strategy is used to indicate the processing method after the current number of cached messages reaches the maximum cache value. The server receives messages to be pushed to the receiving end and assigns a unique identifier to each message. The server determines whether it has obtained push permission; If the server obtains push permission, it pushes a set of messages to the receiving end, wherein the set of messages includes one or more of the following data: latest messages, cached messages, and identifiers of specified messages, wherein the specified messages include messages that have been discarded and the receiving end is unaware of them; If the server does not obtain push permission, it determines whether the current number of cached messages has reached the maximum cache value. If it has not reached the maximum cache value, the messages in the message set are stored in the cache as push failure messages. If the maximum cache value has been reached, the backpressure strategy is applied.
11. A terminal device, characterized in that, The device includes: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, it implements the message push method as described in any one of claims 1 to 6, or the message push method as described in any one of claims 7 to 8.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer program instructions, which, when executed by a processor, implement the message push method as described in any one of claims 1 to 6, or the message push method as described in any one of claims 7 to 8.