CN109831372B - Message synchronization method and instant messaging system - Google Patents

Message synchronization method and instant messaging system Download PDF

Info

Publication number
CN109831372B
CN109831372B CN201910111809.4A CN201910111809A CN109831372B CN 109831372 B CN109831372 B CN 109831372B CN 201910111809 A CN201910111809 A CN 201910111809A CN 109831372 B CN109831372 B CN 109831372B
Authority
CN
China
Prior art keywords
data center
synchronization
message
timestamp
center agent
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910111809.4A
Other languages
Chinese (zh)
Other versions
CN109831372A (en
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.)
Beijing Yunzhong Rongxin Network Technology Co ltd
Original Assignee
Beijing Yunzhong Rongxin Network Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Yunzhong Rongxin Network Technology Co ltd filed Critical Beijing Yunzhong Rongxin Network Technology Co ltd
Priority to CN201910111809.4A priority Critical patent/CN109831372B/en
Publication of CN109831372A publication Critical patent/CN109831372A/en
Application granted granted Critical
Publication of CN109831372B publication Critical patent/CN109831372B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The application provides a message synchronization method and an instant messaging system, wherein corresponding data center agents are configured for data centers, message synchronization among the data centers is completed by the data center agents, communication messages are not transmitted among the data centers, so that each data center does not need to maintain information of other data centers, and the information of other data centers can be maintained by the data center agents. Therefore, the message processing flow in the instant communication system is simplified, the data center agents are configured with corresponding timestamps for the communication messages, and when the data center agents determine that the messages need to be synchronized, the messages are transmitted among the data center agents, so that the delivered messages can be ensured not to be lost, disordered and repeated, and the message transmission efficiency is improved.

Description

Message synchronization method and instant messaging system
Technical Field
The invention relates to the technical field of instant messaging, in particular to a message synchronization method and an instant messaging system.
Background
The instant messaging server can be deployed in a micro-service architecture, and can be divided into various service modules such as single chat, group chat and session, and message transmission is performed between the modules in an RPC (Remote Procedure Call) mode. When the server is deployed in a multi-data center mode, each data center respectively comprises the service module, and the terminal users respectively access different data centers according to regions and routing load strategies. This creates a problem of message delivery from user to user, module to module, and across data centers if messages are sent to each other. The data center needs to maintain the relevant information of each service module of other data centers, and in the face of more data centers in a data center cluster, each service module in one data center needs to maintain a large amount of relevant information of the service modules in other data centers, so that the information maintenance workload is huge, and the message delivery process is very complicated.
Disclosure of Invention
In view of this, the present invention provides a message synchronization method and an instant messaging system, which can achieve more efficient message delivery.
The technical scheme provided by the invention is as follows:
a message synchronization method is applied to an instant messaging system, the instant messaging system comprises a first data center, a second data center, a first data center agent and a second data center agent, the first data center agent is used for providing instant messaging service for a user terminal, the first data center agent corresponds to the first data center, the second data center agent corresponds to the second data center, and the method comprises the following steps:
the first data center agent sends a message synchronization notification to the second data center agent every other preset period, wherein the message synchronization notification comprises a first synchronization timestamp;
the second data center agent determines whether message synchronization is needed according to the first synchronization timestamp, and if the message synchronization is needed, the second data center agent sends a synchronization request message carrying a second synchronization timestamp to the first data center agent;
the first data center agent sends the message to be synchronized to the second data center agent according to the second synchronization time stamp in the synchronization request message;
and the second data center agent sends the message to be synchronized to the second data center for message synchronization.
Further, the first synchronization timestamp is a timestamp of a latest piece of information received by the first data center agent, and the step of determining whether message synchronization is required by the second data center agent according to the first synchronization timestamp includes:
the second data center agent judges whether the first synchronization timestamp is later than a second synchronization timestamp stored locally, wherein the second synchronization timestamp is the latest timestamp of the communication message sent by the first data center agent and received by the second data center agent last time;
if the first synchronization timestamp is later than the second synchronization timestamp, determining that message synchronization is required;
if the first synchronization timestamp is earlier than the second synchronization timestamp or the first synchronization timestamp is the same as the second synchronization timestamp, it is determined that message synchronization is not required.
Further, the sending, by the first data center agent, the message to be synchronized to the second data center agent according to the second synchronization timestamp in the synchronization request message includes:
and the first data center agent takes the message with the timestamp later than the second synchronization timestamp in the received messages as the message to be synchronized, and sends the message to be synchronized to the second data center agent.
Further, after the first data center agent sends the message to be synchronized to the second data center agent according to the second synchronization timestamp in the synchronization request message, the method further includes:
the second data center agent updates the second synchronization timestamp stored locally using the timestamp of the received latest message.
Further, before the first data center agent sends the message synchronization notification to the second data center agent every preset period, the method further includes:
and the first data center agent receives the messages of the first data center, persists the messages to the local and stores the messages in order according to the time stamp.
The application also provides an instant messaging system, the instant messaging system comprises a first data center, a second data center, a first data center agent and a second data center agent, the first data center agent is used for providing instant messaging service for the user terminal, the first data center agent corresponds to the first data center, the second data center agent corresponds to the second data center, wherein:
the first data center agent is used for sending a message synchronization notification to the second data center agent every other preset period, wherein the message synchronization notification comprises a first synchronization timestamp;
the second data center agent is used for determining whether message synchronization is needed according to the first synchronization timestamp, and if the message synchronization is needed, sending a synchronization request message carrying a second synchronization timestamp to the first data center agent;
the first data center agent is used for sending the message to be synchronized to the second data center agent according to a second synchronization time stamp in the synchronization request message;
and the second data center agent is used for sending the message to be synchronized to the second data center for message synchronization.
Further, the first synchronization timestamp is a timestamp of a latest piece of information received by the first data center agent, and the method for determining whether message synchronization is required by the second data center agent according to the first synchronization timestamp includes:
the second data center agent judges whether the first synchronization timestamp is later than a second synchronization timestamp stored locally, wherein the second synchronization timestamp is the latest timestamp of the communication message sent by the first data center agent and received by the second data center agent last time;
if the first synchronization timestamp is later than the second synchronization timestamp, determining that message synchronization is required;
if the first synchronization timestamp is earlier than the second synchronization timestamp or the first synchronization timestamp is the same as the second synchronization timestamp, it is determined that message synchronization is not required.
Further, the method for the first data center agent to send the message to be synchronized to the second data center agent according to the second synchronization timestamp in the synchronization request message includes:
and the first data center agent takes the message with the timestamp later than the second synchronization timestamp in the received messages as the message to be synchronized, and sends the message to be synchronized to the second data center agent.
Further, after the first data center agent sends the message to be synchronized to the second data center agent according to the second synchronization timestamp in the synchronization request message, the second data center agent is further configured to update the second synchronization timestamp stored locally with the timestamp of the received latest message.
Further, before the first data center agent sends the message synchronization notification to the second data center agent every preset period, the first data center agent is further configured to receive the message of the first data center, persist the message locally, and store the message in order according to the timestamp.
In the embodiment of the application, the data center agents are configured for the data centers, the data center agents complete message synchronization, communication messages are not directly transmitted between the data centers, the data centers do not need to maintain information of other data centers, and the information of the other data centers can be maintained by the data center agents corresponding to the data centers. Meanwhile, the data center agent does not need to know the details of the service modules in other data centers, and only needs to know the information of other data center agents. The service module in the first data center needs to send the message to the service module in the second data center, and only needs to send the message to the first data center agent, and the service module in the first data center does not need to maintain the related information of the service module in the second data center, so that the information maintenance workload of the service module in the data center is reduced, and the message processing flow in the data center is simplified. The first data center agent synchronizes messages to the second data center agent only if the first synchronization timestamp is later than the second synchronization timestamp. The system architecture simplifies the message processing flow in the instant communication system, can ensure that the delivered messages are not lost, disordered and repeated, and improves the message transmission efficiency.
In order to make the aforementioned and other objects, features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 is a schematic diagram of an instant messaging system according to an embodiment of the present invention.
Fig. 2 is a flowchart illustrating a message synchronization method according to an embodiment of the present invention.
Fig. 3 is a schematic diagram of the substeps of step S102 in fig. 2.
Fig. 4 is a timing diagram of a message synchronization method according to an embodiment of the present invention.
Icon: 10-an instant messaging system; 100-a first data center; 200-a first proxy server; 300-a second data center; 400-a second proxy server.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures. Meanwhile, in the description of the present invention, the terms "first", "second", and the like are used only for distinguishing the description, and are not to be construed as indicating or implying relative importance.
An embodiment of the present application provides a message synchronization method, which is applied to an instant messaging system 10, as shown in fig. 1, the instant messaging system 10 includes a first data center 100 and a second data center 300, which are used for providing an instant messaging service for a user terminal, the first data center 100 is provided with a corresponding first data center agent 200, and the second data center 300 is provided with a corresponding second data center agent 400. As shown in fig. 2, the message synchronization method may include the following steps.
Step S101, the first data center agent 200 sends a message synchronization notification to the second data center agent 400 every preset period, where the message synchronization notification includes a first synchronization timestamp.
In the embodiment of the application, each data center in the instant messaging system can be provided with a corresponding data center agent in the data center, the data center agents serve as execution main bodies of message synchronization between the data centers, and the data center agents can receive messages which need to be sent out by each service module in the data center and can also receive messages which are sent to the data center agents by other data center agents. The first data center agent is used for receiving messages sent by all the service modules in the first data center, the second data center agent is used for receiving messages sent by all the service modules in the second data center, and the messages sent to other data centers by all the service modules in the data center can be processed by the data center agent corresponding to the data center. Therefore, a corresponding independent proxy server does not need to be configured for each data center, and the hardware cost caused by the configuration of the proxy server and the work of configuring a large number of proxy servers are avoided. In addition, since the proxy server generally can only forward messages according to preset routing rules, it is difficult to achieve synchronization of a large number of messages across data centers. Meanwhile, a proxy server is not configured for the data center, so that communication delay caused by data communication between the data center and the proxy server can be avoided.
After receiving the communication message sent by the user terminal, the first data center 100 may send the communication message to the first data center agent 200, and the first data center agent 200 delivers the message. In the embodiment of the application, the data center does not need to maintain the relevant information of other data centers, the relevant information of other data centers only needs to be maintained by the data center agent corresponding to the data center, and the data center agent only needs to maintain the relevant information of the data center agents corresponding to other data centers, and the data center agent does not need to know the details of the service modules configured inside other data centers. Each service module in the data center only needs to send the message to be synchronized to the data center agent corresponding to the data center, and the data center agent synchronizes the message. When the network policies are configured among the data centers in advance, the network policies among the data center agents corresponding to the data centers only need to be configured.
After receiving the communication message that needs to be sent by the first data center 100, the first data center agent 200 may notify the second data center agent 400 to perform message synchronization at a preset period, for example, the preset period may be 2 seconds. In this embodiment of the application, the message that the first data center 100 needs to send may be a message that needs to be sent to multiple data centers, and each message may be configured with identification information of a target data center that needs to be delivered, and it can be understood that, when notifying other data center agents, the first data center agent 200 may first determine, according to the identification information of the target data center corresponding to the message, a data center to which a communication message needs to be delivered, such as the second data center 300; determining a data center agent corresponding to the data center, such as the second data center agent 400; the data center agent corresponding to the data center to which the communication message needs to be delivered is the second data center agent 400. The first data center agent 200 may persist the communication message to the local when receiving the communication message sent by the first data center to ensure that the message is not lost. Meanwhile, the received time can be correspondingly stored as the time stamp of each communication message, the time stamp of each communication message is unique, and the first data center agent 200 can store the communication messages in order according to the sequence of the time stamps, so that the communication messages can be guaranteed against disorder.
The first data center agent 200 may take the latest time information of the time stamp in the communication message to be delivered to the second data center agent 400 as the first synchronization time stamp and send the first synchronization time stamp to the second data center agent 400. The first synchronization timestamp is essentially the timestamp of the communication message received at the latest time of receipt of all communication messages received by the first data center agent 200 that are to be delivered to the second data center agent 400.
Step S102, the second data center agent 400 determines whether message synchronization is required according to the first synchronization timestamp, and if so, sends a synchronization request message carrying a second synchronization timestamp to the first data center agent 200.
The second data center agent 400, upon receiving the message synchronization notification, may determine whether message synchronization is required based on the first synchronization timestamp included in the message synchronization notification. In detail, as shown in fig. 3, the second data center agent 400 may determine whether message synchronization is required through the following sub-steps.
And a substep S121 of determining whether the first synchronization timestamp is later than a locally stored second synchronization timestamp.
The second data center agent 400 stores a second synchronization timestamp, which is the latest timestamp in the communication message received by the second data center agent 400. The second data center agent 400 may send the message to each service module in the second data center 300 after receiving the message, and the local timestamp may also be understood as the latest timestamp in the communication message that was last delivered by the second data center agent 300 to the second data center 300. The second data center agent 400 may compare the received first synchronization timestamp to the second synchronization timestamp to determine whether the time of day information of the first synchronization timestamp is later than the time of day information of the second synchronization timestamp. It can be understood that, in the embodiment of the present application, each proxy server is time-synchronized in advance or at regular time intervals, and the time of each proxy server is completely synchronized, so as to ensure that the first synchronization timestamp and the second synchronization timestamp are based on the same time dimension.
In the embodiment of the present application, the timestamp of the communication message is uniquely determined when the communication message is received by the first data center agent 200, the timestamp of the communication message is not changed when the communication message is transmitted between the data center agents or when the communication message is transmitted between the data center agents and the data center, and the timestamp of the communication message is stored as the inherent attribute of the communication message.
And a substep S122, determining that message synchronization is required if the first synchronization timestamp is later than the second synchronization timestamp.
The second data center agent 400 may update the second synchronization timestamp with the latest timestamp in the delivered message or received message each time a communication message is delivered to the second data center 300 or each time a message sent by the first data center agent 200 is received, the second synchronization timestamp being updated as the delivery of the message progresses. If the first synchronization timestamp is later than the second synchronization timestamp, it indicates that the time information of the latest communication message is later than the time information of the latest communication message that was last delivered by the second data center agent 400, i.e., at least one of the latest messages received by the first data center agent 200 has not been delivered to the second data center agent 400. At this point, the second data center agent 400 needs to synchronize the new communication message.
Substep S123, determining that message synchronization is not required if the first synchronization timestamp is earlier than or the same as the second synchronization timestamp.
When the first synchronization timestamp is later than the second synchronization timestamp, it indicates that a new communication message was not delivered from the first data center agent 200 to the second data center agent 400. Similarly, if the first synchronization timestamp is earlier than the second synchronization timestamp or the first synchronization timestamp is the same, it indicates that all communication messages with the latest timestamp in the first data center agent 200 have been processed by the second data center agent 400, and there is no message to be delivered to the second data center agent 400 for the communication message in the first data center agent 200, and there is no need to perform message synchronization.
As previously described, the first synchronization timestamp is determined by the first data center agent 200 and the second synchronization timestamp is determined by the second data center agent 400. The first synchronization timestamp is a timestamp of a message with the latest time information among the communication messages received by the first data center agent 200 and to be delivered to the second data center agent 400. It is understood that a plurality of communication messages to be delivered to a plurality of second data center agents 400 may be received by the first data center agent 200 within a certain period of time, and the first data center agent 200 needs to notify each second data center agent 400 to perform message synchronization, and determine the first synchronization timestamp corresponding to each second data center agent 400, so that each second data center agent 400 can determine whether message synchronization is needed according to the first synchronization timestamp received by itself.
Step S103, the first data center agent 200 sends the message to be synchronized to the second data center agent 400 according to the second synchronization timestamp in the synchronization request message.
After comparing the first synchronization timestamp and the second synchronization timestamp, when it is determined that message synchronization is required, the second data center agent 400 may feed back synchronization request information carrying the second synchronization timestamp to the first data center agent 200.
The first data center agent 200 takes the message with the timestamp later than the second synchronization timestamp in the received messages as the message to be synchronized, and sends the message to be synchronized to the second data center agent 400.
When the first data center agent 200 performs message synchronization to the second data center agent 400, all communication messages which are locally stored and need to be delivered to the second data center agent 400 are not sent to the second data center agent 400, but only the communication messages with the time stamps later than the second synchronization time stamp are synchronized to the second data center agent 400, so that the latest messages which are not delivered are all received by the second data center agent 400, and the messages with the time stamps later than the second synchronization time stamp are taken as the messages to be synchronized which need to be synchronized to the second data center agent 400 by the first data center agent 200.
Step S104, the second data center agent 400 sends the message to be synchronized to the second data center 300 for message synchronization.
After receiving the messages to be synchronized, the second data center agent 400 may deliver the messages to the second data center 300, and each service module configured in the second data center 300 may receive the latest communication message.
It is understood that, since the number of messages to be synchronized may be large, in order to avoid confusion caused by sending a large number of messages to be synchronized at the same time, the messages to be synchronized may be sent in batches, for example, 100 messages are synchronized in each batch, and after the second data center agent 400 completes delivery of the messages, the next batch of messages to be synchronized is sent. After receiving the to-be-synchronized message, the second data center agent 400 may return an acknowledgement message to the first data center agent 200 confirming that the batch of to-be-synchronized messages has been received so that the first data center agent 200 may continue with the synchronization of the unsynchronized messages. To ensure that the messages to be synchronized are not out of order, the first data center agent 200 may send the messages to be synchronized sequentially in the order of the timestamps when sending the messages to be synchronized to the second data center agent 400.
In another embodiment, the method further comprises the following steps.
In step S105, the second data center agent 400 updates the second synchronization timestamp stored locally using the timestamp of the received latest message.
After receiving the messages to be synchronized each time, the second data center agent 400 may, in addition to delivering each message to be synchronized to the second data center 300, use a timestamp of a latest message among the messages to be synchronized as a new second synchronization timestamp, where the latest message is a message whose timestamp is closest to the current time among the communication messages received by the second data center agent 400. After updating the second synchronization timestamp and receiving the message synchronization notification from the first data center agent 200 again, the second data center agent 400 may determine whether message synchronization is required using the new second synchronization timestamp, and when message synchronization is required, send the new second synchronization timestamp to the first data center agent 200.
As previously described, the first data center agent 200 can send the messages to be synchronized to the second data center agent 400 in batches, and the second data center agent 400 updates the second synchronization timestamp with the timestamp of the latest message after each batch of messages to be synchronized is received. The first data center agent 200 will also use the timestamp of the new, up-to-date message that has not been synchronized as the new first synchronization timestamp when sending the first synchronization timestamp.
Next, as shown in fig. 4, the above message synchronization method is explained by taking a message synchronization process as an example.
In step a, the first data center 100 sends a communication message to the first data center agent 200.
And step b, the first data center agent 200 confirms the time stamps of the communication messages and stores the communication messages according to the sequence of the time stamps.
Step c, the first data center agent 200 sends a message synchronization notification to the second data center agent 400, wherein the message synchronization notification comprises the first synchronization timestamp.
Step d, the second data center agent 400 confirms whether message synchronization is required according to the second synchronization timestamp and the first synchronization timestamp.
Step e, when the second data center agent 400 confirms that the message synchronization is required, the second data center agent 400 sends a synchronization request message to the first data center agent 200, wherein the synchronization request message includes a second synchronization timestamp.
In step f, the first data center agent 200 retrieves the message to be synchronized with a timestamp later than the second synchronization timestamp.
Step g, the first data center agent 200 sends the message to be synchronized to the second data center agent 400.
Step h, the second data center agent 400 sends the message to be synchronized to the second data center 300.
Step i, the second data center agent 400 returns an acknowledgement message to the first data center agent 200.
Step h and step i may be performed simultaneously, and the order of message delivery and acknowledgement message return is not limited in the embodiments of the present application. Through the steps, the message synchronization is completed between the first data center agent and the second data center agent, so that the message received by the first data center agent is finally delivered to the second data center.
In summary, in the embodiment of the present application, the data center agents are configured for the data centers, so that the data center agents complete message synchronization, transmission of communication messages is not directly performed between the data centers, the data centers do not need to maintain information of other data centers, and the information of other data centers can be maintained by the data center agents corresponding to the data centers. Meanwhile, the data center agent does not need to know the details of the service modules in other data centers, and only needs to know the information of other data center agents. The service module in the first data center needs to send the message to the service module in the second data center, and only needs to send the message to the first data center agent, and the service module in the first data center does not need to maintain the related information of the service module in the second data center, so that the information maintenance workload of the service module in the data center is reduced, and the message processing flow in the data center is simplified. The first data center agent synchronizes messages to the second data center agent only if the first synchronization timestamp is later than the second synchronization timestamp. The system architecture simplifies the message processing flow in the instant communication system, can ensure that the delivered messages are not lost, disordered and repeated, and improves the message transmission efficiency.
The embodiment of the present application further provides an instant messaging system, where the instant messaging system includes a first data center, a second data center, a first data center proxy and a second data center proxy, where the first data center proxy corresponds to the first data center, the second data center proxy corresponds to the second data center, and where:
the first data center agent is used for sending a message synchronization notification to the second data center agent every other preset period, wherein the message synchronization notification comprises a first synchronization timestamp;
the second data center agent is used for determining whether message synchronization is needed according to the first synchronization timestamp, and if the message synchronization is needed, sending a synchronization request message carrying a second synchronization timestamp to the first data center agent;
the first data center agent is used for sending the message to be synchronized to the second data center agent according to a second synchronization time stamp in the synchronization request message;
and the second data center agent is used for sending the message to be synchronized to the second data center for message synchronization.
Further, the first synchronization timestamp is a timestamp of a latest piece of information received by the first data center agent, and the method for determining whether message synchronization is required by the second data center agent according to the first synchronization timestamp includes:
the second data center agent judges whether the first synchronization timestamp is later than a second synchronization timestamp stored locally, wherein the second synchronization timestamp is the latest timestamp of the communication message sent by the first data center agent and received by the second data center agent last time;
if the first synchronization timestamp is later than the second synchronization timestamp, determining that message synchronization is required;
if the first synchronization timestamp is earlier than the second synchronization timestamp or the first synchronization timestamp is the same as the second synchronization timestamp, it is determined that message synchronization is not required.
Further, the method for the first data center agent to send the message to be synchronized to the second data center agent according to the second synchronization timestamp in the synchronization request message includes:
and the first data center agent takes the message with the timestamp later than the second synchronization timestamp in the received messages as the message to be synchronized, and sends the message to be synchronized to the second data center agent.
Further, after the first data center agent sends the message to be synchronized to the second data center agent according to the second synchronization timestamp in the synchronization request message, the second data center agent is further configured to update the second synchronization timestamp stored locally with the timestamp of the received latest message.
Further, before the first data center agent sends the message synchronization notification to the second data center agent every preset period, the first data center agent is further configured to receive the message of the first data center, persist the message locally, and store the message in order according to the timestamp.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention. It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (10)

1. A message synchronization method is applied to an instant messaging system, the instant messaging system comprises a first data center, a second data center, a first data center agent and a second data center agent, the first data center agent is used for providing instant messaging service for a user terminal, the first data center agent corresponds to the first data center, the second data center agent corresponds to the second data center, and the method comprises the following steps:
the first data center agent sends a message synchronization notification to the second data center agent at intervals of a preset period, wherein the message synchronization notification comprises a first synchronization timestamp, and the first synchronization timestamp is a timestamp of a latest piece of information received by the first data center agent;
the second data center agent determines whether message synchronization is needed according to the first synchronization timestamp, and if so, sends a synchronization request message carrying a second synchronization timestamp to the first data center agent, wherein the second synchronization timestamp is the latest timestamp in the communication message sent by the first data center agent and received by the second data center agent last time;
the first data center agent sends the message to be synchronized to the second data center agent according to the second synchronization time stamp in the synchronization request message;
and the second data center agent sends the message to be synchronized to the second data center for message synchronization.
2. The message synchronization method of claim 1, wherein the step of the second data center agent determining whether message synchronization is required based on the first synchronization timestamp comprises:
the second data center agent determines whether the first synchronization timestamp is later than a locally stored second synchronization timestamp;
if the first synchronization timestamp is later than the second synchronization timestamp, determining that message synchronization is required;
if the first synchronization timestamp is earlier than the second synchronization timestamp or the first synchronization timestamp is the same as the second synchronization timestamp, it is determined that message synchronization is not required.
3. The message synchronization method of claim 1, wherein the first data center agent sending the message to be synchronized to the second data center agent according to the second synchronization timestamp in the synchronization request message comprises:
and the first data center agent takes the message with the timestamp later than the second synchronization timestamp in the received messages as the message to be synchronized, and sends the message to be synchronized to the second data center agent.
4. The message synchronization method according to claim 1, wherein after the first data center agent sends the message to be synchronized to the second data center agent according to the second synchronization timestamp in the synchronization request message, the method further comprises:
the second data center agent updates the second synchronization timestamp stored locally using the timestamp of the received latest message.
5. The message synchronization method according to claim 1, wherein before the first data center agent sends the message synchronization notification to the second data center agent every preset period, the method further comprises:
and the first data center agent receives the messages of the first data center, persists the messages to the local and stores the messages in order according to the time stamp.
6. An instant messaging system, characterized in that the instant messaging system comprises a first data center, a second data center, a first data center broker and a second data center broker for providing instant messaging service for a user terminal, the first data center broker corresponds to the first data center, the second data center broker corresponds to the second data center, wherein:
the first data center agent is used for sending a message synchronization notification to the second data center agent every other preset period, wherein the message synchronization notification comprises a first synchronization timestamp, and the first synchronization timestamp is a timestamp of a latest piece of information received by the first data center agent;
the second data center agent is used for determining whether message synchronization is needed according to the first synchronization timestamp, and if the message synchronization is needed, sending a synchronization request message carrying a second synchronization timestamp to the first data center agent, wherein the second synchronization timestamp is the latest timestamp in the communication messages sent by the first data center agent and received by the second data center agent last time;
the first data center agent is used for sending the message to be synchronized to the second data center agent according to a second synchronization time stamp in the synchronization request message;
and the second data center agent is used for sending the message to be synchronized to the second data center for message synchronization.
7. The instant messaging system of claim 6, wherein the method for the second data center agent to determine whether message synchronization is required based on the first synchronization timestamp comprises:
the second data center agent determines whether the first synchronization timestamp is later than a locally stored second synchronization timestamp;
if the first synchronization timestamp is later than the second synchronization timestamp, determining that message synchronization is required;
if the first synchronization timestamp is earlier than the second synchronization timestamp or the first synchronization timestamp is the same as the second synchronization timestamp, it is determined that message synchronization is not required.
8. The instant messaging system of claim 6, wherein the method for the first data center broker to send the message to be synchronized to the second data center broker according to the second synchronization timestamp in the synchronization request message comprises:
and the first data center agent takes the message with the timestamp later than the second synchronization timestamp in the received messages as the message to be synchronized, and sends the message to be synchronized to the second data center agent.
9. The instant messaging system of claim 6, wherein after the first data center broker sends the message to be synchronized to the second data center broker according to the second synchronization timestamp in the synchronization request message, the second data center broker is further configured to update the second synchronization timestamp stored locally with the timestamp of the latest message received.
10. The instant messaging system of claim 6, wherein before the first data center broker sends the message synchronization notification to the second data center broker at every predetermined period, the first data center broker is further configured to receive the message from the first data center, persist the message locally, and store the message in order according to a timestamp.
CN201910111809.4A 2019-02-12 2019-02-12 Message synchronization method and instant messaging system Active CN109831372B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910111809.4A CN109831372B (en) 2019-02-12 2019-02-12 Message synchronization method and instant messaging system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910111809.4A CN109831372B (en) 2019-02-12 2019-02-12 Message synchronization method and instant messaging system

Publications (2)

Publication Number Publication Date
CN109831372A CN109831372A (en) 2019-05-31
CN109831372B true CN109831372B (en) 2021-09-21

Family

ID=66863497

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910111809.4A Active CN109831372B (en) 2019-02-12 2019-02-12 Message synchronization method and instant messaging system

Country Status (1)

Country Link
CN (1) CN109831372B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2021189283A1 (en) * 2020-03-25 2021-09-30 深圳市欢太科技有限公司 Method and device for data processing, electronic device, and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102542007A (en) * 2011-12-13 2012-07-04 中国电子科技集团公司第十五研究所 Method and system for synchronization of relational databases
CN104025090A (en) * 2012-01-11 2014-09-03 霍夫曼-拉罗奇有限公司 System And Method For Database Synchronization For Medical Records

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10841391B2 (en) * 2017-06-14 2020-11-17 Fanout, Inc. Proxy-managed checkpoint identifiers

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102542007A (en) * 2011-12-13 2012-07-04 中国电子科技集团公司第十五研究所 Method and system for synchronization of relational databases
CN104025090A (en) * 2012-01-11 2014-09-03 霍夫曼-拉罗奇有限公司 System And Method For Database Synchronization For Medical Records

Also Published As

Publication number Publication date
CN109831372A (en) 2019-05-31

Similar Documents

Publication Publication Date Title
CN100452776C (en) System and method of wireless instant messaging
EP3490224A1 (en) Data synchronization method and system
US8180882B2 (en) Distributed messaging system and method for sharing network status data
CN101079869B (en) A data synchronization method and system based on distribution
CN102395115A (en) Method and system for managing message threads in converged IP messaging service
CN110492967B (en) Time synchronization method, relay equipment and device
TWI454917B (en) Access control method, access control device and access control program
WO2009068973A2 (en) Apparatus and methods for managing communications between parties
CN110012115A (en) The update method and system of direct broadcasting room pushed information
WO2023186085A1 (en) Node election voting method and apparatus based on consensus system
CN111641470B (en) Time consistency synchronization method for distributed simulation
CN109831372B (en) Message synchronization method and instant messaging system
CN101296507A (en) Method and system and server for implementing list information synchronization
JP2013153400A (en) Radio communication system, radio communication device, and reference device
EP3602974B1 (en) Apparatus and method for maintaining message databases in eventual consistency distributed database systems
CN110209986A (en) Internal storage state method of data synchronization and device
CN106210053A (en) A kind of electrical power system wide-area information management method
EP2025133B1 (en) Repository synchronization in a ranked repository cluster
CN106815053A (en) A kind of data-updating method, device, data call end and data update system
CN102118422A (en) Peer node of RELOAD peer network as well as method and system for updating configuration of peer node
CN114138520A (en) Distributed message processing method and system
CN111245939A (en) Data synchronization method, device and system
KR100435985B1 (en) Nonstop service system using voting and, information updating and providing method in the same
WO2015188481A1 (en) Unread message processing method, device and system
WO2022033291A1 (en) Ranking list service system, ranking list generation method, server, and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant