CN117061470B - Message pulling method, device and storage medium - Google Patents
Message pulling method, device and storage medium Download PDFInfo
- Publication number
- CN117061470B CN117061470B CN202311000830.XA CN202311000830A CN117061470B CN 117061470 B CN117061470 B CN 117061470B CN 202311000830 A CN202311000830 A CN 202311000830A CN 117061470 B CN117061470 B CN 117061470B
- Authority
- CN
- China
- Prior art keywords
- message
- pulling
- time
- messages
- request
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 84
- 230000000977 initiatory effect Effects 0.000 claims abstract description 4
- 238000012545 processing Methods 0.000 claims description 25
- 230000015654 memory Effects 0.000 claims description 19
- 230000001360 synchronised effect Effects 0.000 claims description 16
- 238000004590 computer program Methods 0.000 claims description 9
- 230000004044 response Effects 0.000 claims description 9
- 230000001960 triggered effect Effects 0.000 claims description 8
- 230000008569 process Effects 0.000 description 23
- 238000010586 diagram Methods 0.000 description 4
- 238000004891 communication Methods 0.000 description 3
- 230000006870 function Effects 0.000 description 2
- 230000003993 interaction Effects 0.000 description 2
- 239000004973 liquid crystal related substance Substances 0.000 description 2
- 230000002159 abnormal effect Effects 0.000 description 1
- 230000006978 adaptation Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 239000003550 marker Substances 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000001953 sensory effect Effects 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L51/00—User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
- H04L51/04—Real-time or near real-time messaging, e.g. instant messaging [IM]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L51/00—User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
- H04L51/21—Monitoring or handling of messages
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Information Transfer Between Computers (AREA)
Abstract
The application provides a message pulling method, a message pulling device and a storage medium. The method comprises the following steps: responding to a trigger message pulling condition, and acquiring a timestamp of a latest message stored locally to obtain a first time; subtracting the time threshold M from the first time to obtain a second time; based on the second time and a preset assembly rule, a first message ID is obtained; initiating a message pulling request to a server based on the pulling parameters, and receiving a target message returned based on the message pulling request; judging whether the number of the target messages is less than S, and taking the message ID of the S-N message in the target message as a pulling parameter of the next cycle under the condition that the number of the target messages is equal to S; until the number of target messages returned based on the message pull request is less than S. The message loss phenomenon is effectively prevented.
Description
Technical Field
The present application relates to the field of mobile internet technologies, and in particular, to a message pulling method, a device and a storage medium.
Background
For instant messaging systems, message must be one of the important conditions for measuring the stability and reliability of the whole system, and message pulling of clients is an essential link. In general, message pulling can be divided into two scenarios: firstly, synchronizing online messages; the other is the pull of the offline message. On the premise of maximally reducing the pressure of the platform, how to completely pull the message is a problem to be solved at present.
In an instant messaging system, HTTP protocol is generally used for requesting synchronization for a large number of message pulls, but to achieve real-time and effective data synchronization, a complete pull mechanism needs to be established.
In an instant messaging system, a server message queue is generally arranged and processed according to a time sequence, and under normal conditions, a client only needs to record the message ID of a latest message which is already pulled locally, and when the next pulling condition triggers, the message ID carrying the latest message locally initiates a request to the server, so that unread messages positioned behind the message ID in the server message queue can be synchronized. However, the background server for receiving the front-end message adopts multi-node cluster deployment, and because of the difference of the processing speed of each node, the message sent by the client side sequentially is processed by different nodes at the server side, and the situation that the message after the message is processed first possibly occurs, while in the prior art, the pulling method for the message is carried out on the premise that the server can guarantee that the message is put in storage in sequence in percentage, the message is lost and omitted, the prior art is over ideal, and the data error formed in the actual environment is ignored.
Disclosure of Invention
The application provides a message pulling method, a message pulling device and a message pulling system, which are used for at least solving the problem of message loss. The technical scheme of the application is as follows:
in a first aspect, an embodiment of the present application provides a message pulling method, which is used for a client, and the method includes:
responding to a trigger message pulling condition, and acquiring a timestamp of a latest message stored locally to obtain a first time;
Subtracting a time threshold M from the first time to obtain a second time; based on the second time and a preset assembly rule, obtaining a first message Identity (ID); wherein the time threshold M is an upper limit value of a time difference between messages which are not synchronized at the same time;
circularly executing the following operations until the number of the target messages returned based on the message pulling request is less than S; the upper limit value of the number of message pulling request pulling message pieces is S, and S is a positive integer;
The message pulling request is initiated to a server based on the pulling parameters, and a target message returned based on the message pulling request is received; judging whether the number of the target messages is smaller than S, and taking the message ID of the S-N message in the target messages as a pulling parameter of the next cycle under the condition that the number of the target messages is equal to S; the first-time circulated pulling parameter is the first message ID; wherein, N is the upper limit value of the number of the asynchronous messages at the same time.
In some implementations, the message pull condition is an offline message pull condition, the method further comprising:
and triggering an offline message pulling condition in response to the login success triggering information.
In some implementations, the message pull condition is an online message pull condition, the method further comprising:
establishing long connection with a server, and receiving a new message sent by the server through the long connection;
acquiring a message ID of a new message sent by the server to obtain a second message ID;
comparing the second message ID with the message ID of the latest message stored locally;
and triggering an online message pulling condition when the second message ID is larger than the message ID of the latest message stored locally.
In some implementations, after the number of the target messages returned by the message pull request is less than S, the method further includes:
comparing the second message ID with the message ID of the latest message in the target message;
An online message pull condition is triggered if the second message ID is greater than a message ID of a latest message in the target message.
In some implementations, the preset assembly rule is a message assembly rule corresponding to a server.
In some implementations, the message pull request is a message pull HTTP request.
In a second aspect, an embodiment of the present application provides a message pulling apparatus, including:
The message processing module is used for responding to the trigger message pulling condition, acquiring the timestamp of the latest message stored locally and obtaining the first time;
The identification acquisition module is used for subtracting the time threshold M from the first time to obtain a second time; based on the second time and a preset assembly rule, obtaining a first message Identity (ID); wherein the time threshold M is an upper limit value of a time difference between messages which are not synchronized at the same time;
The circulation control module is used for circularly executing the following operations until the number of the target messages returned based on the message pulling request is smaller than S; the upper limit value of the number of message pulling request pulling message pieces is S, and S is a positive integer;
The message pulling module is used for initiating the message pulling request to the server based on the pulling parameters and receiving a target message returned based on the message pulling request; judging whether the number of the target messages is smaller than S, and taking the message ID of the S-N message in the target messages as a pulling parameter of the next cycle under the condition that the number of the target messages is equal to S; the first-time circulated pulling parameter is the first message ID; wherein, N is the upper limit value of the number of the asynchronous messages at the same time.
In some implementations, the message pull condition is an offline message pull condition, and the apparatus further includes a pull trigger module configured to:
and triggering an offline message pulling condition in response to the login success triggering information.
In some implementations, the message pulling condition is an online message pulling condition, and the pulling trigger module is further configured to:
establishing long connection with a server, and receiving a new message sent by the server through the long connection;
acquiring a message ID of a new message sent by the server to obtain a second message ID;
comparing the second message ID with the message ID of the latest message stored locally;
and triggering an online message pulling condition when the second message ID is larger than the message ID of the latest message stored locally.
In some implementations, the pull trigger module is further configured to, after the number of target messages returned based on the message pull request is less than S:
comparing the second message ID with the message ID of the latest message in the target message;
An online message pull condition is triggered if the second message ID is greater than a message ID of a latest message in the target message.
In some implementations, the preset assembly rule is a message assembly rule corresponding to the server.
In some implementations, the message pull request is a message pull HTTP request.
In a third aspect, an embodiment of the present application provides an electronic device, including: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the message pulling method according to the embodiment of the first aspect of the present application.
In a fourth aspect, embodiments of the present application provide a non-transitory computer readable storage medium storing computer instructions for causing a computer to perform a message pulling method according to an embodiment of the first aspect of the present application.
In a fifth aspect, embodiments of the present application provide a computer program product comprising computer instructions which, when executed by a processor, implement the steps of the message pulling method according to the embodiments of the first aspect of the present application.
The technical scheme provided by the embodiment of the application at least has the following beneficial effects:
By the compensation method for pulling the new message after the time stamp of the new message moves forward by the time threshold, the message warehousing error generated by the server due to multi-node cluster deployment is compensated, and the phenomenon of message loss is effectively prevented. By using the message ID of the (S-N) th message returned by the current paging request as a pulling parameter in the process of completely pulling the message once, each paging request ensures that the N new messages have no condition of losing the message. The message pulling strategy is perfected through the client, the server does not need to do extra marking processing, the processing pressure of the message queue of the server is reduced, and the stability of the instant messaging system is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the application as claimed.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description, serve to explain the principles of the application and do not constitute a undue limitation on the application.
Fig. 1 is a flow chart illustrating a message pulling method according to an exemplary embodiment.
Fig. 2 is a flow chart illustrating a message pulling method according to another exemplary embodiment.
Fig. 3 is a flow chart illustrating a message pulling method according to yet another exemplary embodiment.
Fig. 4 is a block diagram illustrating a message pulling apparatus according to an example embodiment.
Fig. 5 is a block diagram of an electronic device, according to an example embodiment.
Detailed Description
In order to enable a person skilled in the art to better understand the technical solutions of the present application, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like herein are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the application described herein may be implemented in sequences other than those illustrated or otherwise described herein. The implementations described in the following exemplary examples do not represent all implementations consistent with the application. Rather, they are merely examples of apparatus and methods consistent with aspects of the application as detailed in the accompanying claims.
ID is an abbreviation of English IDentity, and is IDentity.
HTTP (Hypertext Transfer Protocol ).
In an instant messaging system, a server message queue is generally arranged and processed according to a time sequence, and under normal conditions, a client only needs to record the message ID of a latest message which is pulled locally, and when a message pulling condition triggers next time, the message ID carrying the latest message locally initiates a request, so that the unread messages behind the message ID of the latest message can be synchronized.
However, the background service module for receiving the front-end message adopts multi-node cluster deployment, and as the processing speed of each node is affected by the comprehensive factors such as the hardware and software of the machine, the processing speed is different, so that the messages sent by the client side sequentially can be processed by different nodes falling to the server side, and the situation that the later messages are processed first can occur, so that the scheme of pulling the latest message simply through the marker bit has defects.
How to synchronize the lost message to the client due to multiple nodes requires the server or the client to fill the vulnerability by technical means. For the server, it is impossible to establish an information table for each client to store the last message pull condition, and it is impossible to establish client pull information for each message, so it is impossible to know which messages are not pulled to the local area by the current client, and it only can guarantee data sequence storage as far as possible. Therefore, aiming at the abnormal situation of the lost message, the client is required to perfect a pull system, so that the message is ensured to be arrived.
In order to solve the above problems, an embodiment of the present application provides a message pulling method, which aims at the situation that all messages cannot be guaranteed to be put in storage in sequence in percentage, and makes a client execute additional data processing when pulling the messages, so as to compensate data errors brought by a server and ensure that the messages must be arrived.
Because the service side message service is basically put in storage according to the sequence, the asynchronous message processing can only occur under the condition of high concurrence, the time difference of the asynchronous messages at the same time can be generally determined not to exceed M seconds, and the number of the asynchronous messages does not exceed N, therefore, the client side in the embodiment of the application can deploy two sets of message pulling flows for offline messages and online messages respectively based on the error characteristics.
Fig. 1 is a flow chart of a message pulling method according to one embodiment of the application. It should be noted that, the message pulling method of the embodiment of the present application may be applied to the message pulling device of the embodiment of the present application. The message pulling device can be configured on electronic equipment such as a mobile phone and the like. As shown in fig. 1, the message pulling method may include the following steps.
In step S101, in response to the trigger message pulling condition, a timestamp of the latest message stored locally is acquired, resulting in a first time.
It should be noted that, the server adds a time stamp attribute to each message, so that the time sequence of the messages can be ensured, the client can obtain the message ID and the message time of the message by decomposing the message, and can generate the message ID corresponding to the rule of the server by the time stamp.
The client responds to the message pulling triggering condition, acquires the timestamp of the latest message stored locally, and obtains the first time, wherein the first time is the attribute value of the timestamp attribute of the latest message stored locally, so that the message can be pulled through the first time later.
It should be further noted that, the message pulling conditions may be triggered in two scenarios, namely an offline scenario and an online scenario, and the offline message pulling process is completed according to the triggering of the offline scenario corresponding to the offline message pulling conditions; and aiming at triggering of the online scene corresponding to the online message pulling condition, completing the online message pulling process.
In step S102, subtracting the time threshold M from the first time to obtain a second time; based on the second time and a preset assembly rule, a first message ID is obtained; the time threshold M is an upper limit value of a time difference between messages which are not synchronized at the same time.
It can be understood that, because the service side message service basically stores in sequence, the message processing is not synchronous only under the condition of high concurrency, and it can be generally determined that the time difference of the messages in which the asynchronous occurs at the same time does not exceed M seconds, so that the timestamp of the latest message stored locally is moved forward by M seconds, and the obtained timestamp is the second time. And then automatically generating a message ID corresponding to the server rule through the second time.
In this embodiment, the preset assembly rule is a message assembly rule corresponding to the server.
In step S103, the following operations are cyclically performed until the number of target messages returned based on the message pull request is less than S; the upper limit value of the number of message pulling request pulling cancellation messages is S, and S is a positive integer.
Because the number of messages that can be pulled per message pulling request is limited, the upper limit of the number of message pulling requests in this embodiment is S, that is, a maximum of S new messages are pulled per message pulling request.
In the case of a relatively large number of new messages, it may be necessary to cycle through multiple initiation message pull requests to pull all of the new messages. That is, the process of pulling all new messages is referred to as a process of pulling a message in its entirety. In the process of completely pulling the message once, each initiated message pulling request can be used as a paging request, and the process of completely pulling the message once may include a plurality of paging requests, so that the process of completely pulling the message once is realized through circulation.
In step S104, a message pulling request is initiated to a server based on the pulling parameters, and a target message returned based on the message pulling request is received; judging whether the number of the target messages is less than S, and taking the message ID of the S-N message in the target message as a pulling parameter of the next cycle under the condition that the number of the target messages is equal to S; the pulling parameter of the first cycle is a first message ID; wherein N is the upper limit value of the number of messages which are not synchronized at the same time.
Wherein N is less than S.
In this embodiment, the message pull request is a message pull HTTP request.
Because the service side message service is basically put in storage according to the sequence, the message processing is asynchronous only under the condition of high concurrency, and the number of messages which are asynchronous at the same time can be generally determined not to exceed N.
That is, the first message ID is used as a pulling parameter to initiate a first message to pull the HTTP request, so that a maximum of S new messages are pulled, so that it can be ensured that the message possibly lost in the last message to pull the HTTP request can be synchronized to the local, and thus, the time error of processing the message queue at the server side is compensated.
After the HTTP request is pulled for the first time, if the number of the pulled messages is less than S, the client is considered to have no more new messages at the server, and the message pulling is completed; if the number of the pulled messages is S, the message ID of the (S-N) th message returned by the message pulling HTTP request initiated at the present time is used as a pulling parameter to initiate the next message pulling HTTP request, so that the situation that the latest N pieces of data cannot lose the messages can be ensured, and the like, and the whole message pulling process is calculated until the number of the messages pulled at a time is less than S.
According to the message pulling method, the compensation method for pulling the message after the time stamp of the new message is moved forward by the time threshold value is used for making up the message warehouse-in error generated by the server due to multi-node cluster deployment, and the message loss phenomenon is effectively prevented. By using the message ID of the (S-N) th message returned by the current paging request as a pulling parameter in the process of completely pulling the message once, each paging request ensures that the N new messages have no condition of losing the message. By means of time and number forward movement of the message bars, the message pulling strategy is perfected through the client, the server does not need to do additional marking processing, the processing pressure of the message queue of the server is reduced, and the stability of the instant messaging system is improved.
The pulling process for offline messages and online messages, respectively, is described in detail below.
Fig. 2 is a flow chart of a message pulling method according to another embodiment of the application. As shown in fig. 2, the message pulling method may include the following steps.
In step S201, an offline message pull condition is triggered in response to triggering the login success information.
That is, after the user logs in successfully, the offline message pulling condition is triggered, and the offline message pulling process is started.
In step S202, in response to triggering the offline message pulling condition, a timestamp of the latest message stored locally is obtained, resulting in a first time.
In step S203, subtracting the time threshold M from the first time to obtain a second time; based on the second time and a preset assembly rule, obtaining a first message Identity (ID); the time threshold M is an upper limit value of a time difference between messages which are not synchronized at the same time.
In step S204, the following operations are cyclically performed until the number of target messages returned based on the message pull request is less than S; the upper limit value of the number of message pulling request pulling cancellation messages is S, and S is a positive integer.
In step S205, a message pulling request is initiated to a server based on the pulling parameters, and a target message returned based on the message pulling request is received; judging whether the number of the target messages is less than S, and taking the message ID of the S-N message in the target message as a pulling parameter of the next cycle under the condition that the number of the target messages is equal to S; the pulling parameter of the first cycle is a first message ID; wherein N is the upper limit value of the number of messages which are not synchronized at the same time.
It should be noted that, in the embodiment of the present application, the implementation process of the step S202 to the step S205 may refer to the description of the implementation process of the step S101 to the step S104, which is not described herein.
According to the message pulling method, in the pulling process of the offline message, the message is pulled after the time stamp of the new message is moved forward by the time threshold value in the compensation method, so that the message warehousing error of the server caused by multi-node cluster deployment is compensated, and the message loss phenomenon is effectively prevented. By using the message ID of the (S-N) th message returned by the current paging request as a pulling parameter in the process of completely pulling the message once, each paging request ensures that the N new messages have no condition of losing the message. By means of time and number forward movement of the message bars, the message pulling strategy is perfected through the client, the server does not need to do additional marking processing, the processing pressure of the message queue of the server is reduced, and the stability of the instant messaging system is improved.
Fig. 3 is a flow chart of a message pulling method according to yet another embodiment of the present application. As shown in fig. 3, the message pulling method may include the following steps.
In step S301, a long connection with the server is established, and a new message sent by the server is received through the long connection.
In step S302, a message ID of a new message sent by the server is obtained, and a second message ID is obtained.
In step S303, comparing the second message ID with the message ID of the latest message stored locally, and triggering an online message pull condition if the second message ID is greater than the message ID of the latest message stored locally; when the second message ID is equal to or less than the message ID of the latest message in the target message, the present flow is ended.
In step S304, in response to triggering the online message pull condition, a timestamp of the latest message stored locally is obtained, resulting in a first time.
In step S305, subtracting the time threshold M from the first time to obtain a second time; based on the second time and a preset assembly rule, obtaining a first message Identity (ID); the time threshold M is an upper limit value of a time difference between messages which are not synchronized at the same time.
In step S306, step S307 is executed in a loop until the number of target messages returned based on the message pull request is less than S, and the process proceeds to step S303; the upper limit value of the number of message pulling request pulling cancellation messages is S, and S is a positive integer.
In step S307, a message pulling request is initiated to the server based on the pulling parameters, and a target message returned based on the message pulling request is received; judging whether the number of the target messages is less than S, and taking the message ID of the S-N message in the target message as a pulling parameter of the next cycle under the condition that the number of the target messages is equal to S; the pulling parameter of the first cycle is a first message ID; wherein N is the upper limit value of the number of messages which are not synchronized at the same time.
It should be noted that, in the embodiment of the present application, the implementation process of the step S304 to the step S307 may refer to the description of the implementation process of the step S101 to the step S104, which is not described herein.
According to the message pulling method, in the pulling process of the offline message, the message is pulled after the time stamp of the new message is moved forward by the time threshold value in the compensation method, so that the message warehousing error of the server caused by multi-node cluster deployment is compensated, and the message loss phenomenon is effectively prevented. By using the message ID of the (S-N) th message returned by the current paging request as a pulling parameter in the process of completely pulling the message once, each paging request ensures that the N new messages have no condition of losing the message. By means of time and number forward movement of the message bars, the message pulling strategy is perfected through the client, the server does not need to do additional marking processing, the processing pressure of the message queue of the server is reduced, and the stability of the instant messaging system is improved.
Fig. 4 is a block diagram illustrating a message pulling apparatus according to an example embodiment. Referring to fig. 4, the message pulling apparatus may include: a message processing module 401, an identification acquisition module 402, a loop control module 403, and a message pulling module 404.
Specifically, the message processing module 401 is configured to obtain, in response to a trigger message pulling condition, a timestamp of a latest message stored locally, so as to obtain a first time;
an identifier obtaining module 402, configured to subtract the time threshold M from the first time to obtain a second time; based on the second time and a preset assembly rule, a first message ID is obtained; wherein the time threshold M is the upper limit value of the time difference between the messages which are not synchronized at the same time;
A loop control module 403, configured to loop the following operations until the number of target messages returned based on the message pull request is less than S; the upper limit value of the number of message pulling request pulling cancellation messages is S, and S is a positive integer;
A message pulling module 404, configured to initiate a message pulling request to a server based on the pulling parameter, and receive a target message returned based on the message pulling request; judging whether the number of the target messages is less than S, and taking the message ID of the S-N message in the target message as a pulling parameter of the next cycle under the condition that the number of the target messages is less than S; the pulling parameter of the first cycle is a first message ID; wherein N is the upper limit value of the number of messages which are not synchronized at the same time.
In some implementations, the message pulling condition is an offline message pulling condition, and the apparatus further includes a pulling triggering module 405 configured to:
and triggering an offline message pulling condition in response to the login success triggering information.
In some implementations, the message pull condition is an online message pull condition, and the pull trigger module 405 is further configured to:
Establishing long connection with the server, and receiving a new message sent by the server through the long connection;
Obtaining a message ID of a new message sent by a server to obtain a second message ID;
comparing the second message ID with the message ID of the latest message stored locally;
an online message pull condition is triggered in the event that the second message ID is greater than the message ID of the locally stored latest message.
In some implementations, the pull trigger module 405, after the number of target messages returned based on the message pull request is less than S, is further configured to:
Comparing the second message ID with the message ID of the latest message in the target message;
An online message pull condition is triggered in the event that the second message ID is greater than the message ID of the latest message in the target message.
In some implementations, the preset assembly rule is a message assembly rule corresponding to the server, and in some implementations, the message pull request is a message pull HTTP request.
The specific manner in which the various modules perform the operations in the apparatus of the above embodiments have been described in detail in connection with the embodiments of the method, and will not be described in detail herein.
According to the message pulling device, the message storage error of the server caused by multi-node cluster deployment is compensated by the compensation method for pulling the message after the time stamp of the new message moves forward by the time threshold, so that the message loss phenomenon is effectively prevented. By using the message ID of the (S-N) th message returned by the current paging request as a pulling parameter in the process of completely pulling the message once, each paging request ensures that the N new messages have no condition of losing the message. By means of time and number forward movement of the message bars, the message pulling strategy is perfected through the client, the server does not need to do additional marking processing, the processing pressure of the message queue of the server is reduced, and the stability of the instant messaging system is improved.
According to an embodiment of the present application, the present application also provides an electronic device and a readable storage medium.
As shown in fig. 5, is a block diagram of an electronic device for implementing a method of message pulling in accordance with an embodiment of the present application. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the applications described and/or claimed herein.
As shown in fig. 5, the electronic device includes: one or more processors 501, memory 502, and interfaces for connecting components, including high-speed interfaces and low-speed interfaces. The various components are interconnected using different buses and may be mounted on a common motherboard or in other manners as desired. The processor may process instructions executing within the electronic device, including instructions stored in or on memory to display graphical information of the GUI on an external input/output device, such as a display device coupled to the interface. In other embodiments, multiple processors and/or multiple buses may be used, if desired, along with multiple memories and multiple memories. Also, multiple electronic devices may be connected, each providing a portion of the necessary operations (e.g., as a server array, a set of blade servers, or a multiprocessor system). One processor 501 is illustrated in fig. 5.
Memory 502 is a non-transitory computer readable storage medium provided by the present application. Wherein the memory stores instructions executable by the at least one processor to cause the at least one processor to perform the message pulling method provided by the present application. The non-transitory computer readable storage medium of the present application stores computer instructions for causing a computer to perform the method of message pulling provided by the present application.
The memory 502 is used as a non-transitory computer readable storage medium for storing non-transitory software programs, non-transitory computer-executable programs, and modules, such as program instructions/modules (e.g., the message processing module 401, the identifier acquisition module 402, the loop control module 403, and the message pulling module 404 shown in fig. 4) corresponding to a message pulling method in an embodiment of the present application. The processor 501 executes various functional applications of the server and data processing, i.e., implements the message pulling method in the above-described method embodiments, by running non-transitory software programs, instructions, and modules stored in the memory 502.
Memory 502 may include a storage program area that may store an operating system, at least one application program required for functionality, and a storage data area; the storage data area may store data created from the use of the electronic device pulled from the message, and the like. In addition, memory 502 may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory 502 may optionally include memory located remotely from processor 501, which may be connected to the message pulled electronic device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The electronic device of the message pulling method may further include: an input device 503 and an output device 504. The processor 501, memory 502, input devices 503 and output devices 504 may be connected by a bus or otherwise, for example in fig. 5.
The input device 503 may receive input numeric or character information and generate key signal inputs related to user settings and function control of the electronic device for message pulling, such as a touch screen, keypad, mouse, trackpad, touchpad, pointer stick, one or more mouse buttons, track ball, joystick, and like input devices. The output devices 504 may include a display device, auxiliary lighting devices (e.g., LEDs), and haptic feedback devices (e.g., vibration motors), among others. The display device may include, but is not limited to, a Liquid Crystal Display (LCD), a Light Emitting Diode (LED) display, and a plasma display. In some implementations, the display device may be a touch screen.
Various implementations of the systems and techniques described here can be realized in digital electronic circuitry, integrated circuitry, application specific ASIC (application specific integrated circuit), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
These computing programs (also referred to as programs, software applications, or code) include machine instructions for a programmable processor, and may be implemented in a high-level procedural and/or object-oriented programming language, and/or in assembly/machine language. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and/or device (e.g., magnetic discs, optical disks, memory, programmable Logic Devices (PLDs)) used to provide machine instructions and/or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal used to provide machine instructions and/or data to a programmable processor.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network).
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other.
In an exemplary embodiment, a computer program product is also provided, which, when instructions in the computer program product are executed by a processor of an electronic device, enables the electronic device to perform the above-described method.
It should also be noted that the exemplary embodiments mentioned in this disclosure describe some methods or systems based on a series of steps or devices. The present invention is not limited to the order of the above-described steps, that is, the steps may be performed in the order mentioned in the embodiments, or may be performed in a different order from the order in the embodiments, or several steps may be performed simultaneously.
Other embodiments of the application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. This application is intended to cover any variations, uses, or adaptations of the application following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the application pertains. The specification and examples are to be regarded in an illustrative manner only.
It is to be understood that the application is not limited to the precise arrangements and instrumentalities shown in the drawings, which have been described above, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the application is limited only by the appended claims.
Claims (10)
1. A message pulling method, for a client, the method comprising:
responding to a trigger message pulling condition, and acquiring a timestamp of a latest message stored locally to obtain a first time;
Subtracting a time threshold M from the first time to obtain a second time; based on the second time and a preset assembly rule, obtaining a first message Identity (ID); wherein the time threshold M is an upper limit value of a time difference between messages which are not synchronized at the same time;
circularly executing the following operations until the number of the target messages returned based on the message pulling request is less than S; the upper limit value of the number of message pulling request pulling message pieces is S, and S is a positive integer;
The message pulling request is initiated to a server based on the pulling parameters, and a target message returned based on the message pulling request is received; judging whether the number of the target messages is smaller than S, and taking the message ID of the S-N message in the target messages as a pulling parameter of the next cycle under the condition that the number of the target messages is equal to S; the first-time circulated pulling parameter is the first message ID; wherein, N is the upper limit value of the number of the asynchronous messages at the same time.
2. The method of claim 1, wherein the message pull condition is an offline message pull condition, the method further comprising:
and triggering an offline message pulling condition in response to the login success triggering information.
3. The method of claim 1, wherein the message pull condition is an online message pull condition, the method further comprising:
establishing long connection with a server, and receiving a new message sent by the server through the long connection;
acquiring a message ID of a new message sent by the server to obtain a second message ID;
comparing the second message ID with the message ID of the latest message stored locally;
and triggering an online message pulling condition when the second message ID is larger than the message ID of the latest message stored locally.
4. The method of claim 3, wherein after the number of target messages returned based on the message pull request is less than S, further comprising:
comparing the second message ID with the message ID of the latest message in the target message;
An online message pull condition is triggered if the second message ID is greater than a message ID of a latest message in the target message.
5. The method of claim 1, wherein the preset assembly rule is a message assembly rule corresponding to a server.
6. A method according to claim 3, wherein the message pull request is a message pull HTTP request.
7. A message pulling apparatus, comprising:
The message processing module is used for responding to the trigger message pulling condition, acquiring the timestamp of the latest message stored locally and obtaining the first time;
The identification acquisition module is used for subtracting the time threshold M from the first time to obtain a second time; based on the second time and a preset assembly rule, obtaining a first message Identity (ID); wherein the time threshold M is an upper limit value of a time difference between messages which are not synchronized at the same time;
The circulation control module is used for circularly executing the following operations until the number of the target messages returned based on the message pulling request is smaller than S; the upper limit value of the number of message pulling request pulling message pieces is S, and S is a positive integer;
The message pulling module is used for initiating the message pulling request to the server based on the pulling parameters and receiving a target message returned based on the message pulling request; judging whether the number of the target messages is smaller than S, and taking the message ID of the S-N message in the target messages as a pulling parameter of the next cycle under the condition that the number of the target messages is equal to S; the first-time circulated pulling parameter is the first message ID; wherein, N is the upper limit value of the number of the asynchronous messages at the same time.
8. An electronic device, comprising:
At least one processor; and
A memory communicatively coupled to the at least one processor; wherein,
The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the message pull method of any one of claims 1 to 6.
9. A non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the message pull method of any one of claims 1 to 6.
10. A computer program product comprising computer programs/instructions which, when executed by a processor, implement the steps of the method of any of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311000830.XA CN117061470B (en) | 2023-08-09 | 2023-08-09 | Message pulling method, device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311000830.XA CN117061470B (en) | 2023-08-09 | 2023-08-09 | Message pulling method, device and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN117061470A CN117061470A (en) | 2023-11-14 |
CN117061470B true CN117061470B (en) | 2024-07-26 |
Family
ID=88660139
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311000830.XA Active CN117061470B (en) | 2023-08-09 | 2023-08-09 | Message pulling method, device and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117061470B (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101707785A (en) * | 2009-10-31 | 2010-05-12 | 青岛海信移动通信技术股份有限公司 | Data synchronization method for mobile communication terminal |
CN112333080A (en) * | 2020-10-27 | 2021-02-05 | 合肥市智享亿云信息科技有限公司 | Instant communication off-line message pushing method |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104144116B (en) * | 2014-07-16 | 2016-04-27 | 腾讯科技(深圳)有限公司 | Instant communication method and instant communicating system |
CN113141522B (en) * | 2020-01-17 | 2022-09-20 | 北京达佳互联信息技术有限公司 | Resource transmission method, device, computer equipment and storage medium |
CN112367149B (en) * | 2020-10-28 | 2022-10-14 | 百果园技术(新加坡)有限公司 | Message acquisition method, device, equipment and storage medium |
CN115297076B (en) * | 2022-08-01 | 2024-03-19 | 招商局金融科技有限公司 | Offline message pulling method and device, computer equipment and storage medium |
-
2023
- 2023-08-09 CN CN202311000830.XA patent/CN117061470B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101707785A (en) * | 2009-10-31 | 2010-05-12 | 青岛海信移动通信技术股份有限公司 | Data synchronization method for mobile communication terminal |
CN112333080A (en) * | 2020-10-27 | 2021-02-05 | 合肥市智享亿云信息科技有限公司 | Instant communication off-line message pushing method |
Also Published As
Publication number | Publication date |
---|---|
CN117061470A (en) | 2023-11-14 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112202746B (en) | RPC member information acquisition method, device, electronic equipment and storage medium | |
CN111966651B (en) | Data synchronization method, device, electronic equipment and storage medium | |
CN110166562B (en) | Data synchronization method and device, storage medium and electronic equipment | |
CN114089974B (en) | Cloud code development system, method, device, equipment and storage medium | |
US11831735B2 (en) | Method and device for processing mini program data | |
CN112202567B (en) | Certificate sending method, cloud terminal and terminal equipment | |
EP3846419A2 (en) | File resource processing method and apparatus, device and medium | |
CN110659184B (en) | Health state checking method, device and system | |
KR102451678B1 (en) | Method and apparatus for data processing based on smart contract, device and storage medium | |
WO2016147073A1 (en) | Method and apparatus for identifying changed mailboxes in an internet message access protocol (imap) list | |
CN112486645A (en) | Timed task monitoring method and device, electronic equipment and medium | |
CN117061470B (en) | Message pulling method, device and storage medium | |
CN111770176A (en) | Traffic scheduling method and device | |
US11783565B2 (en) | Image processing method, electronic device and readable storage medium for maintaining a face image buffer queue | |
CN112069137A (en) | Method and device for generating information, electronic equipment and computer readable storage medium | |
CN110620701B (en) | Data stream monitoring processing method, device, equipment and storage medium | |
CN112148447B (en) | Task processing method and system based on risk control and electronic equipment | |
CN114095758A (en) | Cloud image intercepting method, related device and computer program product | |
CN107995022B (en) | Session synchronization method and device, storage medium and electronic equipment | |
CN117113942B (en) | Model synchronization method and device, electronic equipment and storage medium | |
CN112035279B (en) | Service calling method and device and electronic equipment | |
CN116614512B (en) | Method, device and equipment for managing strong consistency group view of distributed group communication | |
CN114978644B (en) | Method and device for testing distribution network function of software, electronic equipment and storage medium | |
CN115174447B (en) | Network communication method, device, system, equipment and storage medium | |
CN116319633A (en) | Instant messaging method, device, equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |