CN112351068A - Information synchronization method, system, device, computer equipment and storage medium - Google Patents

Information synchronization method, system, device, computer equipment and storage medium Download PDF

Info

Publication number
CN112351068A
CN112351068A CN202011052983.5A CN202011052983A CN112351068A CN 112351068 A CN112351068 A CN 112351068A CN 202011052983 A CN202011052983 A CN 202011052983A CN 112351068 A CN112351068 A CN 112351068A
Authority
CN
China
Prior art keywords
message
client
long connection
topic
theme
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
CN202011052983.5A
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.)
Suning Cloud Computing Co Ltd
Original Assignee
Suning Cloud Computing 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 Suning Cloud Computing Co Ltd filed Critical Suning Cloud Computing Co Ltd
Priority to CN202011052983.5A priority Critical patent/CN112351068A/en
Publication of CN112351068A publication Critical patent/CN112351068A/en
Priority to CA3131954A priority patent/CA3131954C/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W4/00Services specially adapted for wireless communication networks; Facilities therefor
    • H04W4/12Messaging; Mailboxes; Announcements

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application relates to an information synchronization method, a system, a device, a computer device and a storage medium, wherein the method comprises the following steps: receiving a message and a message theme sent by a client, and publishing the message and the message theme to a message middleware so that any server subscribes the message and the message theme from the message middleware; subscribing the topic message associated with the message topic in the message middleware, wherein the message middleware is used for receiving the topic message published by any server; when any topic message associated with the message topic is subscribed from the message middleware, any topic message is synchronously pushed to the client. The method realizes real-time information synchronization by adopting a message topic publishing and subscribing mode without realizing synchronous forwarding of the information in the same server.

Description

Information synchronization method, system, device, computer equipment and storage medium
Technical Field
The present application relates to the field of information processing technologies, and in particular, to an information synchronization method, system, apparatus, computer device, and storage medium.
Background
At present, information synchronization among a plurality of clients is widely applied to various industries of computers. A conventional way of synchronizing information of multiple clients is shown in fig. 1. Fig. 1 shows an information synchronization mechanism between 2 clients, where in order to implement information synchronization between a client 1(client1) and a client 2(client2), a connection needs to be respectively established with a backend server a, and the backend server a needs to maintain a topic of information to be maintained by multiple clients. Client1 and client2 send messages to the same backend server a. The backend server a needs to maintain all client connections on the topic. For example, a message sent by client1 needs to be forwarded to client2, and a message sent by client2 needs to be forwarded to client 1. When there are multiple clients, the pressure of a single backend server a will be very large. If the topic of another information needs to be synchronized, it becomes very complicated and difficult for the backend server a to maintain multiple clients.
Therefore, the conventional information synchronization method has the following problems: if a server maintains a plurality of message themes, the server is difficult to maintain when a plurality of clients are required to be controlled to be connected to different servers, and the capacity planning of the server is difficult. When a single server synchronously forwards information, the real-time performance of the information is difficult to guarantee due to the limitations of IO (input/output) and cpu (central processing unit) memories of the server.
Disclosure of Invention
Based on this, it is necessary to provide an information synchronization method, system, apparatus, computer device and storage medium for implementing real-time information synchronization by publishing and subscribing to message topics without implementing synchronous forwarding of information in the same server.
A method of synchronizing information, the method comprising: receiving a message and a message theme sent by a client, and publishing the message and the message theme to a message middleware so that any server subscribes the message and the message theme from the message middleware; subscribing the topic message associated with the message topic in the message middleware, wherein the message middleware is used for receiving the topic message published by any server; in one embodiment, the method further includes: establishing long connection with a client to generate a client identifier of the client; associating the long connection with the client identity; receiving a message and a message theme sent by a client, wherein the message theme comprises: receiving a message and a message theme sent by a client through long connection; synchronously pushing any theme message to the client, comprising: and determining long connection according to the client identification, and synchronously pushing any theme message to the client through the long connection.
In one embodiment, the number of the clients is multiple, and the multiple clients comprise a first client and a second client; establishing a long connection with a client, generating a client identifier of the client, and associating the long connection with the client identifier, wherein the method comprises the following steps: establishing a first long connection with a first client and a second long connection with a second client; generating a first identification of a first client and a second identification of a second client; associating the first long connection with a first identifier and the second long connection with a second identifier; receiving messages and message themes sent by a client through a long connection, comprising: receiving a message and a message theme sent by a first client through a first long connection, and receiving a message and a message theme sent by a second client through a second long connection; determining long connection according to the client identification, and synchronously pushing any theme message to the client through the long connection, wherein the method comprises the following steps: determining a first long connection according to the first identifier, and synchronously pushing any theme message to the first client through the first long connection; and determining a second long connection according to the second identifier, and synchronously pushing any theme message to the second client through the second long connection.
In one embodiment, the method further includes: creating a storage container of the key value pair, recording a message theme by using keys of the storage container, and recording a first identifier of a first client and a second identifier of a second client by using values corresponding to the keys; determining a first long connection according to the first identifier, synchronously pushing any theme message to the first client through the first long connection, determining a second long connection according to the second identifier, and synchronously pushing any theme message to the second client through the second long connection, wherein the steps of: when any topic message related to the message topic is subscribed from the message middleware, a target key of a storage container is determined according to the message topic, a corresponding value is determined according to the target key, a first identifier and a second identifier are determined according to the corresponding value, a first long connection is determined according to the first identifier, any topic message is synchronously pushed to a first client through the first long connection, a second long connection is determined according to the second identifier, and any topic message is synchronously pushed to a second client through the second long connection.
An information synchronization system, the system includes a message management distribution cluster and message middleware; the message management distribution cluster comprises a plurality of servers, wherein any server is used for receiving messages and message themes sent by a client, publishing the messages and the message themes to a message middleware, subscribing theme messages related to the message themes in the message middleware, and synchronously pushing any theme message to the client when any theme message related to the message themes is subscribed from the message middleware; the message middleware is used for receiving the topic messages published by any server in the message management distribution cluster and receiving the subscription of the message topics of any server in the message management distribution cluster.
In one embodiment, a plurality of servers in the message management distribution cluster are in distributed connection, each server is deployed by adopting a spring boot micro-service structure, and the message middleware is a distributed message cache center.
In one embodiment, a storage container of key value pairs is arranged in any server, keys of the storage container are used for recording message themes received by any server, values corresponding to the keys of the storage container are used for recording identifications of clients sending micro service requests of the message themes to any server, and any server identifies long connection of the clients through the identifications of the clients and sends any theme message of the message themes to the clients through the long connection.
An information synchronization apparatus, the apparatus comprising: the receiving module is used for receiving the message and the message theme sent by the client and publishing the message and the message theme to the message middleware so that any server subscribes the message and the message theme from the message middleware; the subscription module is used for subscribing topic messages related to message topics in the message middleware, and the message middleware is used for receiving topic messages published by any server; and the synchronization module is used for synchronously pushing any topic message to the client when any topic message associated with the message topic is subscribed from the message middleware.
A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the method of any of the above embodiments when executing the computer program.
A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method of any of the above embodiments.
According to the information synchronization method, the information synchronization system, the information synchronization device, the computer equipment and the storage medium, the server receives the message and the message theme sent by the client, and publishes the message and the message theme to the message middleware, so that any server subscribes the message and the message theme from the message middleware; and simultaneously, subscribing the topic messages associated with the message topics in the message middleware, wherein the message middleware is used for receiving the topic messages published by any server. When any topic message associated with the message topic is subscribed from the message middleware, any topic message is synchronously pushed to the client. Therefore, the server realizes the publishing of the message theme of the client and the subscription of the related theme message of the message theme through the message middleware, the synchronization of the information of the message theme can be realized without using a single server to realize the forwarding of the theme message of the same message theme, and the capacity of the server can be quickly expanded under the condition that a plurality of clients are controlled to be connected to different servers when a plurality of message themes are maintained. Meanwhile, synchronous forwarding of information does not need to be achieved in the same server, and real-time synchronization of the information can be achieved without limitation of IO (input/output) and cpu (central processing unit) memories and the like of the server in the information synchronization process.
Drawings
FIG. 1 is a diagram of information interaction for information synchronization of a plurality of conventional clients;
FIG. 2 is a diagram illustrating an exemplary architecture of an information synchronization system;
FIG. 3 is a flow chart illustrating a method for synchronizing information according to an embodiment;
FIG. 4 is a diagram of information interactions between a client and one or more servers in one embodiment;
FIG. 5 is a diagram illustrating an exemplary structure of a map container in a server;
FIG. 6 is a diagram of a display interface for a plurality of people editing an online document, in one embodiment;
FIG. 7 is a diagram illustrating the structure of map mapping preservation in a server in one embodiment;
FIG. 8 is an interaction diagram illustrating a server subscribing to a topic message of a document editing message topic from a distributed memory message center in one embodiment;
FIG. 9 is a diagram of a model for implementing the information synchronization method employed in one embodiment;
FIG. 10 is a diagram showing a display interface when a plurality of persons edit an online document in another embodiment;
FIG. 11 is a block diagram of an information synchronization apparatus according to an embodiment;
FIG. 12 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The application provides an information synchronization system. The information synchronization system is used for realizing the information synchronization method. Specifically, as shown in FIG. 2, the information synchronization system includes a message management distribution cluster 102 and message middleware 202. The message management distribution cluster 102 includes a plurality of servers. The servers are in distributed connection, and each server is deployed by adopting a spring boot micro-service structure. That is, the message management distribution cluster 102 is deployed using a microservice architecture. The plurality of clients issue messages to the message management distribution cluster 102, and the message management distribution cluster 102 synchronizes the messages to the plurality of clients, respectively. Specifically, the message management distribution cluster 102 includes a plurality of servers, and any server is configured to receive a message and a message topic sent by any client, publish the message and the message topic to the message middleware 202, and subscribe a topic message associated with the message topic in the message middleware 202. When any topic message associated with the message topic is subscribed from the message middleware 202, any topic message is synchronously pushed to the corresponding client. The message middleware 202 is configured to receive a topic message published by any server in the message management distribution cluster 102, and receive a subscription of a message topic of any server in the message management distribution cluster 102. The message middleware 202 may include a plurality of databases, and the plurality of databases constitute a distributed message cache center. In particular, message middleware 202 may be a distributed message caching hub comprised of redis clusters.
In an embodiment, a storage container of a key value pair is disposed in any server in the message management distribution cluster 102, a key of the storage container is used to record a message topic received by any server, and a value corresponding to the key of the storage container is used to record an identifier of a client that sends a microservice request of the message topic to any server. And any server identifies the long connection of the client through the identification of the client and sends any theme message of the message theme to the client through the long connection.
Specifically, a map container is set in any server in the message management distribution cluster 102. A long connection message pushing mechanism is integrated in any server, and the long connection message pushing mechanism comprises a websocket function. Any server adopts a websocket to establish long connection with a client, and adopts the websocket to receive messages and message subjects sent by the client and synchronize the subject messages to the client. And any server records the identification of one or more clients corresponding to each message topic by adopting a map container so as to identify the corresponding client, and receives and sends any topic message of the message topic to the client through the long connection corresponding to the client.
Therefore, the information caching, the information subscription and the information publishing are carried out by adopting the message middleware, so that the real-time information synchronization is realized. Meanwhile, the client does not need to be connected with the same appointed back-end server through a special algorithm to synchronously push the theme message of the message theme, so that the back-end server can be continuously expanded, and the requirement of simultaneously connecting a large number of clients is met. Moreover, a single server does not need to be continuously maintained, and the servers in the corresponding message management distribution cluster 102 can be correspondingly expanded only by estimating the number of the clients, so that the supporting capability of information synchronization is greatly improved.
In an embodiment, as shown in fig. 3, the present application provides an information synchronization method, which is described by taking the method as an example applied to the message management distribution cluster 102 in fig. 2, and includes the following steps:
s102, receiving the message and the message theme sent by the client, and publishing the message and the message theme to the message middleware, so that any server subscribes the message and the message theme from the message middleware.
In this embodiment, the message management distribution cluster 102 deploys a plurality of service machines in the form of micro-services, and implements, through codes, a topic message subscribing to a message topic from the message middleware and a message topic and a message sent by a publishing client. The client establishes a long connection with the server of the back-end message management distribution cluster 102 through the long connection, and carries the concerned message topic. Specifically, each client may establish a long connection with multiple servers in the message management distribution cluster 102 through a polling distribution manner, as shown in fig. 4. Here, micro service 1 and micro service 2 refer to two different servers in the message management distribution cluster 102, respectively. And the connection relation between each server and the client is maintained in a connection maintenance mode according to a message theme. Each server maintains all the connections established between the server and the client, and is responsible for receiving all the messages of the client and distributing and synchronizing the messages sent by other clients.
In this embodiment, any server in the message management distribution cluster 102 receives a message and a message topic sent by a client, and synchronously publishes the message and the message topic to the message middleware. The message middleware is configured to receive a message topic published by any server in the message management distribution cluster 102 and a topic message associated with the message topic published by any server. The message middleware is also used for accepting information subscription of any server in the message management distribution cluster 102. When any server publishes the message topic to the message middleware, other servers can synchronously subscribe to topic messages related to the message topic from the message middleware in a subscription mode. Thus, information synchronization of message topics is achieved.
And S104, subscribing the theme message associated with the message theme in the message middleware, wherein the message middleware is used for receiving the theme message published by any server.
In this embodiment, any server may not only publish the message and the message topic to the message middleware, but also synchronously acquire any topic message published by another server in a manner of subscribing to the topic message of the message topic from the message middleware. The theme message associated with the message theme comprises data information obtained by any operation of other servers on the message theme. And the other servers publish the theme messages to the message middleware, and any server reads the theme messages from the message middleware in a mode of subscribing the theme messages related to the message themes in the message middleware.
For example, the message topic may be an online document a, and the topic message associated with the message topic may be any operation information of any client within the online document a. Such as data information filled in the online document a, and data modification information for the online document a. Thus, information synchronization of message topics can be achieved.
S106, when any topic message related to the message topic is subscribed from the message middleware, any topic message is synchronously pushed to the client.
In this embodiment, when any server subscribes to any topic message associated with a message topic from the message middleware, any topic message is synchronized to the corresponding client. Specifically, any server establishes a websocket connection with the client, receives a message topic sent by the client through the websocket connection, and synchronously pushes any topic message to the client through the websocket connection. Thus, synchronization of information is achieved.
In the information synchronization method, the server receives the message theme sent by the client, and publishes the message theme to the message middleware so that any server subscribes the message theme from the message middleware; and simultaneously, subscribing the topic messages associated with the message topics in the message middleware, wherein the message middleware is used for receiving the topic messages published by any server. When any topic message associated with the message topic is subscribed from the message middleware, any topic message is synchronously pushed to the client. Therefore, the server realizes the publishing of the message theme of the client and the subscription of the related theme message of the message theme through the message middleware, the synchronization of the information of the message theme can be realized without using a single server to realize the forwarding of the theme message of the same message theme, and the capacity of the server can be quickly expanded under the condition that a plurality of clients are controlled to be connected to different servers when a plurality of message themes are maintained. Meanwhile, synchronous forwarding of information does not need to be achieved in the same server, and real-time synchronization of the information can be achieved without limitation of IO (input/output) and cpu (central processing unit) memories and the like of the server in the information synchronization process.
In an embodiment, before S102, the method further includes: establishing long connection with a client to generate a client identifier of the client; the long connection is associated with a client identification. S102 includes: and receiving the message and the message subject sent by the client through the long connection. S106 includes: and determining long connection according to the client identification, and synchronously pushing any theme message to the client through the long connection.
In this embodiment, the server establishes a communication with the client over the long connection and associates the long connection with the client. A long connection maintains a message topic for the client. When the server subscribes to any topic message of the message topic, the client corresponding to the subscribed message topic is determined, the corresponding long connection is further determined according to the client identification, and any topic message is synchronously pushed to the client through the long connection. Thus, synchronization of the subject message of the message subject can be achieved. Specifically, between the client and the server, a websocket is used as a message push mechanism for long connections. The client integrates the websocket function, and the server also realizes the message receiving function of the websocket.
In one embodiment, the number of the clients is multiple, and the multiple clients include a first client and a second client. Establishing a long connection with a client, generating a client identifier of the client, and associating the long connection with the client identifier, wherein the method comprises the following steps: establishing a first long connection with a first client and a second long connection with a second client; generating a first identification of a first client and a second identification of a second client; the first long connection is associated with a first identity and the second long connection is associated with a second identity. Receiving messages and message themes sent by a client through a long connection, comprising: and receiving the message and the message theme sent by the first client through the first long connection, and receiving the message and the message theme sent by the second client through the second long connection. Determining long connection according to the client identification, and synchronously pushing any theme message to the client through the long connection, wherein the method comprises the following steps: determining a first long connection according to the first identifier, and synchronously pushing any theme message to the first client through the first long connection; and determining a second long connection according to the second identifier, and synchronously pushing any theme message to the second client through the second long connection.
In this embodiment, the server may receive messages and message topics sent by a plurality of clients, and send the messages and the message topics to the message middleware, so that other servers subscribe to topic messages of the message topics from the message middleware. At this time, the server needs to maintain the subject message of the message subject sent by the plurality of clients. Specifically, the server establishes long connections with a first client and a second client, respectively, the first long connection is associated with the first client, and the second client is associated with the second long connection. The association may be performed by generating an identifier of each client and establishing association between the identifier and the long connection. When the server receives the message and the message theme sent by the first client through the first long connection, the relation between the message theme and the first long connection is recorded. And when the server receives the message theme sent by the second client through the second long connection, recording the message and the relation between the message theme and the second long connection. When the server subscribes to any topic message associated with the message topic from the message middleware, searching a client associated with the message topic in the local server and a long connection corresponding to the client, and sending any topic message to the corresponding client through the corresponding long connection. Therefore, the servers can be connected with the plurality of clients in a balanced mode, each server can process a certain amount of connection and message pushing work, the servers can make full use of internal resources of IO (input/output), cpu (central processing unit) and a memory in the local server, and efficient information pushing is achieved.
In an embodiment, before S106, the method further includes: and creating a storage container of the key value pair, recording the message theme by adopting the keys of the storage container, and recording the first identifier of the first client and the second identifier of the second client by adopting the values corresponding to the keys. Determining a first long connection according to the first identifier, synchronously pushing any theme message to the first client through the first long connection, determining a second long connection according to the second identifier, and synchronously pushing any theme message to the second client through the second long connection, wherein the steps of: when any topic message related to the message topic is subscribed from the message middleware, a target key of a storage container is determined according to the message topic, a corresponding value is determined according to the target key, a first identifier and a second identifier are determined according to the corresponding value, a first long connection is determined according to the first identifier, any topic message is synchronously pushed to a first client through the first long connection, a second long connection is determined according to the second identifier, and any topic message is synchronously pushed to a second client through the second long connection.
In this embodiment, the storage container for key-value pairs may be a map container. As shown in FIG. 5, key in the map container represents a key and value represents a value. key-value pair wise associations. And recording the message theme by adopting a key, and recording the client identification corresponding to the message theme by the value corresponding to the key. When a topic message of a message topic is subscribed, the server searches an internal map container to determine a client corresponding to the message topic, and then pushes the subscribed topic message to the client. Specifically, the server generates a unique client identifier for each client, and the server maintains a long connection associated with the client identifier. And mapping the identifier of the client and the message topic and then storing the mapped identifier and the mapped message topic in a local map, wherein key is the id of the message topic concerned by the client, and value is a connection list corresponding to the client. When the client side obtains the latest message, namely the topic message subscribed to the message topic, the client side connected with the message topic is obtained by searching the map container through the message topic id, and the topic message is pushed to the client side through the long connection of each client side.
For example, the map containers within server 1 and server 2 each hold identification information for each client with which a long connection is established. The existing 2 servers are assumed to be capable of supporting 1000 client connections, the message middleware adopts a redis cluster, the read and write of the redis cluster can meet the requirement, and the QPS is assumed to be 1 w/s. When the number of client connections is increased to 10000, the number of servers can be linearly increased to 20, and 1 redis server can also meet the requirement as a redis cluster. Similarly, when the number of the clients is increased to 1000000, the number of the servers can be linearly increased to 2000, assuming that the write request is 100000/s, and the synchronization information to be pushed is 1000000, the redis cluster is expanded to 10 master servers and 100 slave servers, the message is hashed, modulo and uniformly distributed to the redis cluster, and the server is 2000 at this time, subscribes the redis cluster synchronization message, and can meet the real-time requirement. Therefore, a single server does not need to be maintained continuously, the server and the message middleware can be correspondingly expanded only by estimating the number of the clients, and the information synchronization supporting capability is greatly improved.
For the information synchronization method and the information synchronization system for implementing the method, a specific implementation scenario is provided as follows:
specifically, multi-person editing using an online document is a specific application of the present application, as shown in fig. 6.
There are currently 2 clients that collectively edit the "New Excel document" file. User a as client a (clienta), user B as client B (clientb. clienta edits document cell D1, and sends the edited data to the message management distribution cluster, hereinafter collectively referred to as "message format 1" of data sent by client as follows:
Figure BDA0002710103770000111
whenever a new client comes online, the client establishes a websocket long connection with the DCMMC. The DCMMC allocates a client identity (client id). DCMMC is responsible for managing the long connection of each client, and saves the client connection for editing the same document by using map mapping, and the structure is shown in FIG. 7.
It should be noted that each server in the DCMMC has a separate map container to manage the connection structure.
Every time a server is added in the DCMMC, the information of the message subject is subscribed with the message middleware. The message middleware can adopt a distributed memory message center realized by redis, and the server subscribes a theme message of a document editing message theme to the distributed memory message center. For example, as shown in fig. 8. Suppose that server a (server a) receives a message (message1) sent by client a (client a). server a publishes the message1 to the redis channel through the subscribed message topic. At this time, each server in the DCMMC receives the message1 issued by server a. And other servers find the corresponding connection websocket of the client B according to the docId of the message subject and the connection management mapping map container maintained by the server, and push the message1 to the client B.
The DCMMC adopts redis as implementation, and realizes high-performance message pushing to 1-n clients by means of a memory, and a model is shown in fig. 9. Finally, the client B receives the pushed message1, which is displayed in the cell, as shown in fig. 10.
According to the information synchronization method and the information synchronization system, high-performance multi-terminal information synchronization without upper limit of the client side is achieved, low information delay is achieved through distributed memory caching, the client side without upper limit expansion is achieved through message publishing and subscribing, the information synchronization without blocking of the front end and the back end is achieved through a full-duplex communication protocol, and each client side can participate in information synchronization of a plurality of message topics at the same time.
It should be understood that, although the steps in the flowchart are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in the figures may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performance of the sub-steps or stages is not necessarily sequential, but may be performed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.
The present application also provides an information synchronization apparatus, as shown in fig. 11, the apparatus includes a receiving module 10, a subscription module 20, and a synchronization module 30. A receiving module 10, configured to receive a message and a message topic sent by a client, and publish the message and the message topic to a message middleware, so that any server subscribes to the message and the message topic from the message middleware; a subscription module 20, configured to subscribe to a topic message associated with a message topic in a message middleware, where the message middleware is configured to receive a topic message published by any server; and the synchronization module 30 is used for synchronously pushing any topic message to the client when any topic message associated with the message topic is subscribed from the message middleware.
In one embodiment, the information synchronization apparatus further includes an association module, configured to establish a long connection with a client, and generate a client identifier of the client; the long connection is associated with a client identification. The receiving module 10 is specifically configured to receive a message and a message topic sent by a client through a long connection. The synchronization module 30 is specifically configured to determine a long connection according to the client identifier, and synchronously push any theme message to the client through the long connection.
In one embodiment, the number of the clients is multiple, and the multiple clients comprise a first client and a second client; the association module is specifically used for establishing a first long connection with a first client and establishing a second long connection with a second client; generating a first identification of a first client and a second identification of a second client; associating the first long connection with a first identifier and the second long connection with a second identifier; the receiving module 10 is specifically configured to receive, through a first long connection, a message and a message theme sent by a first client, and receive, through a second long connection, a message and a message theme sent by a second client; the synchronization module 30 is specifically configured to determine a first long connection according to the first identifier, and synchronously push any theme message to the first client through the first long connection; and determining a second long connection according to the second identifier, and synchronously pushing any theme message to the second client through the second long connection.
In one embodiment, an information synchronization apparatus further includes a creating module, configured to create a storage container of key-value pairs, record a message topic with a key of the storage container, and record a first identifier of a first client and a second identifier of a second client with a value corresponding to the key; the synchronization module 30 is specifically configured to, when any topic message associated with a message topic is subscribed from the message middleware, determine a target key of the storage container according to the message topic, determine a corresponding value according to the target key, determine a first identifier and a second identifier according to the corresponding value, determine a first long connection according to the first identifier, synchronously push any topic message to the first client through the first long connection, determine a second long connection according to the second identifier, and synchronously push any topic message to the second client through the second long connection.
For specific limitations of the information synchronization apparatus, reference may be made to the above limitations of the information synchronization method, which are not described herein again. The modules in the information synchronization device can be wholly or partially realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as shown in fig. 12. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used for connecting with an external terminal so as to receive a message theme sent by a client of the terminal and a theme message related to the message theme. The computer program is executed by a processor to implement an information synchronization method.
Those skilled in the art will appreciate that the architecture shown in fig. 12 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program: receiving a message and a message theme sent by a client, and publishing the message and the message theme to a message middleware so that any server subscribes the message and the message theme from the message middleware; subscribing the topic message associated with the message topic in the message middleware, wherein the message middleware is used for receiving the topic message published by any server; when any topic message associated with the message topic is subscribed from the message middleware, any topic message is synchronously pushed to the client.
In one embodiment, the processor, when executing the computer program, performs the following steps: establishing long connection with a client to generate a client identifier of the client; associating the long connection with the client identity; when the processor executes the computer program to realize the steps of receiving the message and the message theme sent by the client, the following steps are specifically realized: and receiving the message and the message subject sent by the client through the long connection. When the processor executes the computer program to realize the step of synchronously pushing any theme message to the client, the following steps are specifically realized: and determining long connection according to the client identification, and synchronously pushing any theme message to the client through the long connection.
In one embodiment, the number of the clients is multiple, and the multiple clients comprise a first client and a second client; the processor executes the computer program to realize the steps of establishing the long connection with the client, generating the client identifier of the client, and associating the long connection with the client identifier, and specifically realizing the following steps: establishing a first long connection with a first client and a second long connection with a second client; generating a first identification of a first client and a second identification of a second client; the first long connection is associated with a first identity and the second long connection is associated with a second identity. When the processor executes the computer program to realize the steps of receiving the message and the message theme sent by the client through the long connection, the following steps are specifically realized: receiving a message and a message theme sent by a first client through a first long connection, and receiving a message and a message theme sent by a second client through a second long connection; when the processor executes the computer program to realize the steps of determining the long connection according to the client identification and synchronously pushing any theme message to the client through the long connection, the following steps are specifically realized: determining a first long connection according to the first identifier, and synchronously pushing any theme message to the first client through the first long connection; and determining a second long connection according to the second identifier, and synchronously pushing any theme message to the second client through the second long connection.
In one embodiment, the processor, when executing the computer program, performs the following steps: creating a storage container of the key value pair, recording a message theme by using keys of the storage container, and recording a first identifier of a first client and a second identifier of a second client by using values corresponding to the keys; the processor executes the computer program to realize the steps of determining the first long connection according to the first identifier, synchronously pushing any theme message to the first client through the first long connection, determining the second long connection according to the second identifier, and synchronously pushing any theme message to the second client through the second long connection, and specifically realizing the following steps: when any topic message related to the message topic is subscribed from the message middleware, a target key of a storage container is determined according to the message topic, a corresponding value is determined according to the target key, a first identifier and a second identifier are determined according to the corresponding value, a first long connection is determined according to the first identifier, any topic message is synchronously pushed to a first client through the first long connection, a second long connection is determined according to the second identifier, and any topic message is synchronously pushed to a second client through the second long connection.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of: receiving a message theme sent by a client, and publishing the message theme to message middleware so that any server subscribes the message theme from the message middleware; subscribing the topic message associated with the message topic in the message middleware, wherein the message middleware is used for receiving the topic message published by any server; when any topic message associated with the message topic is subscribed from the message middleware, any topic message is synchronously pushed to the client.
In one embodiment, the computer program when executed by the processor performs the steps of: establishing long connection with a client to generate a client identifier of the client; associating the long connection with the client identity; when the computer program is executed by the processor to realize the message theme step sent by the receiving client, the following steps are specifically realized: and receiving the message theme sent by the client through the long connection. When the computer program is executed by the processor to realize the step of synchronously pushing any theme message to the client, the following steps are specifically realized: and determining long connection according to the client identification, and synchronously pushing any theme message to the client through the long connection.
In one embodiment, the number of the clients is multiple, and the multiple clients comprise a first client and a second client; the computer program is executed by the processor to realize the steps of establishing the long connection with the client, generating the client identifier of the client, and associating the long connection with the client identifier, and specifically realizing the following steps: establishing a first long connection with a first client and a second long connection with a second client; generating a first identification of a first client and a second identification of a second client; the first long connection is associated with a first identity and the second long connection is associated with a second identity. When the computer program is executed by the processor to realize the step of receiving the message theme sent by the client through the long connection, the following steps are specifically realized: receiving a message theme sent by a first client through a first long connection, and receiving a message theme sent by a second client through a second long connection; when the computer program is executed by the processor to realize the steps of determining the long connection according to the client identification and synchronously pushing any theme message to the client through the long connection, the following steps are specifically realized: determining a first long connection according to the first identifier, and synchronously pushing any theme message to the first client through the first long connection; and determining a second long connection according to the second identifier, and synchronously pushing any theme message to the second client through the second long connection.
In one embodiment, the computer program when executed by the processor performs the steps of: creating a storage container of the key value pair, recording a message theme by using keys of the storage container, and recording a first identifier of a first client and a second identifier of a second client by using values corresponding to the keys; when the computer program is executed by the processor to implement the steps of determining the first long connection according to the first identifier, synchronously pushing any theme message to the first client through the first long connection, determining the second long connection according to the second identifier, and synchronously pushing any theme message to the second client through the second long connection, the following steps are specifically implemented: when any topic message related to the message topic is subscribed from the message middleware, a target key of a storage container is determined according to the message topic, a corresponding value is determined according to the target key, a first identifier and a second identifier are determined according to the corresponding value, a first long connection is determined according to the first identifier, any topic message is synchronously pushed to a first client through the first long connection, a second long connection is determined according to the second identifier, and any topic message is synchronously pushed to a second client through the second long connection.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A method of information synchronization, the method comprising:
receiving a message and a message theme sent by a client, publishing the message and the message theme to message middleware, so that any server subscribes the message and the message theme from the message middleware;
subscribing to a topic message associated with the message topic in the message middleware, wherein the message middleware is used for receiving the topic message published by any server;
and when any topic message associated with the message topic is subscribed from the message middleware, synchronously pushing any topic message to the client.
2. The method of claim 1, further comprising:
establishing long connection with the client to generate a client identifier of the client;
associating the long connection with the client identification;
the receiving of the message and the message theme sent by the client includes: receiving the message and the message subject sent by the client through the long connection;
the synchronously pushing any theme message to the client comprises:
and determining the long connection according to the client identification, and synchronously pushing any theme message to the client through the long connection.
3. The method of claim 2, wherein the client is a plurality of clients, the plurality of clients comprising a first client and a second client;
the establishing of the long connection with the client, the generating of the client identification of the client, and the associating of the long connection with the client identification comprise:
establishing a first long connection with the first client and establishing a second long connection with the second client;
generating a first identification of the first client and a second identification of the second client;
associating the first long connection with the first identity and the second long connection with the second identity;
the receiving the message and the message subject sent by the client through the long connection comprises:
receiving the message and the message theme sent by the first client through the first long connection, and receiving the message and the message theme sent by the second client through the second long connection;
the determining the long connection according to the client identifier, and synchronously pushing any theme message to the client through the long connection includes:
determining the first long connection according to the first identifier, and synchronously pushing any theme message to the first client through the first long connection;
and determining the second long connection according to the second identifier, and synchronously pushing any theme message to the second client through the second long connection.
4. The method of claim 3, further comprising:
creating a storage container of key value pairs, recording the message theme by using keys of the storage container, and recording a first identifier of the first client and a second identifier of the second client by using values corresponding to the keys;
the determining the first long connection according to the first identifier, synchronously pushing any one theme message to the first client through the first long connection, determining the second long connection according to the second identifier, and synchronously pushing any one theme message to the second client through the second long connection includes:
when any topic message related to the message topic is subscribed from the message middleware, a target key of the storage container is determined according to the message topic, a corresponding value is determined according to the target key, the first identifier and the second identifier are determined according to the corresponding value, the first long connection is determined according to the first identifier, the any topic message is synchronously pushed to the first client through the first long connection, the second long connection is determined according to the second identifier, and the any topic message is synchronously pushed to the second client through the second long connection.
5. An information synchronization system, characterized in that the system comprises a message management distribution cluster and a message middleware;
the message management and distribution cluster comprises a plurality of servers, wherein any server is used for receiving messages and message themes sent by clients, publishing the messages and the message themes to the message middleware, subscribing theme messages related to the message themes in the message middleware, and synchronously pushing any theme message to the clients when any theme message related to the message themes is subscribed from the message middleware;
the message middleware is used for receiving the topic message published by any server in the message management distribution cluster and receiving the subscription of the message topic of any server in the message management distribution cluster.
6. The system of claim 5, wherein the plurality of servers in the message management distribution cluster are connected in a distributed manner, each server is deployed in a spring boot micro-service structure, and the message middleware is a distributed message cache center.
7. The system according to claim 5, wherein a storage container with key value pairs is arranged in any server, keys of the storage container are used for recording message topics received by any server, values corresponding to the keys of the storage container are used for recording identifications of clients sending microservice requests of the message topics to any server, and any server identifies long connections of the clients through the identifications of the clients and sends any topic messages of the message topics to the clients through the long connections.
8. An information synchronization apparatus, characterized in that the apparatus comprises:
the receiving module is used for receiving the message and the message theme sent by the client and publishing the message and the message theme to the message middleware so that any server subscribes the message and the message theme from the message middleware;
a subscription module, configured to subscribe to a topic message associated with the message topic in the message middleware, where the message middleware is configured to receive the topic message published by any server;
and the synchronization module is used for synchronously pushing any topic message to the client when any topic message associated with the message topic is subscribed from the message middleware.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the steps of the method of any of claims 1 to 4 are implemented when the computer program is executed by the processor.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 4.
CN202011052983.5A 2020-09-29 2020-09-29 Information synchronization method, system, device, computer equipment and storage medium Pending CN112351068A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202011052983.5A CN112351068A (en) 2020-09-29 2020-09-29 Information synchronization method, system, device, computer equipment and storage medium
CA3131954A CA3131954C (en) 2020-09-29 2021-09-27 Information synchronization method, system, apparatus, computer device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011052983.5A CN112351068A (en) 2020-09-29 2020-09-29 Information synchronization method, system, device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112351068A true CN112351068A (en) 2021-02-09

Family

ID=74361334

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011052983.5A Pending CN112351068A (en) 2020-09-29 2020-09-29 Information synchronization method, system, device, computer equipment and storage medium

Country Status (2)

Country Link
CN (1) CN112351068A (en)
CA (1) CA3131954C (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112882987A (en) * 2021-03-12 2021-06-01 北京小米移动软件有限公司 Multi-core communication method and device, electronic equipment and storage medium
CN113938497A (en) * 2021-12-17 2022-01-14 中证信用增进股份有限公司 Data synchronization method, device and system based on message middleware
CN114422569A (en) * 2021-12-30 2022-04-29 天翼云科技有限公司 Message pushing method and device of cloud desktop
CN114827171A (en) * 2022-03-23 2022-07-29 青岛中科曙光科技服务有限公司 Information synchronization method and device, computer equipment and storage medium

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115002213A (en) * 2022-06-01 2022-09-02 上海嘉车信息科技有限公司 Data transmission method and framework

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104811459A (en) * 2014-01-23 2015-07-29 阿里巴巴集团控股有限公司 Processing method, processing device and system for message services and message service system
CN111131501A (en) * 2019-12-31 2020-05-08 郑州信大捷安信息技术股份有限公司 MQTT protocol-based message pushing system and method

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104811459A (en) * 2014-01-23 2015-07-29 阿里巴巴集团控股有限公司 Processing method, processing device and system for message services and message service system
CN111131501A (en) * 2019-12-31 2020-05-08 郑州信大捷安信息技术股份有限公司 MQTT protocol-based message pushing system and method

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112882987A (en) * 2021-03-12 2021-06-01 北京小米移动软件有限公司 Multi-core communication method and device, electronic equipment and storage medium
CN113938497A (en) * 2021-12-17 2022-01-14 中证信用增进股份有限公司 Data synchronization method, device and system based on message middleware
CN114422569A (en) * 2021-12-30 2022-04-29 天翼云科技有限公司 Message pushing method and device of cloud desktop
CN114827171A (en) * 2022-03-23 2022-07-29 青岛中科曙光科技服务有限公司 Information synchronization method and device, computer equipment and storage medium
CN114827171B (en) * 2022-03-23 2023-12-15 青岛中科曙光科技服务有限公司 Information synchronization method, apparatus, computer device and storage medium

Also Published As

Publication number Publication date
CA3131954C (en) 2023-11-07
CA3131954A1 (en) 2022-03-29

Similar Documents

Publication Publication Date Title
CN112351068A (en) Information synchronization method, system, device, computer equipment and storage medium
US10719260B2 (en) Techniques for storing and retrieving data from a computing device
CN108011929B (en) Data request processing method and device, computer equipment and storage medium
EP1330907B1 (en) Method and apparatus for real-time parallel delivery of segments of a large payload file
KR20210002574A (en) Data backup methods, storage media and computing devices
US10579595B2 (en) Method and device for calling a distributed file system
KR101150146B1 (en) System and method for managing cached objects using notification bonds
CN112199419B (en) Distributed time sequence database, storage method, equipment and storage medium
EP2434758A1 (en) Distributed node video monitoring system and management method thereof
CN108829720B (en) Data processing method and device
CN110196843B (en) File distribution method based on container cluster and container cluster
WO2016095149A1 (en) Data compression and storage method and device, and distributed file system
US20020156931A1 (en) Remote file system using network multicast
CN111641700B (en) Ceph object-based management and retrieval implementation method for storage metadata
CN103997525A (en) Distributed data synchronization method and system
CN111522874A (en) Block chain consensus method, block chain consensus device, computer equipment and storage medium
CN110740155A (en) Request processing method and device in distributed system
CN111193789A (en) Subscription information pushing method and device, computer equipment and readable storage medium
CN114401261A (en) File downloading method and device
CN107168642B (en) Data storage method and system
CN117714532A (en) Data information pushing method based on Timeline model, gateway and related equipment
CN112532763A (en) Container operation data synchronization method and device
CN112733051A (en) Websocket-based information push management system and method
CN114827171B (en) Information synchronization method, apparatus, computer device and storage medium
CN114138895A (en) Data synchronization method and device for multiple data sources, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20210209