CN115883639A - Web real-time message pushing method and device, equipment and storage medium - Google Patents

Web real-time message pushing method and device, equipment and storage medium Download PDF

Info

Publication number
CN115883639A
CN115883639A CN202111143668.8A CN202111143668A CN115883639A CN 115883639 A CN115883639 A CN 115883639A CN 202111143668 A CN202111143668 A CN 202111143668A CN 115883639 A CN115883639 A CN 115883639A
Authority
CN
China
Prior art keywords
information
timestamp information
timestamp
client
server
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.)
Pending
Application number
CN202111143668.8A
Other languages
Chinese (zh)
Inventor
邹孝恒
李杰亮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Mobile Communications Group Co Ltd
China Mobile Suzhou Software Technology Co Ltd
Original Assignee
China Mobile Communications Group Co Ltd
China Mobile Suzhou Software Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Mobile Communications Group Co Ltd, China Mobile Suzhou Software Technology Co Ltd filed Critical China Mobile Communications Group Co Ltd
Priority to CN202111143668.8A priority Critical patent/CN115883639A/en
Publication of CN115883639A publication Critical patent/CN115883639A/en
Pending legal-status Critical Current

Links

Images

Abstract

The embodiment of the invention discloses a method, a device, equipment and a storage medium for pushing web real-time messages; the method comprises the steps that a server generates a first time stamp message and sends the first time stamp message to a client according to the time of modification operation in a database based on Graphql service and kafka service, and the client receives second time stamp information which is received by the client in the first time stamp information. And comparing the first timestamp information according to the second timestamp information to obtain lost information, and sending the lost information to the client. The embodiment of the invention can determine whether the data loss exists between the client and the server in the data interaction by comparing the data received by the client and the data difference sent by the server on the basis of realizing the real-time pushing of the web message, and if the data loss exists, the information loss is determined and the lost information is retransmitted; the success rate of data transmission is improved, and the risk of data loss is reduced.

Description

Web real-time message pushing method and device, equipment and storage medium
Technical Field
The present invention relates to the field of information technologies, and in particular, to a method, an apparatus, a device, and a storage medium for pushing a web real-time message.
Background
There are currently two ways to push web messages. One is a client polling mode: the client and the server are communicated with each other all the time, and the client sends a request to the server segment once every other period of time so as to acquire the latest data stored in the current database. The other is a message pushing mode based on the websocket protocol: the client sends out a websocket connection request, the server responds, and actions similar to TCP handshake are realized, so that an HTTP long connection fast channel is formed between the browser client and the websocket server and is used for direct data transmission between the browser client and the websocket server without connection and response. Meanwhile, both the browser client and the websocket server can select the long connection.
However, in the above technical solution, when the polling interval is too long, the polling mode of the client may cause the user not to receive the updated data in time; when the polling interval is too short, the query requests are too many, and the access pressure of the database and the load of the server are increased; and real-time pushing of the message cannot be realized. Although the message pushing mode based on the websocket protocol can realize real-time pushing of the message, the client does not receive the message after the server sends the message, that is, the message is lost.
Disclosure of Invention
The embodiment of the invention provides a web real-time message pushing method, a web real-time message pushing device, web real-time message pushing equipment and a web real-time message pushing storage medium, wherein on the basis of realizing the real-time pushing of web messages, whether data loss exists in data interaction between a client and a server is determined by comparing the difference between data received by the client and data sent by the server, and if the data loss exists, information loss is determined and the lost information is retransmitted; therefore, the success rate of data transmission is improved, and the risk of data loss is reduced.
The technical scheme of the invention is realized as follows:
the embodiment of the invention provides a web real-time message pushing method, which is applied to a server, wherein the server is provided with Graphql service and kafka service, and the method comprises the following steps:
receiving a modification identifier acquisition request through the Graphql service; the modification identifier acquisition request carries modification information;
responding to the modification identifier acquisition request, determining and sending first timestamp information corresponding to the modification information to a client through the Graphql service according to the modification information;
receiving an information query request through the Graphql service and the kafka service; the information query request carries second timestamp information; the second timestamp information is timestamp information received by the client;
responding to the information query request, determining lost information from the first timestamp information based on the second timestamp information, and sending the lost information to the client through the Graphql service; the lost information is timestamp information lost in data interaction in the first timestamp information.
In the foregoing solution, the determining, in response to the information query request and based on the second timestamp information and from the first timestamp information, loss information and sending the loss information to the client through the Graphql service includes:
comparing the first timestamp information based on the second timestamp information to obtain a comparison result;
and based on the comparison result, determining the loss information from the first timestamp information and sending the loss information to the client through the Graphql service.
In the foregoing solution, the comparing the first timestamp information based on the second timestamp information to obtain a comparison result includes:
comparing the first sub-timestamp information with the second sub-timestamp information until all timestamp information in the first timestamp information is screened to obtain a comparison result; the first sub-timestamp information is any one of the first timestamp information; the second sub-timestamp information is any one of the second timestamp information.
In the foregoing solution, the determining the loss information from the first timestamp information based on the comparison result and sending the loss information to the client through the Graphql service includes:
if the comparison result is that the first sub-timestamp information is different from the second sub-timestamp information; determining that the timestamp information corresponding to the first sub-timestamp information is sub-lost information;
determining the loss information from the sub-loss information.
In the foregoing solution, the determining the loss information from the sub-loss information includes:
and determining the sub-loss information with the largest value as the loss information from the sub-loss information.
In the above scheme, the method further comprises:
determining a reference information sample from the second timestamp information based on a preset period;
and deleting the first time stamp information based on the reference information sample.
In the foregoing solution, the determining a reference information sample from the second timestamp information based on a preset period includes:
and determining second sub-timestamp information with the maximum value as the reference information sample from the second timestamp information based on the preset period.
In the foregoing solution, the deleting the first timestamp information based on the reference information sample includes:
comparing the first sub-timestamp information based on the reference information sample to obtain a first comparison result;
and if the first comparison result is that the first sub-timestamp information is smaller than the reference information sample, deleting the timestamp information corresponding to the first sub-timestamp information.
In the above scheme, the method further comprises:
receiving a subscription request through the Graphql service; the subscription request carries the second timestamp information or the loss information;
responding to the subscription request, determining subscription information in a database according to the second timestamp information or the loss information, and sending the subscription information to a client through the Graphql service; wherein the subscription information characterizes a subject matter in the database relating to field changes at a time corresponding to the second timestamp information or the loss information.
The embodiment of the invention provides a web real-time message pushing method, which is applied to a client, wherein the client is provided with a Graphql API (application program interface), and the method comprises the following steps:
sending a modification identifier acquisition request to a server through the Graphql API; the modification identifier request carries modification information, and the client side realizes data interaction with the Graphql service of the server through the Graphql API
Receiving second timestamp information sent by the server in response to the modification identifier acquisition request through the Graphql API; the second timestamp information is timestamp information received by the client in the first timestamp information; the first timestamp information is timestamp information sent by the server;
sending the information query request to the server through the Graphql API; the information query request carries the second timestamp information;
receiving lost information sent by the server in response to the information query request through the Graphql API; the lost information is timestamp information lost in data interaction in the first timestamp information.
In the foregoing solution, the method further includes:
sending a subscription request to the server through the Graphql API; wherein the subscription request carries the second timestamp information or the loss information;
receiving subscription information sent by the server in response to the subscription request through the Graphql API; and the subscription information represents the subject of field change related to the time corresponding to the second timestamp information or the loss information in the database.
The embodiment of the invention provides a web real-time message pushing device, which comprises a first receiving unit, a determining unit and a first sending unit, wherein the first receiving unit is used for receiving a web real-time message; wherein the content of the first and second substances,
the first receiving unit is used for receiving a modification identifier acquisition request through a Graphql service; the modification identifier acquisition request carries modification information; receiving an information query request through the Graphql service and the kafka service; the information query request carries second timestamp information;
the determining unit is used for responding to the modification identifier obtaining request and determining first timestamp information corresponding to the modification information according to the modification information; determining loss information from the first timestamp information based on the second timestamp information in response to the information query request;
the first sending unit is configured to send the first timestamp information to a client through the Graphql service; for sending the loss information to the client via the Graphql service.
In the foregoing solution, the determining unit is further configured to compare the first timestamp information based on the second timestamp information to obtain a comparison result; and based on the comparison result, determining the loss information from the first timestamp information and sending the loss information to the client through the Graphql service.
In the above scheme, the determining unit is further configured to compare the first sub-timestamp information with the second sub-timestamp information until the first timestamp information is screened, so as to obtain a comparison result; the first sub-timestamp information is any one timestamp information in the first timestamp information; the second sub-timestamp information is any one of the second timestamp information.
In the foregoing solution, the determining unit is further configured to determine that the first sub-timestamp information is different from the second sub-timestamp information if the comparison result indicates that the first sub-timestamp information is different from the second sub-timestamp information; determining that the timestamp information corresponding to the first sub-timestamp information is sub-loss information; determining the loss information from the sub-loss information.
In the above solution, the determining unit is further configured to determine, from the sub-loss information, the sub-loss information with the largest value as the loss information.
In the above scheme, the apparatus further comprises a processing unit, wherein:
the determining unit is further configured to determine a reference information sample from the second timestamp information based on a preset period;
the processing unit is configured to perform a deletion process on the first timestamp information based on the reference information sample.
In the foregoing solution, the determining unit is further configured to determine, based on the preset period, a second sub-timestamp with a largest value from the second timestamp information as the reference information sample.
In the above solution, the processing unit is further configured to compare the first sub-timestamp information based on the reference information sample to obtain a first comparison result; and if the first comparison result shows that the first sub-timestamp information is smaller than the reference information sample, deleting the timestamp information corresponding to the first sub-timestamp information.
In the foregoing solution, the first receiving unit is further configured to receive a subscription request through the Graphql service; the subscription request carries the second timestamp information or the loss information;
the determining unit is further configured to determine subscription information in a database according to the second timestamp information or the loss information in response to the subscription request; wherein the subscription information characterizes a subject in the database that relates to field changes at a time corresponding to the second timestamp information or the loss information;
the first sending unit is further configured to send the subscription information to a client through the Graphql service.
The embodiment of the invention provides a web real-time message pushing device, which comprises a second receiving unit and a second sending unit; wherein the content of the first and second substances,
the second receiving unit is configured to receive, through the Graphql API, second timestamp information sent by the server in response to the modification identifier obtaining request; receiving lost information sent by the server in response to an information query request through the Graphql API;
the second sending unit is configured to send a modification identifier obtaining request to a server through the Graphql API; the modification identifier request carries modification information; sending the information query request to the server through the Graphql API; the information query request carries the second timestamp information.
In the foregoing solution, the second receiving unit is further configured to receive, through the Graphql API, subscription information sent by the server in response to the subscription request; the time corresponding to the second timestamp information or the loss information in the subscription information representation database relates to the subject of field change;
the second sending unit is further configured to send a subscription request to the server through the Graphql API; wherein the subscription request carries the second timestamp information or the loss information.
An embodiment of the present invention provides a server, where the server includes:
a first memory for storing executable instructions;
a first communication bus for enabling communication of the first memory with a first processor;
the first processor is configured to execute the executable instructions stored in the first memory to implement the web real-time message pushing method applied to the server according to the embodiment of the present invention.
An embodiment of the present invention provides a client, where the client includes:
a second memory for storing executable instructions;
a second communication bus for enabling communication of the second memory with a second processor;
the second processor is configured to execute the executable instructions stored in the second memory to implement the web real-time message pushing method applied to the client according to the embodiment of the present invention.
Embodiments of the present invention provide a storage medium storing executable instructions for causing a first processor to execute a web real-time message push method applied to a server according to an embodiment of the present invention when the executable instructions are executed.
Embodiments of the present invention provide a storage medium storing executable instructions for causing a second processor to execute a web real-time message push method applied to a server according to an embodiment of the present invention when the executable instructions are executed.
The embodiment of the invention provides a method, a device, equipment and a storage medium for pushing a web real-time message; the method comprises the steps that a server generates a first time stamp message and sends the first time stamp message to a client according to the time of modification operation in a database based on Graphql service and kafka service, and the client receives second time stamp information which is received by the client in the first time stamp information. And comparing the first time stamp information with the second time stamp information to obtain lost information, and determining whether data is lost between the server and the client in the interaction process. And sending the lost information to the client so that the client can acquire the corresponding subscription information again through the lost information.
The embodiment of the invention can determine whether the data loss exists in the data interaction between the client and the server or not by comparing the data difference between the data received by the client and the data sent by the server on the basis of realizing the real-time pushing of the web message, and if the data loss exists, the information loss is determined and the lost information is retransmitted; the success rate of data transmission is improved, and the risk of data loss is reduced.
Drawings
Fig. 1 is a first flowchart of a web real-time message pushing method applied to a server according to an embodiment of the present invention;
fig. 2 is a flowchart ii of a web real-time message pushing method applied to a server according to an embodiment of the present invention;
fig. 3 is a flowchart three of a web real-time message pushing method applied to a server according to an embodiment of the present invention;
fig. 4 is a first flowchart of a web real-time message pushing method applied to a client according to an embodiment of the present invention;
fig. 5 is a flowchart ii of a web real-time message pushing method applied to a client according to an embodiment of the present invention;
fig. 6 is a first flowchart of a method for pushing a web real-time message according to an embodiment of the present invention;
fig. 7 is a flowchart of a web real-time message pushing method according to an embodiment of the present invention;
fig. 8 is a third flowchart of a method for pushing a web real-time message according to an embodiment of the present invention;
fig. 9 is a functional architecture diagram of a web real-time message pushing apparatus according to an embodiment of the present invention;
fig. 10 is a functional architecture diagram of another web real-time message pushing device according to an embodiment of the present invention;
fig. 11 is a functional architecture diagram of a server according to an embodiment of the present invention;
fig. 12 is a functional architecture diagram of a client according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention.
Fig. 1 is a first flowchart of a web real-time message pushing method applied to a server according to an embodiment of the present invention, and as shown in fig. 1, the embodiment of the present invention provides a web real-time message pushing method applied to a server, where the server is provided with a grapql service and a kafka service, and the method includes:
s101, receiving a modification identifier acquisition request through a Graphql service; the modification identifier acquisition request carries modification information.
The embodiment of the invention is suitable for a scene that a server sends the subject information related to field change in data to a client when the field in a database is modified.
In the embodiment of the invention, a server receives a modification identifier acquisition request sent by a client through a Graphql service, wherein the modification identifier acquisition request carries modification information.
In the embodiment of the invention, the modification information is a field which is modified on a page by a user or triggered by a server, so that the database is modified; the modification identification acquisition request is used for requesting the server to provide identification information of the modified field in the database. And the server determines the modified fields in the database according to the identification information and sends the related information to the client.
In the embodiment of the invention, the server can provide different data for the same scene through the Graphql service so as to meet the requirement of client application display; in practical use, the Graphql service defines which subscriptions the server can provide to the client, i.e. adds a root type in the schema file of the server, where the root type is: a Subscription; wherein, the description is at the same level as Query and music. The root type Subscription includes a messageAdded method definition, which represents a theme that the client can subscribe, and when the fields of the theme are modified, the server notifies the client.
In the embodiment of the present invention, the server should detect the connection condition with the client periodically or in real time, and if the server detects that the connection between the server and the client is disconnected due to a network reason, reconnection needs to be attempted, and the number of times of attempting reconnection is set according to actual needs, for example, the maximum reconnection number may be set to be 3 times.
It can be understood that the server obtains the request and the modification information according to the received modification identifier, and provides the identifier of the modification information for the client, so that the subsequent server can push the message according to the needs of the client.
And S102, responding to the modification identifier acquisition request, determining and sending first timestamp information corresponding to the modification information to the client through the Graphql service according to the modification information.
The method and the device are suitable for determining the timestamp of the changed field in the database and sending the timestamp to the client after receiving the modification identifier acquisition request.
In the embodiment of the invention, after receiving a modification identifier acquisition request and modification information sent by a client, a server responds to the modification identifier acquisition request, determines first timestamp information corresponding to the modification information according to the modification information, and sends the first timestamp information to the client through Graphql service.
In the embodiment of the invention, the modification information comprises at least one piece of information, and the first timestamp information comprises at least one piece of timestamp information; wherein each piece of the at least one piece of information corresponds to one piece of time stamp information of the at least one piece of time stamp information.
In the embodiment of the invention, the timestamp information corresponds to the time of modifying the field in the database, wherein the timestamp information is accurate to millisecond.
It can be understood that the server determines the changed fields in the database through the timestamp information, determines the changed fields within a required time period according to requirements, and then sends the subjects with the changed fields to the client, so that the efficiency of determining and sending messages is improved, and the accuracy of the determined subjects with the changed fields is ensured.
S103, receiving an information query request through Graphql service and kafka service; the information inquiry request carries second time stamp information. And the second timestamp information is timestamp information received by the client.
The embodiment of the invention is suitable for a scene of acquiring the receiving condition of the sent first time stamp information.
In the embodiment of the invention, the server receives the information query request and the second timestamp information carried by the information query request through the Graphql service, and processes the second timestamp information through the kafka service. The second timestamp information is timestamp information received by the client.
In the embodiment of the present invention, the second timestamp information is timestamp information that is successfully received by the client in the first timestamp information sent by the server. The number of time stamp information in the second time stamp information should be less than or equal to the number of time stamp information in the first time stamp information, and the same time stamp information exists between the time stamp information in the second time stamp information and the time stamp information in the first time stamp information.
In the embodiment of the invention, the information query request is used for requesting the server to query whether the first timestamp information is lost or not in the process of sending the first timestamp information to the client, and the lost timestamp information is sent to the client again.
It can be understood that the server can know whether data loss exists in the client data interaction process or not by comparing the second timestamp information with the first timestamp information, so that subsequent processing can be conveniently performed according to the data loss, and the risk of data loss is reduced.
S104, responding to the information query request, determining lost information from the first timestamp information based on the second timestamp information, and sending the lost information to the client through the Graphql service; the lost information is timestamp information lost in data interaction in the first timestamp information.
The embodiment of the invention is suitable for determining the data (lost information) lost in the data interaction process with the client by the server and sending the lost data to the client, thereby reducing the risk of data loss.
In the embodiment of the invention, after receiving the information query request, the server responds to the information query request, and based on the second timestamp information, the lost information is determined in the first timestamp information, and the lost information is the timestamp information lost by the first timestamp information in the data interaction between the server and the client. And sending the lost information to the client.
In the embodiment of the invention, the kafka service is arranged in the server to introduce a kafka message queue. In actual use, the first time stamp information and the second time stamp information are respectively stored in different variables (kafka message queues), wherein the variables can be TreeSet classes; the TreeSet class is a subclass of Set; the TreeSet class can ensure that the timestamp information stored in the TreeSet class is in the ordering state, that is, the timestamp information stored in the TreeSet class can be automatically ordered. In actual use, the server may generate two first time stamp information and save into the variables through the kafka service. Exemplarily, the first timestamp information is id1, id2, id3, id4, id5, id6 and id7; the second timestamp information is id1, id2, id3. Storing two pieces of first timestamp information and two pieces of second timestamp information in different TreeSet classes respectively, and recording the two pieces of first timestamp information as topic1, topic2 and topic3 respectively, storing the two pieces of first timestamp information in topic1 and topic2 respectively, namely recording a timestamp information Set in topic1 as Set1= (id 1, id2, id3, id4, id5, id6 and id 7), and recording a timestamp information Set in topic2 as Set2= (id 1, id2, id3, id4, id5, id6 and id 7); the second timestamp information is saved in topic3, i.e., the Set of timestamp information in topic3 is Set3= (id 1, id2, id 3). The server acquires the timestamp information from the Set1 and sends the timestamp information to the client.
In the embodiment of the invention, the sorting mode is that sorting is performed according to the values of the timestamp information from small to large, so that in topic1 and topic2, the first timestamp information is sorted as id1< id2< id3< id4< id5< id6< id7, and in topic3, the second timestamp information is sorted as id1< id2< id3. Since the larger the value of the time stamp information is, the closer the time stamp indicating the modified field is to the current time, id7 in the first time stamp information is the time stamp information closest to the current time.
In the embodiment of the present invention, after determining the missing information, the server may store the missing information in topic1 and topic3, respectively.
In the embodiment of the invention, a timer can be arranged in the server and used for periodically executing the preset task; the preset task may be a comparison function, the comparison function is used for comparing the first timestamp information and the second timestamp information to determine timestamp information lost in the data interaction process, and the timer may be created based on the setInterval. Exemplarily, since the first timestamp information is id1, id2, id3, id4, id5, id6 and id7; the second timestamp information is id1, id2, id3. Therefore, by comparing the first time stamp information and the second time stamp information by the timer, it can be determined that id4, id5, id6 and id7 are lost during the data interaction. All timestamp information lost in the data interaction process can be saved to Set1 and Set3 through the kafka service and sent to the client, or only a part of timestamp information in the timestamp information lost in the data interaction process can be sent. In actual use, because a user only cares about the latest data, the data is not received due to data loss in the middle process, and the user is unaware of the data, the timestamp information with the largest determined value in the timestamp information lost in the data interaction process can be sent to the client as the lost information, namely, the id7 is determined to be the lost information in the id4, the id5, the id6 and the id 7.
It can be understood that the server obtains the lost information according to the first timestamp information and the second timestamp information, and sends the lost information to the client, thereby ensuring the success rate of data sending and reducing the risk of data loss.
In some embodiments of the present invention, S104 may further include S1041 and S1042 as follows:
and S1041, comparing the first timestamp information based on the second timestamp information to obtain a comparison result.
In some embodiments of the invention, it is adapted to determine a scenario of missing information based on the second timestamp information.
In some embodiments of the present invention, the server compares the first timestamp information and the second timestamp information with reference to the second timestamp information, and obtains a comparison result.
In some embodiments of the present invention, the server compares whether the timestamp information in the first timestamp information and the timestamp information in the second timestamp information are the same, and obtains a comparison result.
In some embodiments of the present invention, the server compares the first sub-timestamp information with the second sub-timestamp information through the kafka service until the first timestamp information is screened, so as to obtain a comparison result. The first sub-timestamp information is any one timestamp information in the first timestamp information; the second sub-timestamp information is any one of the second timestamp information.
In some embodiments of the present invention, any one piece of timestamp information is taken as first sub-timestamp information in the first timestamp information, any one piece of timestamp information is taken as second sub-timestamp information in the second timestamp information, and the first sub-timestamp information and the second sub-timestamp information are compared until all pieces of timestamp information in the first timestamp information are screened, so as to obtain a comparison result.
It can be understood that by comparing the first time stamp information and the second time stamp information, the time stamp information lost in the data interaction process can be obtained.
And S1042, based on the comparison result, determining the lost information from the first time stamp information and sending the lost information to the client through the Graphql service.
In some embodiments of the invention, it is adapted to determine the scene of missing information based on the comparison result.
In some embodiments of the present invention, the server determines the missing information from the first timestamp information based on the comparison result obtained in S1041 and sends the missing information to the client through the Graphql service.
In some embodiments of the present invention, the comparison result may include a plurality of sub-comparison results, each sub-comparison result corresponds to one timestamp information, and at least one timestamp information lost in the data interaction may be determined according to the plurality of sub-comparison results.
It can be understood that, based on the comparison result, the timestamp information lost in the data interaction process is determined, and the lost timestamp information is retransmitted to the client, so that the success rate of information transmission is ensured.
In some embodiments of the invention, S1042 may include S10421 and S10422 as follows:
s10421, if the comparison result is that the first sub-timestamp information is different from the second sub-timestamp information; determining that the timestamp information corresponding to the first sub-timestamp information is sub-loss information.
In some embodiments of the present invention, it is useful to determine the context of timestamp information lost during a data interaction.
In some embodiments of the present invention, if the comparison result indicates that the first sub-timestamp information is different from the second sub-timestamp information, the server determines that the timestamp information corresponding to the first sub-timestamp information is the sub-loss information.
In some embodiments of the present invention, based on the comparison, at least one timestamp information lost in the data interaction may be determined; the loss information includes at least one sub-loss information, each of the at least one sub-loss information corresponding to each of at least one timestamp information lost in the data interaction.
In some embodiments of the present invention, if the comparison result indicates that the first sub-timestamp information is the same as the second sub-timestamp information, the server determines that the timestamp information corresponding to the first sub-timestamp information is not sub-lost information. At this time, the time stamp information corresponding to the first sub time stamp information is deleted.
It can be understood that determining the sub-loss information according to the comparison result and determining the loss information according to the sub-loss information can reduce the number of timestamp information sent to the client and reduce the transmission cost.
S10422, determining the loss information from the sub-loss information.
In some embodiments of the present invention, the method is adapted to determine a scene of the lost information after determining the sub lost information.
In some embodiments of the present invention, the server determines, from the sub-loss information, the sub-loss information having the largest time value as the loss information.
In some embodiments of the present invention, after determining that the sub-loss information with the largest time value is the loss information, the sub-loss information is sent to the client.
It can be understood that, the server determines that the information is lost and then sends the information to the client, so that the success rate of data sending can be ensured, and the risk of data loss is reduced.
Based on fig. 1, fig. 2 is a second flowchart of a web real-time message pushing method applied to a server according to an embodiment of the present invention, and as shown in fig. 2, the scheme further includes:
and S105, determining a reference information sample from the first time stamp information based on a preset period.
The embodiment of the invention is suitable for determining a scene with one piece of time stamp information as a reference information sample from the first time stamp information.
In the embodiment of the invention, the server periodically determines one piece of time stamp information from the first time stamp information as a reference information sample.
In the embodiment of the present invention, according to a preset period, all pieces of timestamp information in the period are obtained from the second timestamp information, and the timestamp information with the largest value is determined as a reference information sample, and the timestamp information with the smallest value may also be determined as a reference information sample.
In the embodiment of the invention, if the first timestamp information has no timestamp information in a preset period, the server does not need any operation.
It can be understood that, by deleting the first time stamp information and the second time stamp information which are not needed periodically, data redundancy can be reduced, the workload of comparing the first time stamp information and the second time stamp information to determine lost information can be reduced, and the working efficiency can be improved.
In some embodiments of the present invention, the first sub-timestamp information having the largest value is determined as the reference information sample from the first timestamp information based on a preset period. The first sub-timestamp information is any one of the first timestamp information.
In some embodiments of the present invention, since it is not necessary to consider whether the user does not receive the timestamp information before the timestamp information with the largest value in the first timestamp information, the timestamp information with the largest value in the first timestamp information is used as the reference information sample.
And S106, based on the reference information sample, deleting the first time stamp information and the second time stamp information.
The embodiment of the invention is suitable for a scene for processing the first time stamp information and the second time stamp information.
In the embodiment of the present invention, based on the reference information sample determined in S105, the server performs deletion processing on the timestamp information meeting the preset requirement in the first timestamp information and the second timestamp information.
In an embodiment of the present invention, the predetermined requirement may be a value smaller than the reference information sample. Exemplarily, the timestamp information with the largest value is determined from Set2= (id 1, id2, id3, id4, id5, id6, id 7) and Set3= (id 1, id2, id 3) as the reference information sample, i.e. id7; wherein id7 represents the timestamp information with the largest median among the timestamp information sent by the server to the client 1 minute ago, and all the timestamp information with median smaller than id7 in Set2= (id 1, id2, id3, id4, id5, id6, id 7) and Set3= (id 1, id2, id 3) are deleted. After deletion, set2= (id 7) is obtained, and Set3 is an empty Set.
It can be understood that, deleting the first time stamp information and the second time stamp information in this way can reduce data redundancy and improve work efficiency.
In some embodiments of the present invention, S106 may include S1061 and S1062, as follows:
and S1061, comparing the first sub-timestamp information with the second sub-timestamp information based on the reference information sample to obtain a first comparison result.
In some embodiments of the present invention, it is suitable for determining a scene of the time stamp information that needs to be deleted in the first time stamp information and the second time stamp information.
In some embodiments of the present invention, the server compares the first sub-timestamp information and the second sub-timestamp information based on the reference information sample to obtain a first comparison result.
It can be understood that, in this way, the time stamp information that needs to be deleted in the first sub time stamp information and the second sub time stamp information can be accurately determined.
And S1062, if the first comparison result shows that the first sub-timestamp information is smaller than the reference information sample, performing deletion processing on the timestamp information corresponding to the first sub-timestamp information.
In some embodiments of the present invention, the present invention is applicable to a scenario in which unnecessary time stamp information of the first time stamp information and the second time stamp information is subjected to deletion processing.
In some embodiments of the present invention, if the first comparison result is that the first sub-timestamp information or the second timestamp information is smaller than the reference information sample, the server performs a deletion process on the timestamp information corresponding to the first sub-timestamp information or the second timestamp information.
In some embodiments of the present invention, if a piece of time stamp information is smaller than the reference information sample, it means that the time stamp information does not need to be sent to the client to inform the user, and therefore, the time stamp information is deleted.
It can be understood that data redundancy can be reduced and work efficiency can be improved.
Based on fig. 1, fig. 3 is a third flowchart of a web real-time message pushing method applied to a server according to an embodiment of the present invention, and as shown in fig. 3, the scheme further includes:
s107, receiving a subscription request through a Graphql service; the subscription request carries second timestamp information or missing information.
The embodiment of the invention is suitable for a scene that a server pushes messages for a client.
In the embodiment of the invention, the server receives the subscription request sent by the client and the second timestamp information or the loss information carried by the subscription request through the Graphql service.
In the embodiment of the present invention, the subscription request is used to request a push subscription message from a server.
In the embodiment of the invention, the server comprises a subscription resolver, the subscription resolver can use published events to resolve subscription requests sent by the client, nested objects are set in the subscription resolver, and subscription information generated in response to the subscription requests is sent to the client through the subscription resolver.
It can be understood that the server responds to the request of the client according to the subscription request, so that the client can meet the requirement of the user.
S108, responding to the subscription request, determining subscription information in the database according to the second timestamp information or the lost information, and sending the subscription information to the client through the Graphql service; and the subscription information represents the subject of field change related to the second timestamp information or the time corresponding to the lost information in the database.
The embodiment of the invention is suitable for providing a scene of subscription information for the client.
In the embodiment of the invention, the server determines subscription information in the database according to the second timestamp information or the loss information and sends the subscription information to the client through the Graphql service, wherein the subscription information is a response result of the subscription request, and the subscription information represents a subject related to field change at a moment corresponding to the second timestamp information or the loss information in the database.
It can be understood that the server sends the subscription information to the client, so that the client can display the latest data in real time to meet the user requirements.
Fig. 4 is a first flowchart of a web real-time message pushing method applied to a client according to an embodiment of the present invention, and as shown in fig. 4, the method provided in the embodiment of the present invention is applied to the client, and the client is provided with a Graphql API (Application Programming Interface); the method comprises the following steps:
s201, sending a modification identifier acquisition request to a server through a Graphql API; the modification identification request carries modification information, and the client side realizes data interaction with the Graphql service of the server through the Graphql API.
The method and the device are suitable for scenes of requesting to push the subject information related to field change in the database.
In the embodiment of the invention, the client sends the modification identifier acquisition request to the server through the Graphql API, and the modification identifier acquisition request carries modification information so as to request to acquire the main information related to field change in the database corresponding to the modification information.
In the embodiment of the present invention, before the client sends the request for obtaining the modification identifier, an instance for subscribing to the root type of the subscription service added in S101 needs to be created at the client to be used as a network interface, that is, as a Graphql API; through the Graphql API, the client can execute ordinary Graphql query and subscription query through WebSockets through HTTP, namely, the client can realize data interaction with the Graphql service of the server through the Graphql API. And creating an observable execution operation at the client, wherein the execution operation comprises a request interface definition and a request parameter value of a descriptor root type of a server to which the client is connected.
It can be understood that the client sends and receives the timestamp information of the message needing to be pushed in real time through the Graphql API, which is beneficial to decoupling the data processing process of the server, and improves the access pressure bearing strength, so that the client does not crash due to a sudden overload request.
S202, receiving second timestamp information sent by the server in response to the modification identifier acquisition request through a Graphql API; the second timestamp information is timestamp information received by the client in the first timestamp information; the first timestamp information is timestamp information sent by the server.
The embodiment of the invention is suitable for a scene of receiving the second timestamp message sent by the server.
In the embodiment of the invention, the client receives second timestamp information sent by the server in response to the modification identifier acquisition request through the Graphql API; the first timestamp information is timestamp information sent by the server, and because the first timestamp information can have the condition that the timestamp information is lost in the data interaction process, the timestamp information received by the client in the first timestamp information is recorded as second timestamp information.
It can be understood that the client can ensure the ordering of the second timestamp information, thereby ensuring the timeliness of the subscription information subsequently acquired by the client according to the second timestamp information.
S203, sending an information query request to a server through a Graphql API; the information inquiry request carries second time stamp information.
The embodiment of the invention is suitable for a scene that the client side inquires whether the data is lost when the server performs data interaction.
In the embodiment of the invention, the client sends the second timestamp information and the information query request to the server together through the Graphql API.
In the embodiment of the invention, the information query request is used for requesting the server to determine whether timestamp information which is not received by the client exists in the first timestamp information according to the second timestamp information.
In the embodiment of the invention, if the timestamp information which is not received by the client exists, the information query request is also used for requesting the server to send the timestamp information which is not received by the client to the client. In practical use, the information query request may also be used to request the server to send the timestamp information with the largest value in the received timestamp information to the client.
It can be understood that, through the information query request, it can be determined whether there is a data loss situation between the client and the server during the data interaction process.
S204, receiving lost information sent by the server in response to the information query request through a Graphql API; the lost information is timestamp information lost in data interaction in the first timestamp information.
The method and the device are suitable for scenes that the client side obtains the timestamp information lost in the data interaction process with the server.
In the embodiment of the invention, the client receives the lost information sent by the server in response to the information query request, and the lost information is the timestamp information lost in data interaction in the first timestamp information.
It can be understood that after receiving the lost information, the client can obtain the subject information of the design field change in the database corresponding to the lost information according to the lost information, and display the subject information to the user; therefore, the success rate of data sending can be ensured, the risk of data loss is reduced, and the integrity of the subscription information received by the user is ensured.
Based on fig. 4, fig. 5 is a second flowchart of a web real-time message pushing method applied to a client according to an embodiment of the present invention, and as shown in fig. 5, a web real-time message pushing method according to some embodiments of the present invention further includes:
and S205, sending a subscription request to a server through a Graphql API. Wherein the subscription request carries second timestamp information or missing information.
The embodiment of the invention is suitable for a scene that the client requests the server to push the subscription information subscribed by the user through the client.
In the embodiment of the invention, the client sends the subscription request to the server through the Graphql API, and when the client sends the subscription request, the subscription request carries the second timestamp information or the lost information.
In the embodiment of the present invention, whether the subscription request carries the second timestamp information or the loss information is determined according to values of timestamp information in the second timestamp information and the loss information. And determining the timestamp information with the maximum value in the second timestamp information and the lost information, and carrying the timestamp information with the maximum value in the subscription request to the server.
It can be appreciated that the client can request the server to send the subscription message closest to the current time, and the probability of the subscription message being lost due to the loss of timestamp information can be reduced.
And S206, receiving the subscription information sent by the server in response to the subscription request through the Graphql API. And the time corresponding to the second timestamp information or the lost information in the subscription information representation database relates to the subject of field change.
The embodiment of the invention is suitable for a scene that the client receives the subscription information.
In the embodiment of the invention, the client receives the subscription information sent by the server in response to the subscription request through the Graphql API, and the subscription information represents the subject of field change related to the time corresponding to the second timestamp information or the lost information in the database.
In the embodiment of the present invention, the subscription information is subject information of which a field is changed at a time corresponding to the second timestamp information or the lost information in the database subscribed by the client.
It can be understood that, the client requests the subscription information according to the second timestamp information or the missing information, which can ensure the receiving success rate of the subscription information and improve the user experience.
Fig. 6 is a flowchart of a web real-time message pushing method according to an embodiment of the present invention, where as shown in fig. 6, a web real-time message pushing method according to some embodiments of the present invention includes:
s301, the client sends a modification identifier acquisition request and modification information to the server.
S302, the server responds to the modification identifier acquisition request and determines first timestamp information corresponding to the modification information according to the modification information.
S303, the server sends the first time stamp information to the client.
S304, the client sends an information query request and second timestamp information to the server, wherein the second timestamp information is the timestamp information received by the client in the first timestamp information.
S305, the server responds to the information inquiry request, and based on the second time stamp information, the lost information is determined from the first time stamp information.
S306, the server sends the lost information to the client.
S307, the client sends a subscription request and second timestamp information or lost information to the server.
S308, the server responds to the subscription request and determines subscription information in the database according to the second timestamp information or the loss information.
S309, the server sends subscription information to the client.
It can be understood that, in the embodiment of the present invention, it may be determined whether data is lost in the data interaction process between the server and the client, and the server may determine the lost information and resend the lost information, which may ensure a success rate of data sending, reduce a risk of data loss, and ensure integrity of subscription information received by the user.
Fig. 7 is a second flowchart of a web real-time message push method according to an embodiment of the present invention, and as shown in fig. 7, a web real-time message push method according to some embodiments of the present invention includes:
s401, a Graphql subscription and subscription resolver is set in a server.
In some embodiments of the invention, the setup of the Graphql service is done by setting up a Graphql subscription and subscription resolver at the server; the Graphql subscription is used for defining the subscription type which can be requested by the client, and the subscription resolver is a filter which saves resources by defining a filter function and specifies whether an event should pass through given event data and a query variable.
S402, the client side creates an instance of subscription description and a request interface definition.
In some embodiments of the present invention, the setup of the Graphql API is completed by creating an instance of the subscription and requesting an interface definition, so as to implement data interaction between the client and the server.
S403, the user or the server triggers a data change.
In some embodiments of the present invention, when a user modifies a page or the server triggers a modification operation to the database, modification information is generated.
S404, the producer (consumer producer) end of the kafka sends the number id1 (second time stamp information) to topic1.
In some embodiments of the present invention, the server numbers the modification information generated in S403 and sends the number to the client.
In some embodiments of the present invention, based on the kafka service provided at the server, the server sends this id1 to topic1 through the producer end of kafka after receiving the number id1, where id is the timestamp accurate to ms, corresponding to the time when the field in the database was modified.
S405, the consumer (message consumer) end of kafka consumes id1 from topic1.
In some embodiments of the invention, the server sends id1 to the server through the consumer terminal of kafka based on the kafka service, and when the consumer terminal sends id1, a subscription request is also generated and sent to the server together to request the server to provide subscribed data according to id1.
S406, the server queries a database and issues the message related to the subject of field change; the producer end of kafka sends the numbers id1 to topic2.
In some embodiments of the present invention, after receiving the message id1, the server immediately queries the database, and issues the message on the subject related to the field change corresponding to id1.
In some embodiments of the invention, the server sends numbers id1 to topic2 through the producer end of kafka based on kafka service for standby, indicating the number sent by the server to the client.
S407, the client receives data (subscription information) in real time through the definition of the subscription type of the server.
In some embodiments of the present invention, the client defines the received data as the theme allowed to be provided by the server according to the type of the description of the server.
S408, the client re-renders the page; and the client sends the id1 to the server through a query type request of Graphql.
In some embodiments of the invention, after the client receives the subscribed data, the page is re-rendered to display the received data for the user.
In some embodiments of the invention, the server further comprises a root type Query and a root type Mutation. Wherein, the root type Query, the root type Mutation and the root type description are in the same level. The client communicates with the Graphql service of the server through the Graphql API, and sends the id1 to the server through a quick type request of the Graphql.
S409, the producer end of kafka sends id1 to topic3.
In some embodiments of the present invention, the server sends id1 to topic3 for saving through kafka based on kafka service, which indicates that the client has received and received the data corresponding to id1.
S410, comparing the numbers of the topic2 and the topic3 by the consumer end of kafka, judging whether id1 needs to be sent to the topic1 again, and if the judgment result is that the id1 needs to be sent to the topic1 again, performing S406.
In some embodiments of the present invention, the number in topic2 is that sent by the server to the client, and the number in topic3 is that received by the client in real time when the client has received the message issued by the server according to the number; the server compares the difference of numbers in topic2 and topic3 by the consumer terminal of kafka based on kafka service, and can obtain the data which is not received by the client terminal.
In some embodiments of the present invention, if id1 needs to be resent into topic1, S406 is performed, and if not, no action is taken.
It can be understood that, in the embodiment of the present invention, the server uses a data consumption mechanism of kafka to compare the difference between the data (second timestamp information) received by the client and the data (first timestamp information) sent by the server, find out the message (lost information) that the pushing fails, and resend the message, which can effectively ensure the success rate of data sending and avoid the risk of data loss; the client side realizes communication (data interaction) with the Graphql service of the server through the Graphql API, complete websocket transmission is supported, real-time Web application based on Graphql is realized, and the method has the advantage of less data.
Fig. 8 is a third flowchart of a web real-time message pushing method according to an embodiment of the present invention, and as shown in fig. 8, a web real-time message pushing method according to some embodiments of the present invention includes:
s501, the server determines the maximum value in the number Set3= (id 1, id2, id3, \8230;) consumed by the client in topic3, and records the maximum value as id max (reference information sample).
In some embodiments of the present invention, in addition to the Graphql service and the kafka service, a setInterval timer may be set in the server; wherein, setInterval timer is independent from Graphql service, and the setInterval timer is used to execute the comparison function shown in S502-S506 of the processing logic 1 time every 1 minute.
In some embodiments of the present invention, the Set of numbers consumed by clients in topic3 is denoted Set3= (id 1, id2, id3, \8230;), and the Set of numbers consumed by clients in topic2 is denoted Set2= (id 1, id2, id3, \8230;). The server determines id in Set3 max . Wherein id max The number is the largest number received by the client in Set 3.
S502, the server deletes the number Set2= (id 1, id2, id3, \8230;) consumed by the client in the topic2 and the number Set3= (id 1, id2, id3, \8230;) consumed by the client in the topic3, which is smaller than id max The number of (2).
In some embodiments of the invention, because the user only cares about the data corresponding to the latest number, the intermediate process is due to the loss of the number or dataThe ID is not received and is not sensed by the client, so that whether the user does not receive the id or not does not need to be considered<id max Or data corresponding to the number.
S503, the server takes the Set2= (id 1, id2, id3, \8230;) in the Set2= (1 minute ago) as Set2'.
In some embodiments of the present invention, set2 'may be Set2' = (id 5, id6, id 7.) for indicating a number that the client did not receive 1 minute ago.
S504, the server judges whether Set2' is an empty Set.
In some embodiments of the present invention, if Set2' is not an empty Set, it indicates that the client exists as the received number 1 minute ago, i.e. there is data loss between the client and the server in the data interaction.
S505, if Set2' is not an empty Set, taking the maximum value as id ' from Set2' max (ii) a If Set2' is an empty Set, the server stops.
In some embodiments of the invention id' max This value represents the number closest to the current time in the data that the client did not receive 1 minute ago.
S506, server sends id' max To client, client will id' max Sent to topic1.
In some embodiments of the invention, the server sends id' max To the client, the client will send id' max Sent to topic1 to resend id 'from the requesting server' max The corresponding data.
It can be understood that the embodiment of the invention can reduce data redundancy, only sends the latest data to the client, and ensures the real-time performance of the data.
Fig. 9 is a functional architecture diagram of a web real-time message pushing apparatus according to an embodiment of the present invention, and as shown in fig. 9, the embodiment of the present invention provides a web real-time message pushing apparatus 9, which corresponds to a web real-time message pushing method, and includes a first receiving unit 91, a determining unit 92, and a first sending unit 93; wherein the content of the first and second substances,
the first receiving unit 91 is configured to receive a modification identifier obtaining request through the Graphql service; the modification identifier acquisition request carries modification information; receiving an information query request through the Graphql service and the kafka service; the information query request carries second timestamp information;
the determining unit 92 is configured to determine, in response to the modification identifier obtaining request, first timestamp information corresponding to the modification information according to the modification information; determining loss information from the first timestamp information based on the second timestamp information in response to the information query request;
the first sending unit 93 is configured to send the first timestamp information to the client through the Graphql service; for sending the loss information to the client via the Graphql service.
In some embodiments of the present invention, the determining unit 92 is further configured to compare the first timestamp information based on the second timestamp information, so as to obtain a comparison result; determining the loss information from the first timestamp information based on the comparison result.
In some embodiments of the present invention, the determining unit 92 is further configured to compare the first sub-timestamp information with the second sub-timestamp information until the first timestamp information is screened, so as to obtain a comparison result; the first sub-timestamp information is any one of the first timestamp information; the second sub-timestamp information is any one of the second timestamp information.
In some embodiments of the present invention, the determining unit 92 is further configured to determine whether the first sub-timestamp information is different from the second sub-timestamp information if the comparison result is that the first sub-timestamp information is different from the second sub-timestamp information; determining that the timestamp information corresponding to the first sub-timestamp information is sub-loss information; determining the loss information from the sub-loss information.
In some embodiments of the present invention, the determining unit 92 is further configured to determine, from the sub loss information, a sub loss information with a largest value as the loss information.
In some embodiments of the invention, the apparatus further comprises a processing unit, wherein:
the determining unit 92 is further configured to determine a reference information sample from the second timestamp information based on a preset period;
the processing unit 94 is further configured to perform a deleting process on the first timestamp information based on the reference information sample.
In some embodiments of the present invention, the determining unit is further configured to determine, based on the preset period, a second sub-timestamp information with a largest value from the second timestamp information as the reference information sample.
In some embodiments of the present invention, the processing unit 94 is further configured to compare the first sub-timestamp information based on the reference information sample to obtain a first comparison result; and if the first comparison result shows that the first sub-timestamp information is smaller than the reference information sample, deleting the timestamp information corresponding to the first sub-timestamp information.
In some embodiments of the present invention, the first receiving unit 91 is further configured to receive a subscription request through the Graphql service; the subscription request carries the second timestamp information or the loss information.
The determining unit 92 is further configured to determine, in response to the subscription request, subscription information in a database according to the second timestamp information or the loss information; wherein the subscription information characterizes a subject in the database that relates to field changes at a time corresponding to the second timestamp information or the loss information;
the first sending unit 93 is further configured to send the subscription information to a client through the Graphql service.
Fig. 10 is a functional architecture diagram of another web real-time message pushing apparatus according to an embodiment of the present invention, and as shown in fig. 10, another web real-time message pushing apparatus 11 according to an embodiment of the present invention is provided, which corresponds to a web real-time message pushing method and includes a second receiving unit 111 and a second sending unit 112; wherein the content of the first and second substances,
the second receiving unit 111, configured to receive, through the Graphql API, second timestamp information sent by the server in response to the modification identifier obtaining request; receiving lost information sent by the server in response to the information query request through the Graphql API;
the second sending unit 112 is configured to send a modification identifier obtaining request to a server through the Graphql API; the modification identifier request carries modification information; sending the information query request to the server through the Graphql API; the information query request carries the second timestamp information.
In some embodiments of the present invention, the second receiving unit 111 is further configured to receive, through the Graphql API, subscription information sent by the server in response to the subscription request; the subscription information represents the subject of field change at the moment corresponding to the second timestamp information or the loss information in the database;
the second sending unit 112 is further configured to send a subscription request to the server through the Graphql API; wherein the subscription request carries the second timestamp information or the loss information.
Fig. 11 is a functional architecture diagram of a server according to an embodiment of the present invention, as shown in fig. 11, an embodiment of the present invention further provides a server 12, and corresponds to a web real-time message pushing method applied to the server, and the web real-time message pushing method includes a first processor 121, a first memory 122, and a first communication bus 124, where the first memory 122 communicates with the first processor 121 through the first communication bus 124, the first memory 122 stores one or more programs executable by the first processor 121, and when the one or more programs are executed, the first processor 121 executes the web real-time message pushing method according to the embodiment of the present invention, and specifically, the server 12 further includes a first communication component 123 for performing data transmission, where at least one of the first processors 121 is provided.
In an embodiment of the present invention, the various components in the server 12 are coupled together by a bus 124. It is understood that a bus 124 is used to enable the connection communication between these components. The pass bus 124 includes a power bus, a control bus, and a status signal bus in addition to a data bus. But for clarity of illustration the various busses are labeled in figure 11 as passing through bus 124.
Fig. 12 is a functional architecture diagram of a client according to an embodiment of the present invention, as shown in fig. 12, an embodiment of the present invention further provides a client 13, and corresponds to a web real-time message pushing method applied to the client, and the web real-time message pushing method includes a second processor 131, a second memory 132, and a second communication bus 134, where the second memory 132 communicates with the second processor 131 through the second communication bus 134, the second memory 132 stores one or more programs executable by the second processor 131, and when the one or more programs are executed, the second processor 131 executes the web real-time message pushing method according to the embodiment of the present invention, and specifically, the client 13 further includes a second communication component 133 for performing data transmission, where at least one of the second processors 131 is provided.
In an embodiment of the present invention, the various components in client 13 are coupled together by a bus 134. It will be appreciated that communications among these components are achieved through the connection of bus 134. The pass bus 134 includes a power bus, a control bus, and a status signal bus in addition to a data bus. But for clarity of illustration the various buses are labeled in figure 12 as passing through bus 134.
Embodiments of the present invention provide a storage medium storing executable instructions for causing a first processor to execute a web real-time message push method applied to a server according to an embodiment of the present invention when the executable instructions are executed
Embodiments of the present invention provide a storage medium storing executable instructions, which when executed, are configured to cause a second processor to execute a web real-time message push method applied to a client according to an embodiment of the present invention.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of a hardware embodiment, a software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the scope of the present invention.

Claims (16)

1. A web real-time message pushing method is applied to a server, the server is provided with a Graphql service and a kafka service, and the method comprises the following steps:
receiving a modification identifier acquisition request through the Graphql service; the modification identifier acquisition request carries modification information;
responding to the modification identifier acquisition request, determining and sending first timestamp information corresponding to the modification information to a client through the Graphql service according to the modification information;
receiving an information query request through the Graphql service and the kafka service; the information query request carries second timestamp information; the second timestamp information is timestamp information received by the client;
responding to the information query request, determining lost information from the first timestamp information based on the second timestamp information, and sending the lost information to the client through the Graphql service; the lost information is timestamp information lost in data interaction in the first timestamp information.
2. The method according to claim 1, wherein the determining, from the first timestamp information, lost information based on the second timestamp information in response to the information query request and sending the lost information to the client through the Graphql service comprises:
comparing the first timestamp information based on the second timestamp information to obtain a comparison result;
and based on the comparison result, determining the loss information from the first timestamp information and sending the loss information to the client through the Graphql service.
3. The method of claim 2, wherein comparing the first timestamp information based on the second timestamp information to obtain a comparison result comprises:
comparing the first sub-timestamp information with the second sub-timestamp information until all timestamp information in the first timestamp information is screened to obtain a comparison result; the first sub-timestamp information is any one timestamp information in the first timestamp information; the second sub-timestamp information is any one of the second timestamp information.
4. The method according to claim 3, wherein the determining the loss information from the first timestamp information based on the comparison result and sending the loss information to the client through the Graphql service comprises:
if the comparison result is that the first sub-timestamp information is different from the second sub-timestamp information; determining that the timestamp information corresponding to the first sub-timestamp information is sub-lost information;
determining the loss information from the sub-loss information.
5. The method of claim 4, wherein the determining the loss information from the sub-loss information comprises:
and determining the sub-loss information with the maximum value as the loss information from the sub-loss information.
6. The method of claim 1, further comprising:
determining a reference information sample from the first timestamp information based on a preset period;
and deleting the first time stamp information and the second time stamp information based on the reference information sample.
7. The method according to claim 6, wherein the determining a reference information sample from the first timestamp information based on a preset period comprises:
and determining the first sub-timestamp information with the maximum value as the reference information sample from the first timestamp information based on the preset period.
8. The method according to claim 6 or 7, wherein the performing a deletion process on the first time stamp information and the second time stamp information based on the reference information sample comprises:
comparing the first sub-timestamp information with the second sub-timestamp information based on the reference information sample to obtain a first comparison result;
and if the first comparison result is that the first sub-timestamp information or the second sub-timestamp information is smaller than the reference information sample, deleting the timestamp information corresponding to the first sub-timestamp information and the second sub-timestamp information.
9. The method of claim 1, further comprising:
receiving a subscription request through the Graphql service; the subscription request carries the second timestamp information or the loss information;
responding to the subscription request, determining subscription information in a database according to the second timestamp information or the loss information, and sending the subscription information to a client through the Graphql service; wherein the subscription information characterizes a subject matter in the database relating to field changes at a time corresponding to the second timestamp information or the loss information.
10. A web real-time message pushing method is applied to a client, wherein the client is provided with GraphqlAPI and comprises the following steps:
sending a modification identifier acquisition request to a server through the GraphqlAPI; the modification identifier request carries modification information, and the client side realizes data interaction with the Graphql service of the server through the GraphqlAPI;
receiving second timestamp information sent by the server in response to the modification identifier acquisition request through the Graphql API; the second timestamp information is timestamp information received by the client in the first timestamp information; the first timestamp information is timestamp information sent by the server;
sending the information query request to the server through the GraphqlAPI; the information query request carries the second timestamp information;
receiving lost information sent by the server in response to the information query request through the Graphql API; the lost information is timestamp information lost in data interaction in the first timestamp information.
11. The method of claim 10, further comprising:
sending a subscription request to the server through the GraphqlAPI; wherein the subscription request carries the second timestamp information or the loss information;
receiving subscription information sent by the server in response to the subscription request through the Graphql API; and the subscription information represents the subject of field change related to the time corresponding to the second timestamp information or the loss information in the database.
12. The web real-time message pushing device is characterized by comprising a first receiving unit, a determining unit and a first sending unit; wherein, the first and the second end of the pipe are connected with each other,
the first receiving unit is configured to receive a modification identifier acquisition request through a Graphql service; the modification identifier acquisition request carries modification information; receiving an information query request through the Graphql service and the kafka service; the information query request carries second timestamp information;
the determining unit is used for responding to the modification identifier acquisition request and determining first timestamp information corresponding to the modification information according to the modification information; determining missing information from the first timestamp information based on the second timestamp information in response to the information query request;
the first sending unit is configured to send the first timestamp information to a client through the Graphql service; for sending the loss information to the client via the Graphql service.
13. The web real-time message pushing device is characterized by comprising a second receiving unit and a second sending unit; wherein, the first and the second end of the pipe are connected with each other,
the second receiving unit is configured to receive, through the Graphql API, second timestamp information sent by the server in response to the modification identifier obtaining request; receiving lost information sent by the server in response to an information query request through the GraphqlAPI;
the second sending unit is configured to send a modification identifier obtaining request to a server through the Graphql API; the modification identifier request carries modification information; sending the information query request to the server through the Graphql API; the information query request carries the second timestamp information.
14. A server, characterized in that the server comprises:
a first memory for storing executable instructions;
a first communication bus for enabling communication of the first memory with a first processor;
the first processor to execute executable instructions stored in the first memory to implement the method of any one of claims 1-9.
15. A client, the client comprising:
a second memory for storing executable instructions;
the second communication bus is used for realizing the communication between the second memory and the second processor;
the second processor to execute executable instructions stored in the second memory to implement the method of claim 10 or 11.
16. A storage medium storing executable instructions that, when executed, cause a first processor to perform the method of any one of claims 1-9; or for causing a second processor to perform the method of claim 10 or 11.
CN202111143668.8A 2021-09-28 2021-09-28 Web real-time message pushing method and device, equipment and storage medium Pending CN115883639A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111143668.8A CN115883639A (en) 2021-09-28 2021-09-28 Web real-time message pushing method and device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111143668.8A CN115883639A (en) 2021-09-28 2021-09-28 Web real-time message pushing method and device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115883639A true CN115883639A (en) 2023-03-31

Family

ID=85763518

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111143668.8A Pending CN115883639A (en) 2021-09-28 2021-09-28 Web real-time message pushing method and device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115883639A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116455527A (en) * 2023-06-16 2023-07-18 深圳华锐分布式技术股份有限公司 Message retransmission method

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116455527A (en) * 2023-06-16 2023-07-18 深圳华锐分布式技术股份有限公司 Message retransmission method

Similar Documents

Publication Publication Date Title
CN110113381B (en) Method and device for subscribing theme in block chain
US8195757B2 (en) Method, apparatus and computer program for controlling retention of publications
CN111800443B (en) Data processing system and method, device and electronic equipment
CN105338061A (en) Lightweight message oriented middleware realization method and system
CN112507029A (en) Data processing system and data real-time processing method
CN108228625B (en) Push message processing method and device
CN113391979A (en) Processing method, equipment and system for monitoring data display and storage medium
CN110912805B (en) Message reading state synchronization method, terminal, server and system
CN112052227A (en) Data change log processing method and device and electronic equipment
CN115883639A (en) Web real-time message pushing method and device, equipment and storage medium
CN110868323A (en) Bandwidth control method, device, equipment and medium
CN114281524A (en) Intelligent cable service processing system management method and device
CN112491951B (en) Request processing method, server and storage medium in peer-to-peer network
CN113315689B (en) Information processing method, system, electronic device and readable storage medium
CN109831335B (en) Data monitoring method, monitoring terminal, storage medium and data monitoring system
CN114095571A (en) Data processing method, data service bus, terminal and storage medium
CN116108036A (en) Method and device for off-line exporting back-end system data
CN113076380B (en) Data synchronization method, device, system, equipment and storage medium
CN111756836B (en) Information sending method and device based on event management model
CN112055058A (en) Data storage method and device and computer readable storage medium
CN113055493A (en) Data packet processing method, device, system, scheduling device and storage medium
CN113079055A (en) Method and device for dynamically acquiring AGV (automatic guided vehicle) running data
CN113641509A (en) Internet of things data processing method and device
CN107147694B (en) Information processing method and device
CN108574622B (en) Instant message processing method and device based on XMPP

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