A web real-time message push method, device, equipment, and storage medium
The Graphql service and the Kafka service are used to detect and solve the missing information in data interaction, which solves the problem of insufficient real-time and loss in data interaction in the existing technology, and improves the success rate of data transmission and user experience.
Patent Information
- Application Number
- CN202111143668.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-28
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2041-09-28
AI Technical Summary
The existing web message push method has insufficient real-time performance and risk of data loss in data interaction. The client polling method causes users to be unable to receive updated data in a timely manner. The method based on the websocket protocol has message loss problems.
Through the Graphql service and kafka service, compare the difference between the data received by the client and the data sent by the server, determine the data loss information and resend it, improve the success rate of data sending, and reduce the risk of data loss.
It realizes timely detection and resolution of lost information during data interaction, improves the success rate of data transmission and user experience, and reduces server load and database access pressure.
Smart Images

Figure CN115883639B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information technology, and in particular to a web real-time message push method and device, equipment, and storage medium. Background Art
[0002] There are currently two ways to push web messages. One is the client polling method: the client and the server will communicate all the time, and the client will send a request to the server every once in a while to obtain the latest data stored in the current database. The other is a message push method based on the websocket protocol: the client sends a websocket connection request, the server responds, and implements an action similar to the TCP handshake, thereby forming an HTTP long connection fast channel between the browser client and the websocket server, which is used for direct data transmission between the browser client and the websocket server, without the need to initiate a connection and respond. At the same time, both the browser client and the websocket server can choose to have the above-mentioned long connection.
[0003] However, in the above technical solution, the client polling method will cause the user to fail to receive updated data in time when the polling interval is too long; when the polling interval is too short, it will lead to too many query requests, increasing the access pressure of the database and the load of the server; and it is impossible to achieve real-time message push. Although the message push method based on the websocket protocol can achieve real-time message push, there is a situation where the client does not receive the message after the server sends the message, that is, the message is lost. Summary of the invention
[0004] The embodiments of the present invention are intended to provide a web real-time message push method and apparatus, device, and storage medium, which can, on the basis of realizing real-time push of web messages, determine whether there is data loss in the data interaction between the client and the server by comparing the difference between the data received by the client and the data sent by the server. If there is data loss, the lost information is determined and the lost information is resent, so as to improve the success rate of data sending and reduce the risk of data loss.
[0005] The technical solution of the present invention is achieved in this way:
[0006] An embodiment of the present invention provides a web real-time message push method, the method is applied to a server, the server is provided with a Graphql service and a Kafka service, the method comprises:
[0007] Receiving a modification identifier acquisition request through the Graphql service; the modification identifier acquisition request carries modification information;
[0008] In response to the modification identification acquisition request, determining, according to the modification information, and sending, through the Graphql service, first timestamp information corresponding to the modification information to the client;
[0009] receiving an information query request through the Graphql service and the kafka service; the information query request carries second timestamp information; wherein the second timestamp information is the timestamp information received by the client;
[0010] In response to the information query request, based on the second timestamp information, the lost information is determined from the first timestamp information and sent to the client through the Graphql service; wherein the lost information is the timestamp information lost in the data interaction in the first timestamp information.
[0011] In the above solution, in response to the information query request, based on the second timestamp information, determining the missing information from the first timestamp information and sending it to the client through the Graphql service includes:
[0012] Based on the second timestamp information, comparing the first timestamp information to obtain a comparison result;
[0013] Based on the comparison result, the lost information is determined from the first timestamp information and sent to the client through the Graphql service.
[0014] In the above solution, comparing the first timestamp information based on the second timestamp information to obtain a comparison result includes:
[0015] The first sub-timestamp information and the second sub-timestamp information are compared until all timestamp information in the first timestamp information are screened to obtain a comparison result; wherein the first sub-timestamp information is any one of the timestamp information in the first timestamp information; and the second sub-timestamp information is any one of the timestamp information in the second timestamp information.
[0016] In the above solution, based on the comparison result, determining the lost information from the first timestamp information and sending it to the client through the Graphql service includes:
[0017] 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;
[0018] The loss information is determined from the sub-loss information.
[0019] In the above solution, determining the loss information from the sub-loss information includes:
[0020] From the sub-loss information, the sub-loss information with the largest value is determined as the loss information.
[0021] In the above scheme, the method further comprises:
[0022] Based on a preset period, determining a reference information sample from the second timestamp information;
[0023] The first timestamp information is deleted based on the reference information sample.
[0024] In the above solution, the step of determining the reference information sample from the second timestamp information based on a preset period includes:
[0025] Based on the preset period, second sub-timestamp information with the largest value is determined from the second timestamp information as the reference information sample.
[0026] In the above solution, the deleting process of the first timestamp information based on the reference information sample includes:
[0027] Based on the reference information sample, the first sub-timestamp information is compared to obtain a first comparison result;
[0028] If the first comparison result is that the first sub-timestamp information is smaller than the reference information sample, the timestamp information corresponding to the first sub-timestamp information is deleted.
[0029] In the above scheme, the method further comprises:
[0030] receiving a subscription request through the Graphql service; the subscription request carries the second timestamp information or the loss information;
[0031] In response to the subscription request, the subscription information is determined in the database according to the second timestamp information or the loss information and sent to the client through the Graphql service; wherein the subscription information represents the subject of the field change involved in the database at the time corresponding to the second timestamp information or the loss information.
[0032] An embodiment of the present invention provides a web real-time message push method, which is applied to a client, and the client is provided with a Graphql API (application programming interface), including:
[0033] Send a modification identification acquisition request to the server through the Graphql API; the modification identification request carries the modification information, and the client implements data interaction with the Graphql service of the server through the Graphql API
[0034] Receiving, through the Graphql API, second timestamp information sent by the server in response to the modification identifier acquisition request; wherein the second timestamp information is the timestamp information received by the client in the first timestamp information; and the first timestamp information is the timestamp information sent by the server;
[0035] Sending the information query request to the server through the Graphql API; the information query request carries the second timestamp information;
[0036] The lost information sent by the server in response to the information query request is received through the Graphql API; wherein the lost information is the timestamp information lost in the data interaction in the first timestamp information.
[0037] In the above scheme, the method further includes:
[0038] Sending a subscription request to the server through the Graphql API; wherein the subscription request carries the second timestamp information or the loss information;
[0039] Receiving, through the Graphql API, subscription information sent by the server in response to the subscription request; wherein the subscription information represents a subject of field changes at a time corresponding to the second timestamp information or the lost information in the database.
[0040] The embodiment of the present invention provides a web real-time message push device, comprising a first receiving unit, a determining unit and a first sending unit; wherein,
[0041] The first receiving unit is used to receive a modification identifier acquisition request through a Graphql service; the modification identifier acquisition request carries modification information; receive an information query request through the Graphql service and the kafka service; the information query request carries second timestamp information;
[0042] The determining unit is configured to determine, in response to the modification identification acquisition request, first timestamp information corresponding to the modification information according to the modification information; and in response to the information query request, determine the lost information from the first timestamp information based on the second timestamp information;
[0043] The first sending unit is used to send the first timestamp information to the client through the Graphql service; and is used to send the loss information to the client through the Graphql service.
[0044] In the above scheme, the determination unit is also used to compare the first timestamp information based on the second timestamp information to obtain a comparison result; based on the comparison result, determine the lost information from the first timestamp information and send it to the client through the Graphql service.
[0045] In the above scheme, the determination unit is also used to compare the first sub-timestamp information and the second sub-timestamp information until the first timestamp information is screened and a comparison result is obtained; wherein the first sub-timestamp information is any one of the first timestamp information; and the second sub-timestamp information is any one of the second timestamp information.
[0046] In the above scheme, the determination unit is also used to determine that the timestamp information corresponding to the first sub-timestamp information is sub-loss information if the comparison result is that the first sub-timestamp information is different from the second sub-timestamp information; and determine the loss information from the sub-loss information.
[0047] In the above solution, the determining unit is further used to determine the sub-loss information with the largest value from the sub-loss information as the loss information.
[0048] In the above solution, the device further includes a processing unit, wherein:
[0049] The determining unit is further configured to determine a reference information sample from the second timestamp information based on a preset period;
[0050] The processing unit is used to delete the first timestamp information based on the reference information sample.
[0051] In the above solution, the determining unit is further used to determine, based on the preset period, from the second timestamp information, the second sub-timestamp information with the largest value as the reference information sample.
[0052] In the above scheme, the processing unit is also used to compare the first sub-timestamp information based on the reference information sample to obtain a first comparison result; if the first comparison result is that the first sub-timestamp information is smaller than the reference information sample, the timestamp information corresponding to the first sub-timestamp information is deleted.
[0053] In the above solution, the first receiving unit is further used to receive a subscription request through the Graphql service; the subscription request carries the second timestamp information or the loss information;
[0054] The determining unit is further configured to determine subscription information in a database in response to the subscription request according to the second timestamp information or the loss information; wherein the subscription information represents a subject in the database that involves a field change at a time corresponding to the second timestamp information or the loss information;
[0055] The first sending unit is further used to send the subscription information to the client through the Graphql service.
[0056] The embodiment of the present invention provides a web real-time message push device, comprising a second receiving unit and a second sending unit; wherein,
[0057] The second receiving unit is used to receive, through the Graphql API, second timestamp information sent by the server in response to a modification identifier acquisition request; and receive, through the Graphql API, loss information sent by the server in response to an information query request;
[0058] The second sending unit is used to send a modification identifier acquisition request to the server through the Graphql API; the modification identifier request carries modification information; and send the information query request to the server through the Graphql API; the information query request carries the second timestamp information.
[0059] In the above scheme, the second receiving unit is further used to receive, through the Graphql API, subscription information sent by the server in response to the subscription request; wherein the subscription information represents the subject of the field change involved at the moment corresponding to the second timestamp information or the lost information in the database;
[0060] The second sending unit is further used 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.
[0061] An embodiment of the present invention provides a server, comprising:
[0062] A first memory, used to store executable instructions;
[0063] A first communication bus, used to implement communication between the first memory and the first processor;
[0064] The first processor is used to execute the executable instructions stored in the first memory to implement the web real-time message push method applied to the server as described in the embodiment of the present invention.
[0065] An embodiment of the present invention provides a client, the client comprising:
[0066] A second memory, used for storing executable instructions;
[0067] A second communication bus, used to implement communication between the second memory and the second processor;
[0068] The second processor is used to execute the executable instructions stored in the second memory to implement the web real-time message push method applied to the client as described in the embodiment of the present invention.
[0069] An embodiment of the present invention provides a storage medium storing executable instructions. When the executable instructions are executed, the storage medium causes a first processor to execute a web real-time message push method applied to a server as described in an embodiment of the present invention.
[0070] An embodiment of the present invention provides a storage medium storing executable instructions. When the executable instructions are executed, the second processor is used to execute the web real-time message push method applied to a server as described in the embodiment of the present invention.
[0071] The embodiment of the present invention provides a web real-time message push method and device, equipment, and storage medium; the method includes a server generating a first timestamp message based on a Graphql service and a kafka service according to the time of the modification operation occurring in the database and sending it to a client, and the client will receive a second timestamp information, and the second timestamp information is the timestamp information received by the client in the first timestamp information. The first timestamp information and the second timestamp information are compared to obtain loss information, and it can be determined whether there is data loss during the interaction between the server and the client. The loss information is sent to the client, so that the client can re-acquire the corresponding subscription information through the loss information.
[0072] The embodiment of the present invention can, on the basis of realizing real-time push of web messages, determine whether there is data loss in data interaction between the client and the server by comparing the difference between the data received by the client and the data sent by the server. If there is data loss, the lost information is determined and the lost information is resent, so as to improve the success rate of data sending and reduce the risk of data loss. BRIEF DESCRIPTION OF THE DRAWINGS
[0073] Figure 1A process of a web real-time message push method applied to a server provided in an embodiment of the present invention Figure 1 ;
[0074] Figure 2 A process of a web real-time message push method applied to a server provided in an embodiment of the present invention Figure 2 ;
[0075] Figure 3 A process of a web real-time message push method applied to a server provided in an embodiment of the present invention Figure 3 ;
[0076] Figure 4 A process of a web real-time message push method applied to a client provided by an embodiment of the present invention Figure 1 ;
[0077] Figure 5 A process of a web real-time message push method applied to a client provided by an embodiment of the present invention Figure 2 ;
[0078] Figure 6 A process of a web real-time message push method provided by an embodiment of the present invention Figure 1 ;
[0079] Figure 7 A process of a web real-time message push method provided by an embodiment of the present invention Figure 2 ;
[0080] Figure 8 A process of a web real-time message push method provided by an embodiment of the present invention Figure 3 ;
[0081] Fig. 9 A functional architecture diagram of a web real-time message push device provided by an embodiment of the present invention;
[0082] Fig.10 A functional architecture diagram of another web real-time message push device provided by an embodiment of the present invention;
[0083] Fig.11 A functional architecture diagram of a server provided in an embodiment of the present invention;
[0084] Fig.12 A functional architecture diagram of a client provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0085] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0086] Figure 1 The present invention provides a method for pushing web real-time messages to a server. Figure 1 ,like Figure 1 As shown, an embodiment of the present invention provides a web real-time message push method, which is applied to a server, and the server is provided with a Graphql service and a Kafka service, including:
[0087] S101. Receive a modification identification acquisition request through a Graphql service; the modification identification acquisition request carries modification information.
[0088] In the embodiment of the present invention, it is applicable to a scenario in which when a field in a database is modified, the server sends subject information related to the field change in the data to the client.
[0089] In an embodiment of the present invention, the server receives a modification identification acquisition request sent by the client through the Graphql service, wherein the modification identification acquisition request carries modification information.
[0090] In the embodiment of the present invention, the modification information is the field of the database that is modified by the user on the page or triggered by the server itself; the modification identification acquisition request is used to request the server to provide the identification information of the modified field in the database. The server determines the modified field in the database according to the identification information and sends the relevant information to the client.
[0091] In the embodiment of the present invention, the server can provide different data for the same scene through the Graphql service to meet the needs of the client application display; in actual use, the Graphql service is used to define which subscriptions the server can provide to the client, that is, a root type is added to the schema file of the server, and the root type is: Subscription; wherein Subscription is at the same level as Query and Mutation. The root type Subscription contains the messageAdded method definition, which indicates the topic that the client can subscribe to. When the field of the above topic is modified, the server notifies the client.
[0092] In an embodiment of the present invention, the server should periodically or in real time detect the connection status with the client. If the server detects that the connection between the server and the client is disconnected due to network reasons, it is necessary to try to reconnect. The number of reconnection attempts is set according to actual needs. For example, the maximum number of reconnection attempts can be set to 3 times.
[0093] It is understandable that the server obtains the request and modification information according to the received modification identifier, and provides the identifier of the modification information to the client, so that the server can subsequently push messages according to the needs of the client.
[0094] S102: In response to the modification identification acquisition request, determine, based on the modification information, and send, via the Graphql service, first timestamp information corresponding to the modification information to the client.
[0095] In the embodiment of the present invention, after receiving a modification identification acquisition request, the timestamp of the field that has changed in the database is determined and sent to the client.
[0096] In an embodiment of the present invention, after receiving the modification identification acquisition request and modification information sent by the client, the server responds to the modification identification acquisition request, determines the first timestamp information corresponding to the modification information according to the modification information, and sends the above-mentioned first timestamp information to the client through the Graphql service.
[0097] In the embodiment of the present invention, the modification information includes at least one piece of information, and the first timestamp information includes at least one timestamp information; wherein each piece of the at least one piece of information corresponds to one timestamp information in the at least one timestamp information.
[0098] In the embodiment of the present invention, the timestamp information corresponds to the time when the field in the database is modified, wherein the timestamp information is accurate to milliseconds.
[0099] It can be understood that the server determines the fields that have changed in the database through timestamp information, and can determine the fields that have changed within the required time period as needed, and then send the subject of the changed field to the client, thereby improving the efficiency of determining and sending messages and ensuring the accuracy of the subject of the determined field that has changed.
[0100] S103, receiving an information query request through the Graphql service and the kafka service, wherein the information query request carries second timestamp information, wherein the second timestamp information is the timestamp information received by the client.
[0101] The embodiment of the present invention is applicable to a scenario of obtaining a reception status of sent first timestamp information.
[0102] In the embodiment of the present invention, the server receives the information query request and the second timestamp information carried in the information query request through the Graphql service, and processes the second timestamp information through the kafka service. The second timestamp information is the timestamp information received by the client.
[0103] In the embodiment of the present invention, the second timestamp information is the timestamp information successfully received by the client in the first timestamp information sent by the server. The number of timestamp information in the second timestamp information should be less than or equal to the number of timestamp information in the first timestamp information, and the timestamp information in the second timestamp information and the timestamp information in the first timestamp information have the same timestamp information.
[0104] In the embodiment of the present invention, the information query request is used to request the server to query whether the first timestamp information is lost in the process of being sent to the client, and to resend the lost timestamp information to the client.
[0105] It is understandable that the server can find out whether there is data loss in the process of data interaction with the client by comparing the second timestamp information with the first timestamp information, so as to facilitate subsequent processing based on the data loss and reduce the risk of data loss.
[0106] S104. In response to the information query request, based on the second timestamp information, determine the missing information from the first timestamp information and send it to the client through the Graphql service; wherein the missing information is the timestamp information in the first timestamp information that is lost during the data interaction.
[0107] The embodiment of the present invention is applicable to a scenario in which a server determines lost data (lost information) during data interaction with a client, and sends the lost data to the client, thereby reducing the risk of data loss.
[0108] In the embodiment of the present invention, after receiving the information query request, the server responds to the information query request and determines the lost information in the first timestamp information based on the second timestamp information, where the lost information is the timestamp information lost in the data interaction between the server and the client, and sends the lost information to the client.
[0109] In the embodiment of the present invention, a Kafka service is set up in the server to introduce a Kafka message queue. In actual use, the first timestamp information and the second timestamp information are respectively saved in different variables (Kafka message queues), and the variables can be of the TreeSet class; the TreeSet class is a subclass of Set; the TreeSet class can ensure that the timestamp information saved in the TreeSet class is in a sorted state, that is, the timestamp information saved to the TreeSet class can be automatically sorted. In actual use, the server can generate two pieces of first timestamp information and save them to the variables through the Kafka service. Exemplarily, the first timestamp information is denoted as id1, id2, id3, id4, id5, id6, and id7; the second timestamp information is id1, id2, id3. The two pieces of first timestamp information and the second timestamp information are respectively saved in different TreeSet classes, and are respectively denoted as topic1, topic2, and topic3. The two pieces of first timestamp information are respectively saved in topic1 and topic2, that is, the set of timestamp information in topic1 is denoted as Set1 = (id1, id2, id3, id4, id5, id6, id7), and the set of timestamp information in topic2 is denoted as Set2 = (id1, id2, id3, id4, id5, id6, id7); the second timestamp information is saved in topic3, that is, the set of timestamp information in topic3 is denoted as Set3 = (id1, id2, id3). Among them, the server obtains the timestamp information from Set1 and sends it to the client.
[0110] In the embodiment of the present invention, since the sorting method is to sort in ascending order according to the value of the timestamp information, therefore, 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 timestamp information, the closer the timestamp of the modified field is to the current time, therefore, id7 in the first timestamp information is the timestamp information closest to the current time.
[0111] In the embodiment of the present invention, after determining the lost information, the server can save the lost information to topic1 and topic3 respectively.
[0112] In an embodiment of the present invention, a timer may be provided in the server, and the timer is used to periodically execute a preset task; wherein the preset task may be a comparison function, and the comparison function is used to compare the first timestamp information and the second timestamp information to determine the timestamp information lost during the data interaction process, and the timer may be created based on 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 timestamp information and the second timestamp information through the timer, it can be determined that id4, id5, id6, and id7 are lost during the data interaction process. All timestamp information lost during the data interaction process can be saved to Set1 and Set3 through the kafka service and sent to the client, or only part of the timestamp information lost during the data interaction process can be sent. In actual use, because users only care about the latest data, they are unaware of the fact that they did not receive data due to data loss in the intermediate process. Therefore, among the timestamp information lost during the data interaction process, the timestamp information with the largest value is determined and sent to the client as the lost information. That is, among id4, id5, id6 and id7, id7 is determined to be the lost information.
[0113] It can be understood that the server obtains the loss information according to the first timestamp information and the second timestamp information, and sends the loss information to the client, thereby ensuring the success rate of data transmission and reducing the risk of data loss.
[0114] In some embodiments of the present invention, S104 may further include S1041 and S1042, as follows:
[0115] S1041. Based on the second timestamp information, compare the first timestamp information to obtain a comparison result.
[0116] In some embodiments of the present invention, it is applicable to a scenario where lost information is determined based on the second timestamp information.
[0117] 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.
[0118] In some embodiments of the present invention, the server compares whether the timestamp information in the first timestamp information and the second timestamp information are the same, and obtains a comparison result.
[0119] In some embodiments of the present invention, the server compares the first sub-timestamp information and the second sub-timestamp information through the kafka service until the first timestamp information is screened to obtain a comparison result. The first sub-timestamp information is any timestamp information in the first timestamp information; the second sub-timestamp information is any timestamp information in the second timestamp information.
[0120] In some embodiments of the present invention, any time stamp information in the first time stamp information is taken as the first sub-time stamp information, and any time stamp information in the second time stamp information is taken as the second sub-time stamp information, and the first sub-time stamp information and the second sub-time stamp information are compared until all timestamp information in the first timestamp information is screened to obtain a comparison result.
[0121] It can be understood that by comparing the first timestamp information and the second timestamp information, the timestamp information lost during the data interaction process can be obtained.
[0122] S1042. Based on the comparison result, determine the missing information from the first timestamp information and send it to the client through the Graphql service.
[0123] In some embodiments of the present invention, it is applicable to determine a scenario where lost information is determined based on a comparison result.
[0124] 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 it to the client through the Graphql service.
[0125] In some embodiments of the present invention, the comparison result may include multiple sub-comparison results, each sub-comparison result corresponds to a timestamp information, and at least one timestamp information lost in the data interaction may be determined based on the multiple sub-comparison results.
[0126] It is understandable that, based on the comparison result, the timestamp information lost during the data interaction process is determined, and the lost timestamp information is resent to the client, thereby ensuring the success rate of information transmission.
[0127] In some embodiments of the present invention, S1042 may include S10421 and S10422 as follows:
[0128] S10421. If the comparison result is that the first sub-timestamp information is different from the second sub-timestamp information, determine that the timestamp information corresponding to the first sub-timestamp information is the sub-loss information.
[0129] In some embodiments of the present invention, it is applicable to determine the scenario of timestamp information lost during data interaction.
[0130] In some embodiments of the present invention, if the comparison result is 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.
[0131] In some embodiments of the present invention, based on the comparison results, at least one timestamp information lost in the data interaction can be determined; the lost information includes at least one sub-loss information, and each sub-loss information in the at least one sub-loss information corresponds to each timestamp information in the at least one timestamp information lost in the data interaction.
[0132] In some embodiments of the present invention, if the comparison result shows 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 the sub-loss information, and deletes the timestamp information corresponding to the first sub-timestamp information.
[0133] It can be understood that by determining the sub-loss information according to the comparison result and determining the loss information according to the sub-loss information, the amount of timestamp information sent to the client can be reduced, thereby reducing the transmission cost.
[0134] S10422. Determine the lost information from the sub-lost information.
[0135] In some embodiments of the present invention, it is applicable to the scenario of determining the loss information after determining the sub-loss information.
[0136] In some embodiments of the present invention, the server determines, from the sub-loss information, the sub-loss information with the largest time value as the loss information.
[0137] In some embodiments of the present invention, after determining that the sub-loss information with the largest time value is the loss information, the loss information is sent to the client.
[0138] It is understandable that after the server determines that the information is lost, it sends it to the client, which can ensure the success rate of data transmission and reduce the risk of data loss.
[0139] based on Figure 1 , Figure 2 The present invention provides a method for pushing web real-time messages to a server. Figure 2 ,like Figure 2 As shown, the program also includes:
[0140] S105. Determine a reference information sample from the first timestamp information based on a preset period.
[0141] The embodiment of the present invention is applicable to a scenario in which a timestamp information is determined from the first timestamp information as a reference information sample.
[0142] In the embodiment of the present invention, the server periodically determines a timestamp information from the first timestamp information as a reference information sample.
[0143] In an embodiment of the present invention, according to a preset period, all timestamp information within the period is obtained from the second timestamp information, and the timestamp information with the largest value is determined as a reference information sample. The timestamp information with the smallest value can also be determined as a reference information sample. The embodiment of the present invention is not limited to the exemplary embodiment. All timestamp information 1 minute ago in topic2 that stores the first timestamp information is recorded as Set2'=(id5,id6,id7), and the largest timestamp information id7 is the reference information.
[0144] In the embodiment of the present invention, if there is no timestamp information in the preset period in the first timestamp information, the server does not need to perform any operation.
[0145] It is understandable that such periodic deletion of unnecessary first timestamp information and second timestamp information can reduce data redundancy and the workload of comparing the first timestamp information and the second timestamp information to determine lost information, thereby improving work efficiency.
[0146] In some embodiments of the present invention, based on a preset period, the first sub-timestamp information with the largest value is determined as the reference information sample from the first timestamp information, wherein the first sub-timestamp information is any timestamp information in the first timestamp information.
[0147] In some embodiments of the present invention, since it is not necessary to consider whether the user has not received 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.
[0148] S106: Deleting the first timestamp information and the second timestamp information based on the reference information sample.
[0149] The embodiment of the present invention is applicable to a scenario where the first timestamp information and the second timestamp information are processed.
[0150] In the embodiment of the present invention, based on the reference information sample determined in S105, the server deletes the timestamp information that meets the preset requirements in the first timestamp information and the second timestamp information.
[0151] In an embodiment of the present invention, the preset requirement may be that the value is smaller than the reference information sample. Exemplarily, the timestamp information with the largest value is determined from Set2 = (id1, id2, id3, id4, id5, id6, id7) and Set3 = (id1, id2, id3) as the reference information sample, that is, id7; wherein id7 represents the timestamp information with the largest value among the timestamp information sent from the server to the client 1 minute ago, and all the timestamp information with a value smaller than id7 in Set2 = (id1, id2, id3, id4, id5, id6, id7) and Set3 = (id1, id2, id3) is deleted. After deletion, Set2 = (id7) is obtained, and Set3 is an empty set.
[0152] It can be understood that deleting the first timestamp information and the second timestamp information in this way can reduce data redundancy and improve work efficiency.
[0153] In some embodiments of the present invention, S106 may include S1061 and S1062 as follows:
[0154] S1061. Compare the first sub-timestamp information and the second sub-timestamp information based on the reference information sample to obtain a first comparison result.
[0155] In some embodiments of the present invention, it is applicable to a scenario where the timestamp information that needs to be deleted is determined between the first timestamp information and the second timestamp information.
[0156] 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.
[0157] It can be understood that in this way, the timestamp information that needs to be deleted in the first sub-timestamp information and the second sub-timestamp information can be accurately determined.
[0158] S1062: If the first comparison result is that the first sub-timestamp information is smaller than the reference information sample, delete the timestamp information corresponding to the first sub-timestamp information.
[0159] In some embodiments of the present invention, it is applicable to a scenario where unnecessary timestamp information in the first timestamp information and the second timestamp information is deleted.
[0160] 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 deletes the timestamp information corresponding to the first sub-timestamp information or the second timestamp information.
[0161] In some embodiments of the present invention, if a timestamp information is smaller than a reference information sample, it means that the timestamp information does not need to be sent to the client to inform the user, and therefore, the timestamp information is deleted.
[0162] It is understandable that data redundancy can be reduced and work efficiency can be improved.
[0163] based on Figure 1 , Figure 3 The present invention provides a method for pushing web real-time messages to a server. Figure 3 ,like Figure 3 As shown, the program also includes:
[0164] S107. Receive a subscription request through the Graphql service; the subscription request carries the second timestamp information or the loss information.
[0165] The embodiment of the present invention is applicable to the scenario where the server pushes messages to the client.
[0166] In the embodiment of the present invention, the server receives a subscription request sent by the client and the second timestamp information or loss information carried in the subscription request through the Graphql service.
[0167] In the embodiment of the present invention, the subscription request is used to request push of subscribed messages from the server.
[0168] In an embodiment of the present invention, the server includes a subscription parser, which can use published events to parse subscription requests sent by the client, set nested objects in the subscription parser, and send subscription information generated in response to the subscription request to the client through the subscription parser.
[0169] It can be understood that the server responds to the client's request based on the subscription request, so that the client meets the user's needs.
[0170] S108. In response to the subscription request, determine the subscription information in the database according to the second timestamp information or the loss information, and send it to the client through the Graphql service; wherein the subscription information represents the subject of the field change involved in the database at the time corresponding to the second timestamp information or the loss information.
[0171] The embodiment of the present invention is applicable to the scenario of providing subscription information to a client.
[0172] In an embodiment of the present invention, the server determines the subscription information in the database based on the second timestamp information or the loss information and sends it to the client through the Graphql service, wherein the subscription information is a response result of the subscription request, and the subscription information represents the subject of the field change involved in the database at the time corresponding to the second timestamp information or the loss information.
[0173] It is understandable that the server sends subscription information to the client so that the client can display the latest data in real time to meet user needs.
[0174] Figure 4 The present invention provides a method for pushing web real-time messages to a client. Figure 1 ,like Figure 4 As shown, a web real-time message push method provided by an embodiment of the present invention is applied to a client, and the client is provided with a Graphql API (Application Programming Interface); comprising:
[0175] S201. Send a modification identification acquisition request to the server through the Graphql API; the modification identification request carries modification information, and the client implements data interaction with the Graphql service of the server through the Graphql API.
[0176] The embodiment of the present invention is applicable to the scenario of requesting to push subject information involving field changes in a database.
[0177] In an embodiment of the present invention, the client sends a modification identification acquisition request to the server through the Graphql API, and carries the modification information through the modification identification acquisition request to request to obtain the main body information involving field changes in the database corresponding to the modification information.
[0178] In the embodiment of the present invention, before sending a modification identifier acquisition request, the client needs to first create an instance of the subscription root type added in S101 for subscription in the client as a network interface, that is, as a Graphql API; through the above Graphql API, the client can execute ordinary Graphql queries and subscription queries through WebSockets through HTTP, that is, the client can implement data interaction with the server's Graphql service through the above Graphql API. And create an observable execution operation on the client, the above execution operation contains the request interface definition and request parameter value of the subscription root type of the server to which the client will connect.
[0179] It is understandable that the client sends and receives the timestamp information of the messages that need to be pushed in real time through the Graphql API, which is conducive to decoupling the data processing process on the server side, improving the access pressure resistance, so that the client will not crash due to sudden overload requests.
[0180] S202. Receive, through the Graphql API, second timestamp information sent by the server in response to a modification identifier acquisition request; wherein the second timestamp information is the timestamp information received by the client in the first timestamp information; and the first timestamp information is the timestamp information sent by the server.
[0181] The embodiment of the present invention is applicable to a scenario in which a second timestamp message sent by a server is received.
[0182] In the embodiment of the present invention, the client receives, through the Graphql API, second timestamp information sent by the server in response to a modification identifier acquisition request; the first timestamp information is the timestamp information sent by the server. Since the first timestamp information may be lost during the data interaction process, the timestamp information received by the client in the first timestamp information is recorded as the second timestamp information.
[0183] It is understandable that the client can ensure the orderliness of the second timestamp information, thereby ensuring the timeliness of the subscription information subsequently acquired by the client according to the second timestamp information.
[0184] S203. Send an information query request to the server through the Graphql API; the information query request carries the second timestamp information.
[0185] The embodiment of the present invention is applicable to a scenario in which a client queries whether data is lost when performing data interaction with a server.
[0186] In the embodiment of the present invention, the client sends the second timestamp information together with the information query request to the server through the Graphql API.
[0187] In the embodiment of the present invention, the information query request is used to request the server to determine from the first timestamp information whether there is timestamp information that the client has not received based on the second timestamp information.
[0188] In the embodiment of the present invention, if there is timestamp information that the client has not received, the information query request is also used to request the server to send the timestamp information that the client has not received to the client. In actual use, the information query request can also be used to request the server to send the timestamp information with the largest value among the timestamp information received by the client to the client.
[0189] It is understandable that, through the information query request, it can be determined whether there is any data loss during the data interaction between the client and the server.
[0190] S204. Receive, through the Graphql API, lost information sent by the server in response to the information query request; wherein the lost information is timestamp information in the first timestamp information that is lost in the data interaction.
[0191] The embodiment of the present invention is applicable to a scenario in which a client obtains timestamp information lost during data interaction with a server.
[0192] In the embodiment of the present invention, the client receives the loss information sent by the server in response to the information query request, and the loss information is the timestamp information lost in the data interaction in the first timestamp information.
[0193] It is understandable that after the client receives the lost information, it can obtain the subject information of the design field changes in the database corresponding to the lost information based on the lost information, and display it to the user; this can ensure the success rate of data sending, reduce the risk of data loss, and ensure the integrity of the subscription information received by the user.
[0194] based on Figure 4 , Figure 5 The present invention provides a method for pushing web real-time messages to a client. Figure 2 ,like Figure 5 As shown, a web real-time message push method provided in some embodiments of the present invention further includes:
[0195] S205, sending a subscription request to the server through the Graphql API, wherein the subscription request carries the second timestamp information or the loss information.
[0196] The embodiment of the present invention is applicable to a scenario in which a client requests a server to push subscription information subscribed by a user through the client.
[0197] In an embodiment of the present invention, the client sends a subscription request to the server through the Graphql API. When the client sends the subscription request, the subscription request carries the second timestamp information or the loss information.
[0198] In the embodiment of the present invention, whether the subscription request carries the second timestamp information or the loss information is determined according to the value of the timestamp information in the second timestamp information and the loss information. The timestamp information with the largest value between the second timestamp information and the loss information is determined, and the subscription request carries the timestamp information with the largest value to the server.
[0199] It is understandable that the client can request the server to send a subscription message that is closest to the current time, and the probability of losing the subscription message due to the loss of timestamp information can be reduced.
[0200] S206, receiving subscription information sent by the server in response to the subscription request through the Graphql API, wherein the subscription information represents the subject of the field change related to the moment corresponding to the second timestamp information or the lost information in the database.
[0201] The embodiment of the present invention is applicable to the scenario where a client receives subscription information.
[0202] In an embodiment of the present invention, the client receives subscription information sent by the server in response to a subscription request through the Graphql API, and the subscription information represents a subject of field changes at a time corresponding to the second timestamp information or the lost information in the database.
[0203] In the embodiment of the present invention, the subscription information is subject information in a database subscribed by the client, in which a field change occurs at a time corresponding to the second timestamp information or the loss information.
[0204] It can be understood that the client requests the subscription information according to the second timestamp information or the loss information, which can ensure the success rate of receiving the subscription information and improve the user experience.
[0205] Figure 6 This is a process of a web real-time message push method provided by an embodiment of the present invention Figure 1 ,like Figure 6 As shown, some embodiments of the present invention provide a web real-time message push method, including:
[0206] S301, the client sends a modification identification acquisition request and modification information to the server.
[0207] S302: The server responds to the modification identification acquisition request and determines, according to the modification information, first timestamp information corresponding to the modification information.
[0208] S303: The server sends first timestamp information to the client.
[0209] 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.
[0210] S305. The server determines the lost information from the first timestamp information based on the second timestamp information in response to the information query request.
[0211] S306: The server sends loss information to the client.
[0212] S307: The client sends a subscription request and second timestamp information or loss information to the server.
[0213] S308: The server determines the subscription information in the database in response to the subscription request according to the second timestamp information or the loss information.
[0214] S309: The server sends subscription information to the client.
[0215] It can be understood that in the embodiments of the present invention, it is possible to determine whether data loss occurs during data interaction between the server and the client, and it is possible to determine the lost information and resend the lost information, thereby ensuring the success rate of data transmission, reducing the risk of data loss, and ensuring the integrity of the subscription information received by the user.
[0216] Figure 7 This is a process of a web real-time message push method provided by an embodiment of the present invention Figure 2 ,like Figure 7 As shown, some embodiments of the present invention provide a web real-time message push method, including:
[0217] S401. Set up Graphql subscription and subscription resolver on the server.
[0218] In some embodiments of the present invention, the setting of the Graphql service is completed by setting up a Graphql subscription and a subscription resolver on the server; wherein the Graphql subscription is used to define the subscription type that the client can request, and the subscription resolver can save resources by defining a filter function to specify whether the event should pass through a filter for given event data and query variables.
[0219] S402: The client creates an instance of subscription and requests interface definition.
[0220] In some embodiments of the present invention, the setting of the Graphql API is completed by creating an instance of a subscription and a request interface definition to achieve data interaction between the client and the server.
[0221] S403: The user or server triggers data change.
[0222] In some embodiments of the present invention, when a user makes a modification on a page, or the server itself triggers a modification operation on the database, modification information will be generated.
[0223] S404, the producer (consumer producer) end of kafka sends the number id1 (second timestamp information) to topic1.
[0224] In some embodiments of the present invention, the server numbers the modification information according to the modification information generated in S403 and sends the modification information to the client.
[0225] In some embodiments of the present invention, based on the kafka service set up on the server, after receiving the number id1, the server sends the id1 to topic1 through the producer end of kafka, where the id is a timestamp accurate to ms, corresponding to the time when the field in the database is modified.
[0226] S405. The Kafka consumer consumes id1 from topic1.
[0227] In some embodiments of the present invention, the server is based on the kafka service and sends id1 to the server through the consumer end of kafka. When the consumer end sends id1, it also generates a subscription request and sends it to the server to request the server to provide subscribed data based on id1.
[0228] S406. The server queries the database and publishes a message on the topic involving field changes; the producer end of Kafka sends the number id1 to topic2.
[0229] In some embodiments of the present invention, after receiving the message id1, the server immediately queries the database and publishes a message corresponding to the topic involving the field change corresponding to id1.
[0230] In some embodiments of the present invention, the server is based on the kafka service, and sends the number id1 to topic2 through the producer end of kafka for backup, which represents the number sent by the server to the client.
[0231] S407. The client receives data (subscription information) in real time through the subscription type definition of the server.
[0232] In some embodiments of the present invention, the client defines, according to the subscription type of the server, that the data received is a topic that the server is allowed to provide.
[0233] S408, the client re-renders the page; the client sends id1 to the server through a Graphql Quary type request.
[0234] In some embodiments of the present invention, after receiving the subscribed data, the client re-renders the page to display the received data to the user.
[0235] In some embodiments of the present invention, the server further includes a root type Query and a root type Mutation. The root type Query and the root type Mutation, as well as the root type Subscription, are at the same level. The client communicates with the Graphql service of the server through the Graphql API, and sends id1 to the server through a Graphql Quarry type request.
[0236] S409, Kafka's producer sends id1 to topic3.
[0237] In some embodiments of the present invention, the server is based on the kafka service, and sends id1 to topic3 through kafka for storage, indicating that the client has received and received the data corresponding to id1.
[0238] S410, the consumer end of Kafka compares the difference between the numbers in topic2 and topic3, and determines whether id1 needs to be resent to topic1. If the judgment result is necessary, proceed to S406.
[0239] In some embodiments of the present invention, the number in topic2 is sent by the server to the client, and the number in topic3 is the data received in real time by the client when the server publishes a message according to the number; the server is based on the kafka service, and compares the difference in the numbers in topic2 and topic3 through the consumer end of kafka to obtain the data that the client has not received.
[0240] In some embodiments of the present invention, if it is necessary to resend id1 to topic1, then S406 is performed; if not, no operation is performed.
[0241] It can be understood that in the embodiment of the present invention, the server adopts the data consumption mechanism of kafka to compare the difference between the data received by the client (second timestamp information) and the data sent by the server (first timestamp information), finds out the message that fails to be pushed (lost information) and resends it, which can effectively ensure the success rate of data transmission and avoid the risk of data loss; the client implements communication (data interaction) with the Graphql service of the server through the Graphql API, supports full websocket transmission, realizes real-time web applications based on Graphql, and also has the advantage of less data, that is, the server allows the client to define the data structure required, and the server can return the required data structure, thereby significantly saving network transmission resources, improving the efficiency of responding to requests, and reducing resource waste.
[0242] Figure 8 This is a process of a web real-time message push method provided by an embodiment of the present invention Figure 3 ,like Figure 8 As shown, some embodiments of the present invention provide a web real-time message push method, including:
[0243] S501, the server determines the maximum value in the set of numbers consumed by the client in topic3, Set3 = (id1, id2, id3, ...), recorded as id max (Refer to sample information).
[0244] In some embodiments of the present invention, in addition to the Graphql service and the kafka service, a setInterval timer may also be set in the server; wherein the setInterval timer is independent of the Graphql service, and the setInterval timer is used to execute the comparison function shown in S502-S506 once every minute in the processing logic.
[0245] In some embodiments of the present invention, the set of numbers consumed by the client in topic3 is recorded as Set3 = (id1, id2, id3, ...), and the set of numbers consumed by the client in topic2 is recorded as Set2 = (id1, id2, id3, ...). The server determines the id in Set3 max Among them, id max This is the largest number received by the client in Set3.
[0246] S502: The server deletes the set of numbers consumed by the client in topic2, Set2 = (id1, id2, id3, ...) and the set of numbers consumed by the client in topic3, Set3 = (id1, id2, id3, ...) that are less than id max Number.
[0247] In some embodiments of the present invention, since the user only cares about the data corresponding to the latest number, the user is unaware of the data not received due to the loss of the number or data in the middle process, so there is no need to consider whether the user has not received the ID. <id max The number or the data corresponding to the number.
[0248] S503: The server takes the number set from Set2=(id1, id2, id3, ...) one minute ago and records it as Set2'.
[0249] In some embodiments of the present invention, Set2′ may be Set2′=(id5, id6, id7, . . . ), which is used to indicate the numbers that were not received by the client one minute ago.
[0250] S504: The server determines whether Set2′ is an empty set.
[0251] In some embodiments of the present invention, if Set2′ is not an empty set, it means that the client has an unreceived number 1 minute ago, that is, there is data loss in the data interaction between the client and the server.
[0252] S505. If Set2′ is not an empty set, take the maximum value from Set2′ and record it as id′ max ; If Set2′ is an empty set, the server stops.
[0253] In some embodiments of the present invention, id′ max This value indicates the number of the data that was not received by the client 1 minute ago and is closest to the current time.
[0254] S506: Server sends id' max To the client, the client sends id′ max Send to topic1.
[0255] In some embodiments of the present invention, the server sends id' max To the client, the client then sends id′ max Send to topic1 to resend id' according to the request server max The corresponding data.
[0256] It can be understood that the embodiments of the present invention can reduce data redundancy, send only the latest data to the client, and ensure the real-time nature of the data.
[0257] Fig. 9 is a functional architecture diagram of a web real-time message push device provided by an embodiment of the present invention, such as Fig. 9 As shown, an embodiment of the present invention provides a web real-time message push device 9, corresponding to a web real-time message push method, including a first receiving unit 91, a determining unit 92 and a first sending unit 93; wherein,
[0258] The first receiving unit 91 is used to receive a modification identifier acquisition request through the Graphql service; the modification identifier acquisition request carries modification information; receive an information query request through the Graphql service and the kafka service; the information query request carries second timestamp information;
[0259] The determining unit 92 is configured to determine, in response to the modification identification acquisition request, first timestamp information corresponding to the modification information according to the modification information; and in response to the information query request, determine the lost information from the first timestamp information based on the second timestamp information;
[0260] The first sending unit 93 is used to send the first timestamp information to the client through the Graphql service; and is used to send the loss information to the client through the Graphql service.
[0261] 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 to obtain a comparison result; and determine the lost information from the first timestamp information based on the comparison result.
[0262] In some embodiments of the present invention, the determination unit 92 is also used to compare the first sub-timestamp information and the second sub-timestamp information until the first timestamp information is screened to obtain a comparison result; wherein the first sub-timestamp information is any one of the first timestamp information; and the second sub-timestamp information is any one of the second timestamp information.
[0263] In some embodiments of the present invention, the determination unit 92 is further used to determine that the timestamp information corresponding to the first sub-timestamp information is sub-loss information if the comparison result is that the first sub-timestamp information is different from the second sub-timestamp information; and determine the loss information from the sub-loss information.
[0264] In some embodiments of the present invention, the determining unit 92 is further configured to determine, from among the sub-loss information, sub-loss information with a maximum value as the loss information.
[0265] In some embodiments of the present invention, the device further comprises a processing unit, wherein:
[0266] The determining unit 92 is further configured to determine a reference information sample from the second timestamp information based on a preset period;
[0267] The processing unit 94 is further configured to delete the first timestamp information based on the reference information sample.
[0268] In some embodiments of the present invention, the determining unit is further configured to determine, based on the preset period, from the second timestamp information, second sub-timestamp information with a maximum value as the reference information sample.
[0269] In some embodiments of the present invention, the processing unit 94 is also used to compare the first sub-timestamp information based on the reference information sample to obtain a first comparison result; if the first comparison result is that the first sub-timestamp information is smaller than the reference information sample, the timestamp information corresponding to the first sub-timestamp information is deleted.
[0270] In some embodiments of the present invention, the first receiving unit 91 is further used to receive a subscription request through the Graphql service; the subscription request carries the second timestamp information or the loss information.
[0271] The determining unit 92 is further configured to determine subscription information in a database in response to the subscription request according to the second timestamp information or the loss information; wherein the subscription information represents a subject in the database that involves a field change at a time corresponding to the second timestamp information or the loss information;
[0272] The first sending unit 93 is further configured to send the subscription information to the client via the Graphql service.
[0273] Fig.10 is a functional architecture diagram of another web real-time message push device provided by an embodiment of the present invention, such as Fig.10 As shown, the embodiment of the present invention provides another web real-time message push device 11, corresponding to a web real-time message push method, including a second receiving unit 111 and a second sending unit 112; wherein,
[0274] The second receiving unit 111 is configured to receive, through the Graphql API, second timestamp information sent by the server in response to the modification identifier acquisition request; and receive, through the Graphql API, loss information sent by the server in response to the information query request;
[0275] The second sending unit 112 is used to send a modification identifier acquisition request to the server through the Graphql API; the modification identifier request carries modification information; send the information query request to the server through the Graphql API; the information query request carries the second timestamp information.
[0276] 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; wherein the subscription information represents a subject of a field change involved in a moment corresponding to the second timestamp information or the lost information in the database;
[0277] 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.
[0278] Fig.11 is a functional architecture diagram of a server provided by an embodiment of the present invention, such as Fig.11 As shown, an embodiment of the present invention further provides a server 12, and corresponds to a web real-time message push method applied to the server, including a first processor 121, a first memory 122 and a first communication bus 124. 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. When the one or more programs are executed, the first processor 121 executes the web real-time message push method as in the embodiment of the present invention. Specifically, the server 12 also includes a first communication component 123 for data transmission, wherein the first processor 121 is provided with at least one.
[0279] In the embodiment of the present invention, the components in the server 12 are coupled together via the bus 124. It is understood that the bus 124 is used to realize the connection and communication between these components. In addition to the data bus, the bus 124 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Fig.11 Various buses are labeled as passing through bus 124.
[0280] Fig.12 is a functional architecture diagram of a client provided by an embodiment of the present invention, such as Fig.12 As shown, an embodiment of the present invention further provides a client 13, and corresponds to a web real-time message push method applied to the client, including a second processor 131, a second memory 132 and a second communication bus 134. The second memory 132 communicates with the second processor 131 via the second communication bus 134. The second memory 132 stores one or more programs executable by the second processor 131. When the one or more programs are executed, the second processor 131 executes the web real-time message push method as in the embodiment of the present invention. Specifically, the client 13 also includes a second communication component 133 for data transmission, wherein the second processor 131 is provided with at least one.
[0281] In the embodiment of the present invention, the components in the client 13 are coupled together via a bus 134. It is understood that the bus 134 is used to realize the connection and communication between these components. In addition to the data bus, the bus 134 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Fig.12 Various buses are labeled as passing through bus 134.
[0282] An embodiment of the present invention provides a storage medium, wherein the storage medium stores executable instructions, and when the executable instructions are executed, the first processor is used to execute the web real-time message push method applied to the server as described in the embodiment of the present invention.
[0283] An embodiment of the present invention provides a storage medium storing executable instructions. When the executable instructions are executed, the second processor is used to execute the web real-time message push method applied to a client as described in the embodiment of the present invention.
[0284] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of hardware embodiments, software embodiments, or embodiments combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer-usable program code.
[0285] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0286] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0287] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0288] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention.
Claims
1. A web real-time message push method, characterized in that: The method is applied to a server, the server is provided with a Graphql service and a Kafka service, and the method comprises: Receiving a modification identifier acquisition request through the Graphql service; the modification identifier acquisition request carries modification information; In response to the modification identification acquisition request, determining, according to the modification information, and sending, through the Graphql service, first timestamp information corresponding to the modification information to the client; receiving an information query request through the Graphql service and the kafka service; the information query request carries second timestamp information; wherein the second timestamp information is the timestamp information received by the client; In response to the information query request, comparing the first timestamp information based on the second timestamp information to obtain a comparison result; Based on the comparison result, lost information is determined from the first timestamp information and sent to the client through the Graphql service; wherein the lost information is the timestamp information in the first timestamp information that is lost during data interaction.
2. The method according to claim 1, characterized in that The comparing the first timestamp information based on the second timestamp information to obtain a comparison result includes: The first sub-timestamp information and the second sub-timestamp information are compared until all timestamp information in the first timestamp information are screened to obtain the comparison result; wherein the first sub-timestamp information is any one of the timestamp information in the first timestamp information; and the second sub-timestamp information is any one of the timestamp information in the second timestamp information.
3. The method according to claim 2, characterized in that The determining, based on the comparison result, from the first timestamp information, the lost information and sending it 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-loss information; The loss information is determined from the sub-loss information.
4. The method according to claim 3, characterized in that The step of determining the loss information from the sub-loss information comprises: From the sub-loss information, the sub-loss information with the largest value is determined as the loss information.
5. The method according to claim 1, characterized in that The method further comprises: Based on a preset period, determining a reference information sample from the first timestamp information; Based on the reference information sample, the first timestamp information and the second timestamp information are deleted.
6. The method according to claim 5, characterized in that The determining, based on a preset period, a reference information sample from the first timestamp information includes: Based on the preset period, the first sub-timestamp information with the largest value is determined from the first timestamp information as the reference information sample.
7. The method according to claim 5 or 6, characterized in that: The deleting the first timestamp information and the second timestamp information based on the reference information sample includes: Based on the reference information sample, comparing the first sub-timestamp information and the second sub-timestamp information to obtain a first comparison result; 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, the timestamp information corresponding to the first sub-timestamp information and the second sub-timestamp information is deleted.
8. The method according to claim 1, characterized in that The method further comprises: Receiving a subscription request through the Graphql service; the subscription request carries the second timestamp information or the loss information; In response to the subscription request, the subscription information is determined in the database according to the second timestamp information or the loss information and sent to the client through the Graphql service; wherein the subscription information represents the subject of the field change involved in the database at the time corresponding to the second timestamp information or the loss information.
9. A web real-time message push method, characterized in that: The method is applied to a client, and the client is provided with a Graphql API, comprising: Sending a modification identification acquisition request to the server through the Graphql API; the modification identification acquisition request carries the modification information, and the client implements data interaction with the Graphql service of the server through the Graphql API; Receiving, through the Graphql API, second timestamp information sent by the server in response to the modification identifier acquisition request; wherein the second timestamp information is the timestamp information received by the client in the first timestamp information; and the first timestamp information is the timestamp information sent by the server; Sending an information query request to the server through the Graphql API; the information query request carries the second timestamp information; Receiving, through the Graphql API, lost information sent by the server in response to the information query request; wherein the lost information is timestamp information in the first timestamp information that is lost in data interaction; The lost information is determined by the server from the first timestamp information based on the second timestamp information by comparing the first timestamp information to obtain a comparison result, and then the lost information is determined from the first timestamp information based on the comparison result.
10. The method according to claim 9, characterized in that The method further comprises: 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, through the Graphql API, subscription information sent by the server in response to the subscription request; wherein the subscription information represents a subject of field changes at a time corresponding to the second timestamp information or the lost information in the database.
11. A web real-time message push device, characterized in that: It includes a first receiving unit, a determining unit and a first sending unit; wherein, The first receiving unit is used to receive a modification identifier acquisition request through a Graphql service; the modification identifier acquisition request carries modification information; receive 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 to determine, in response to the modification identification acquisition request, first timestamp information corresponding to the modification information according to the modification information; in response to the information query request, compare the first timestamp information based on the second timestamp information to obtain a comparison result, and determine the missing information from the first timestamp information based on the comparison result; the first sending unit is used to send the first timestamp information to the client through the Graphql service; and is used to send the missing information to the client through the Graphql service.
12. A web real-time message push device, characterized in that: It includes a second receiving unit and a second sending unit; wherein, The second receiving unit is used to receive, through the Graphql API, second timestamp information sent by the server in response to a modification identifier acquisition request; and receive, through the Graphql API, loss information sent by the server in response to an information query request; The lost information is determined by the server based on the second timestamp information by comparing the first timestamp information to obtain a comparison result, and the comparison result is determined from the first timestamp information; the second sending unit is used to send the modification identifier acquisition request to the server through the Graphql API; the modification identifier request carries the modification information; and the information query request is sent to the server through the Graphql API; the information query request carries the second timestamp information.
13. A server, characterized in that: The server comprises: A first memory, used to store executable instructions; A first communication bus, used to implement communication between the first memory and the first processor; The first processor is used to execute the executable instructions stored in the first memory to implement the method according to any one of claims 1-8.
14. A client, characterized in that: The client comprises: A second memory, used for storing executable instructions; A second communication bus, used to implement communication between the second memory and the second processor; The second processor is used to execute the executable instructions stored in the second memory to implement the method according to claim 9 or 10.
15. A storage medium, characterized in that: The storage medium stores executable instructions, which, when executed, are used to cause the first processor to execute the method according to any one of claims 1 to 8; or, are used to cause the second processor to execute the method according to claim 9 or 10.
