CN111327511A - Instant messaging method, system, terminal equipment and storage medium - Google Patents

Instant messaging method, system, terminal equipment and storage medium Download PDF

Info

Publication number
CN111327511A
CN111327511A CN201811533331.6A CN201811533331A CN111327511A CN 111327511 A CN111327511 A CN 111327511A CN 201811533331 A CN201811533331 A CN 201811533331A CN 111327511 A CN111327511 A CN 111327511A
Authority
CN
China
Prior art keywords
message
server
token
terminal device
open
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.)
Granted
Application number
CN201811533331.6A
Other languages
Chinese (zh)
Other versions
CN111327511B (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 Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information 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 Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201811533331.6A priority Critical patent/CN111327511B/en
Publication of CN111327511A publication Critical patent/CN111327511A/en
Application granted granted Critical
Publication of CN111327511B publication Critical patent/CN111327511B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L51/00User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
    • H04L51/04Real-time or near real-time messaging, e.g. instant messaging [IM]
    • 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/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • 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/133Protocols for remote procedure calls [RPC]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/163In-band adaptation of TCP data exchange; In-band control procedures
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/30Definitions, standards or architectural aspects of layered protocol stacks
    • H04L69/32Architecture of open systems interconnection [OSI] 7-layer type protocol stacks, e.g. the interfaces between the data link level and the physical level
    • H04L69/322Intralayer communication protocols among peer entities or protocol data unit [PDU] definitions
    • H04L69/329Intralayer communication protocols among peer entities or protocol data unit [PDU] definitions in the application layer [OSI layer 7]

Abstract

The embodiment of the application discloses an instant communication method, a system, terminal equipment and a storage medium, wherein the method comprises the following steps: the method comprises the steps that an open server receives a first message sent by first terminal equipment, generates a token of the first terminal equipment, stores the first message and a mapping relation between the first message and the token to a storage server, and sends the token to the first terminal equipment; the proxy server receives a second message sent by the first terminal, determines a target message server for the first terminal equipment from the N message servers, and stores the second message into a message queue corresponding to the target message server; and the target message server sends a third message to the second terminal equipment so that the second terminal equipment acquires the first message according to the token. Therefore, the message server can freely perform horizontal extension according to the service scale, and can support massive long connection access.

Description

Instant messaging method, system, terminal equipment and storage medium
Technical Field
The embodiment of the application relates to the technical field of internet, in particular to an instant messaging method, an instant messaging system, terminal equipment and a storage medium.
Background
With the rapid development of internet technology, the importance of instant messaging systems is increasing, and many product lines are related to the use of instant messaging systems, but the complexity of instant messaging system design is determined by the difference of the nature and the service scale of the product lines. For many product lines with small concurrency or small user quantity, in order to save research and development investment, an open-source instant messaging system, such as Openfire and the like, can be adopted, and Openfire is a free, open-source real-time collaboration server developed by adopting a Java programming language and based on an extensible messaging and presentation protocol (XMPP).
However, Openfire is based on XMPP (Extensible Messaging and Presence Protocol), and the XMPP Protocol has major disadvantages of large transmission data volume, and the performance of data transmission is greatly reduced due to the complex communication process because of the XML format. Meanwhile, the Openfire open source version is mainly single machine deployment and does not support horizontal extension, so that the supported concurrent connection is limited.
Disclosure of Invention
The embodiment of the application provides an instant messaging method, an instant messaging system, terminal equipment and a storage medium.
In a first aspect, an embodiment of the present application provides an instant messaging method, where the method is applied to an instant messaging system, and the instant messaging system includes: the server comprises a proxy server, N message servers, a kafka, a storage server and an open server, wherein the proxy server is used for proxy TCP, each message server corresponds to one message queue on the kafka, and N is a positive integer;
the open server receives a first message sent by first terminal equipment, generates a token of the first terminal equipment, stores the first message and the mapping relation between the first message and the token to the storage server, and sends the token to the first terminal equipment;
the proxy server receives a second message sent by the first terminal device according to the token, determines a target message server for the first terminal device from the N message servers, and stores the second message into a message queue corresponding to the target message server, wherein the second message comprises the token;
the target message server sends a third message to second terminal equipment, wherein the third message comprises the token; so that the second terminal device obtains the first message according to the token.
In an implementation manner of the first aspect, the causing the second terminal device to obtain the first message according to the token includes:
and the open server receives a fourth message sent by the second terminal device according to the token, acquires the first message corresponding to the token from the storage server according to the token included in the fourth message, and sends the first message to the second terminal device.
In another implementation manner of the first aspect, the kafka includes a common message queue, and the saving, by the proxy server, the second message to the message queue corresponding to the target message server includes:
the target message server receives a second message sent by the proxy server and stores the second message in the common message queue;
and the storage server consumes a second message from the common message queue, pre-processes the second message and stores the pre-processed second message into a message queue corresponding to the target message server.
In another implementation manner of the first aspect, after the open server sends the first message to the second terminal device, the method further includes:
the open server receives a fifth message sent by the second terminal device, wherein the fifth message includes the token, and the fifth message is used for indicating that the first message corresponding to the token has been received;
and the open server marks the first message as read according to the fifth message and sends a receipt message to the second terminal equipment.
Optionally, the open server includes an Http and/or RPC interface.
Optionally, at least one of the first message, the fourth message, and the fifth message is an Http message or an RPC message.
Optionally, at least one of the second message and the third message is a TCP message.
Optionally, the storage server uses Hbase storage.
In a second aspect, an embodiment of the present application provides an instant messaging method, where the method is applied to a first terminal device, and the method includes;
sending a first message to an open server so that the open server generates a token of the first terminal device, and storing the first message and a mapping relation between the first message and the token to a storage server;
receiving the token sent by the open server;
and sending a second message to the proxy server according to the token, so that the proxy server determines a target message server for the first terminal device from the N message servers, and stores the second message into a message queue corresponding to the target message server, wherein the second message comprises the token.
In a third aspect, an embodiment of the present application provides an instant messaging method, where the method is applied to a second terminal device, and the method includes;
sending a third message to a target message server, wherein the third message comprises the token;
and acquiring the first message according to the token.
In an implementation manner of the third aspect, the obtaining, by the second terminal device, the first message according to the token includes:
sending a fourth message to the open server, the fourth message including the token; enabling the open server to acquire the first message corresponding to the token from the storage server according to the token;
and receiving the first message sent by the open server.
In another implementation manner of the third aspect, after the second terminal device receives the first message sent by the open server, the method further includes:
sending a fifth message to the open server, wherein the fifth message comprises the token and is used for indicating that the first message corresponding to the token is received; so that the open server marks the first message as read according to the fifth message;
receiving a receipt message sent by the open server, wherein the receipt message is used for indicating that the first message is marked as read.
In a fourth aspect, an embodiment of the present application provides an instant messaging system, including: the server comprises a proxy server, N message servers, a kafka, a storage server and an open server, wherein the proxy server is used for proxy TCP, each message server corresponds to one message queue on the kafka, and N is a positive integer;
the open server is configured to receive a first message sent by a first terminal device, generate a token of the first terminal device, store the first message and a mapping relationship between the first message and the token in the storage server, and send the token to the first terminal device;
the proxy server is configured to receive a second message sent by the first terminal device according to the token, determine a target message server for the first terminal device from the N message servers, and store the second message in a message queue corresponding to the target message server, where the second message includes the token;
the target message server is used for sending a third message to a second terminal device, wherein the third message comprises the token; so that the second terminal device obtains the first message according to the token.
In a fifth aspect, an embodiment of the present application provides a terminal device, including:
a transmitter, configured to send a first message to an open server, so that the open server generates a token of the first terminal device, and stores the first message and a mapping relationship between the first message and the token in a storage server;
a receiver for receiving the token transmitted by the open server;
the sender is further configured to send a second message to the proxy server according to the token, so that the proxy server determines a target message server for the first terminal device from the N message servers, and stores the second message into a message queue corresponding to the target message server, where the second message includes the token.
In a sixth aspect, an embodiment of the present application provides a terminal device, including:
a sender, configured to send a third message to a target message server, where the third message includes the token;
and the processor is used for acquiring the first message according to the token.
In one implementation manner of the sixth aspect, the terminal device further includes a receiver, including:
the transmitter is specifically configured to send a fourth message to the open server, where the fourth message includes the token; enabling the open server to acquire the first message corresponding to the token from the storage server according to the token;
the receiver is specifically configured to receive the first message sent by the open server.
In another implementation manner of the sixth aspect, after the second terminal device receives the first message sent by the open server, the method further includes:
the transmitter is specifically configured to send a fifth message to the open server, where the fifth message includes the token, and the fifth message is used to indicate that the first message corresponding to the token has been received; so that the open server marks the first message as read according to the fifth message;
the receiver is configured to receive a response piece message sent by the open server, where the response piece message is used to indicate that the first message is marked as read.
In a seventh aspect, an embodiment of the present application provides a computer storage medium, where a computer program is stored in the storage medium, and the computer program, when executed, implements the instant messaging method according to any one of the first aspect.
The instant messaging method, the instant messaging system, the terminal device and the storage medium provided by the embodiment of the application receive a first message sent by a first terminal device through an open server, generate a token of the first terminal device, store the first message and a mapping relation between the first message and the token to the storage server, and send the token to the first terminal device; the proxy server receives a second message sent by the first terminal device according to the token, determines a target message server for the first terminal device from the N message servers, and stores the second message into a message queue corresponding to the target message server, wherein the second message comprises the token; the target message server sends a third message to second terminal equipment, wherein the third message comprises the token; so that the second terminal device obtains the first message according to the token. Therefore, the message server can freely perform transverse expansion according to the service scale, is not constrained by a single CPU, an internal memory and the like, can support massive long connection access, has strong flexibility and has very good robustness. Meanwhile, the TCP protocol is combined with the Http protocol and/or the RPC protocol to simplify a communication model, and transmission stability and reliability are improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to these drawings without inventive exercise.
Fig. 1 is a schematic structural diagram of an instant messaging system according to an embodiment of the present disclosure;
fig. 2 is a schematic flow chart illustrating an instant messaging method according to an embodiment of the present invention;
fig. 3 is a schematic flow chart of the instant messaging method according to the second embodiment;
fig. 4 is a schematic structural diagram of an instant messaging system according to a second embodiment;
fig. 5 is a schematic flowchart of an instant messaging method according to the third embodiment;
FIG. 6 is a graph illustrating test results according to an embodiment of the present disclosure;
fig. 7 is a schematic structural diagram of an instant messaging system method according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of a terminal device according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of a terminal device according to a first embodiment of the present application;
fig. 10 is a schematic structural diagram of a terminal device according to a second embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The existing instant messaging system based on Openfire has the disadvantages of complex communication process, low performance, no support of horizontal extension and incapability of realizing access of mass user equipment.
In order to solve the above technical problem, an embodiment of the present application provides an instant messaging system, where a proxy server is used to proxy a TCP (Transmission Control Protocol), for example, a Nginx TCP proxy module is installed in the proxy server, and is used for load balancing of the TCP, so as to implement horizontal extension of a message server, and if a user access amount is continuously increased, performance of the message server may be improved by adding the message server.
Meanwhile, each message server is allocated with a message queue (such as Kafka Topic) to realize distributed storage of messages, so that the message servers acquire the messages from the corresponding message queues, and the independence among the message servers is ensured.
The technical solution of the present application will be described in detail below with specific examples. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments.
Fig. 1 is a schematic structural diagram of an instant messaging system according to an embodiment of the present disclosure. As shown in fig. 1, the instant messaging system of the present embodiment includes: the server comprises a proxy server, N message servers, a kafka, a storage server and an open server, wherein each message server corresponds to one message queue on the kafka server, and N is a positive integer.
Specifically, as shown in fig. 1, the proxy server of this embodiment may be a nginnx proxy server, and the nginnx proxy server is used for proxy TCP and is used for implementing load balancing of the TCP. For example, a NginxTCP proxy module (Nginx _ tcp _ proxy _ module) is installed on the Nginx proxy server. Alternatively, the TCP load balancing function of the commercially authorized version of the Nginx Plus is used. Therefore, when the mass equipment of the user accesses the message server through the proxy server, the proxy server can realize four-layer load balancing. The message server can be selected from a plurality of message servers for the user equipment to access, so that the message servers are mutually independent, and the message servers can be conveniently and transversely expanded.
The message server of this embodiment may be an IM (Instant Messaging) server, and the main role of the message server is to establish a TCP connection. The number of the consumption servers is 1 or more, and 1 message server can support access of a plurality of user equipments, for example, 1 message server supports access of 10 ten thousand user equipments. The number of the message servers is not limited in this embodiment, and is specifically determined according to actual needs. As user equipment increases, the number of message servers may increase.
The kafka of this example is an open source stream processing platform developed by the Apache software foundation, written in Scala and Java. Kafka is a high-throughput distributed publish-subscribe messaging system that can handle all the action flow data in a consumer-scale website. This action (web browsing, searching and other user actions) is a key factor in many social functions on modern networks. These data are typically addressed by handling logs and log aggregations due to throughput requirements. This is a viable solution to the limitations of Hadoop-like log data and offline analysis systems, but which require real-time processing. The purpose of Kafka is to unify online and offline message processing through the parallel loading mechanism of Hadoop, and also to provide real-time messages through clustering. Kafka includes one or more servers, and messages stored by Kafka clusters are recorded in a topic category.
The Kafka of the present embodiment assigns a message queue, such as Kafka topoic, to each message server so that each message server can store its respective message in its respective message queue.
The instant messaging system of this embodiment may include one storage server, or may include a plurality of storage servers, and this embodiment does not limit the number of storage servers, and is specifically determined according to actual needs.
The open server in this embodiment may be a seek server, and the seek server is configured to receive an end connection message sent by the user equipment, for example, an Http (HyperText Transfer Protocol) message or an RPC (Remote Procedure Call) message. The Seek server is used for inquiring the details of the message sent by the user, and the interface receives receipt processing to obtain the request token or provide a message sending log inquiry interface for the use of an administrator.
The number of the open servers is not limited in this embodiment, and may be one or more, and is specifically determined according to actual needs.
The instant messaging method of the present embodiment is described in detail below with reference to the instant messaging system shown in fig. 1.
Fig. 2 is a flowchart illustrating an instant messaging method according to an embodiment of the present invention. This embodiment relates to an example of a message sent by a first terminal device to a second terminal device through the instant messaging system shown in fig. 1. As shown in fig. 2, the method of this embodiment may include:
s101, the first terminal device sends a first message to the open server.
S102, the open server generates a token of the first terminal device according to the first message, and stores the first message and the mapping relation between the first message and the token to the storage server.
S103, the open server sends the token to the first terminal equipment.
When the first terminal equipment needs to send the first message to the second terminal equipment, the first message is sent to the open server. For example, the first terminal device sends a first message to the open server using Http or RPC interface, where the first message may be a POST message, and the POST message may be: { "to": second terminal device @ im-xx.xx.com/app "," id ": 98ef99199928", "body": { "content": text "}," node ": message", "created": 1505204095053"," device ": app", "from": first terminal device @ im-xx.xx.com/app "," group ": point" }.
After receiving the first message, the open server generates a token (token) for the first terminal device according to the first message, establishes a mapping relationship between the token and the first message, and stores the mapping relationship and the first message in the storage server. And sending the generated token to the first terminal equipment.
The steps from S101 to S103 may be understood as a process in which the first terminal device logs in the instant messaging system for the first time, and after logging in, the open server stores the first message and generates a token for the first terminal device. In the subsequent interactive process, the token is used as the basis for information exchange, and the first message is always stored in the storage server, so that the first message is prevented from being lost or damaged when being transmitted for multiple times, and the safety of the first message is further improved.
And S104, the first terminal equipment sends a second message to the proxy server according to the token.
Wherein the second message comprises the token.
S105, the proxy server determines a target message server for the first terminal device from the N message servers, and stores the second message into a message queue corresponding to the target message server.
S106, the target message server sends a third message to the second terminal device.
Wherein the token is included in the third message.
And S107, the second terminal equipment acquires the first message according to the token.
Specifically, after obtaining the token sent by the open server, the first terminal device sends a second message to the proxy server according to the token, where the second message includes the token. For example, the second message is: { "req _ type": set _ messgae "," token ": T1" }.
And after receiving the second message, the proxy server determines a message server as a target message server for the first terminal equipment from N message servers in the instant messaging system.
And then, the proxy server stores the second message into a message queue corresponding to the target message server, wherein the second message comprises the token. In one example, the proxy server stores the second message directly in a message queue corresponding to the target message server. In another example, the proxy server performs preprocessing on the second message, for example, splitting a group chat message, splitting a public number message, storing a message log, and the like, and stores the preprocessed second message in a message queue corresponding to the target message server.
And when the target message server detects that the second terminal equipment is on line, sending a third message carrying the token of the first terminal to the second terminal equipment. The third message is used to indicate that the first terminal device corresponding to the second terminal device token has sent a message to it. For example, the third message is: { "req _ type": get _ messgae "," token ": T1" }.
And after receiving the third message, the second terminal equipment acquires a first message corresponding to the token from the storage server according to the token carried in the third message.
Optionally, the second terminal device is connected to the storage server, and may directly obtain the first message corresponding to the token from the storage server.
Optionally, the second terminal device obtains the first message from the storage server by sending the first message to the open server.
In the method of the embodiment, when the second terminal device is offline or the instant messaging system is congested and the like, the first terminal device stores the first message in the storage server through the development server. When the second terminal equipment is on-line or the instant communication system is idle, the target message server informs the second terminal equipment that other terminal equipment sends messages to the second terminal equipment, so that the second terminal equipment can pull the first message in time, and accurate and complete transmission of the first message is further ensured.
Optionally, at least one of the second message and the third message is a TCP message.
Optionally, the first message is an Http message or an RPC message.
According to the timely communication method provided by the embodiment of the application, an open server receives a first message sent by a first terminal device, generates a token of the first terminal device, stores the first message and a mapping relation between the first message and the token to a storage server, and sends the token to the first terminal device; the proxy server receives a second message sent by the first terminal device according to the token, determines a target message server for the first terminal device from the N message servers, and stores the second message into a message queue corresponding to the target message server, wherein the second message comprises the token; the target message server sends a third message to second terminal equipment, wherein the third message comprises the token; so that the second terminal device obtains the first message according to the token. Therefore, the message server can freely perform transverse expansion according to the service scale, is not constrained by a single CPU, an internal memory and the like, can support massive long connection access, has strong flexibility and has very good robustness. Meanwhile, the TCP protocol is combined with the Http protocol and/or the RPC protocol to simplify a communication model, and transmission stability and reliability are improved.
Fig. 3 is a schematic flowchart of the instant messaging method according to the second embodiment, and fig. 4 is a schematic structural diagram of the instant messaging system according to the second embodiment. As shown in fig. 3 and 4, this embodiment relates to a specific process that when kafka includes a common message queue, the proxy server stores the second message in the message queue corresponding to the target message server in S105.
S201, the proxy server sends the second message to the target message server.
S202, the target message server stores the second message in the common message queue.
S203, the storage server consumes the second message from the shared message queue, pre-processes the second message, and stores the pre-processed second message into the message queue corresponding to the target message server.
As shown in fig. 4, Kafka of this embodiment further includes a common message queue, such as MQ Kafka topoc, and in actual use, after receiving a long connection message (such as a TCP message) of a user, each message server does not immediately store the long connection message in the corresponding message queue, but writes the long connection message into MQ Kafka topoc first. Thus, the storage server will consume the long connection message from MQKafka Topic and subject the long connection message to some logical processing, such as: and (4) warehousing Hbase, splitting and sending group chat messages, splitting and sending public number messages, storing message logs and the like, and finally storing the processed long connection messages into corresponding message queues.
Specifically, after the proxy server sends the second message to the target message server, the target message server does not directly store the second message in the corresponding message queue, but stores the second message in MQ Kafka topoic. The storage server then consumes the second message from MQ Kafka Topic and pre-processes the second message, such as group chat message breakout, public number message breakout, message log storage, and so forth. And finally, the storage server stores the preprocessed second message into a message queue corresponding to the target message server.
Optionally, the instant messaging system of this embodiment further includes a Redis, where the Redis may store a mapping relationship between a message queue corresponding to the message server and a message sent to the message server. For example, the target message server corresponds to the message queue 1, and the message sent to the target message server is the second message 1, so that the Redis can store the mapping relationship between the second message 1 and the message queue 1. At this time, after the storage server processes the second message 1, the message queue 1 corresponding to the second message 1 is obtained from the Redis, and the second message 1 is stored in the message queue 1.
According to the instant messaging method provided by the embodiment of the application, the message processing logic is moved to the storage server, the pressure of the message server is relieved, and meanwhile, if the consumption capacity of the storage server is insufficient, the storage server can be added to realize the expansion of the storage service.
Fig. 5 is a schematic flow chart of an instant messaging method provided in the third embodiment, where based on the foregoing embodiments, as shown in fig. 5, the instant messaging method of the third embodiment may include:
s301, the first terminal device sends a first message to the open server.
S302, the open server generates a token of the first terminal device according to the first message, and stores the first message and the mapping relation between the first message and the token to the storage server.
And S303, the open server sends the token to the first terminal equipment.
S304, the first terminal device sends a second message to the proxy server according to the token.
S305, the proxy server determines a target message server for the first terminal device from the N message servers, and stores the second message into a message queue corresponding to the target message server.
S306, the target message server sends a third message to the second terminal device.
The specific processes of S301 to S306 are the same as those in the above embodiments, and reference is made to some blocks in the above embodiments, which are not described herein again.
And S307, the second terminal equipment sends a fourth message to the open server.
Wherein the fourth message comprises the token.
S308, the open server acquires the first message corresponding to the token from the storage server.
S309, the open server sends the first message to the second terminal device.
S307 to S309 are specific processes of S107.
Specifically, after receiving the third message sent by the target message server, the second terminal device learns that there are other terminal devices sending messages to the second terminal device, and therefore, the second terminal device sends a fourth message to the open server, where the fourth message is, for example: { "req _ type": get _ messgae "," token ": T1" }. And after the open server receives the fourth message, acquiring the first message corresponding to the token from the storage server according to the token in the fourth message. And finally, sending the first message to the second terminal equipment. For example, the message returned by the open server to the second terminal device is: { "to": second terminal device @ im-xx.xx.com/app "," id ": 98ef99199928", "body": { "content": text "}," node ": message", "created": 1505204095053"," device ": app", "from": first terminal device @ im-xx.xx.com/app "," group ": point" }. Therefore, the second terminal equipment can acquire the first message from the instant communication system in time.
And S310, the second terminal equipment sends a fifth message to the open server.
Wherein the fifth message includes the token, and the fifth message is used to indicate that the first message corresponding to the token has been received.
S311, the open server marks the first message as read according to the fifth message.
And S312, the open server sends a response message to the second terminal device.
In this embodiment, in order to ensure that the second terminal device receives the first message, the second terminal device sends a fifth message to the open server after receiving the first message, where the fifth message is, for example: { "req _ type": flush _ receive "," token ": T1" }. And after receiving the fifth message, the open server learns that the second terminal has received the first message, and at this time, the open server marks the first message held in the storage server as read, so as to prevent the first message from being subsequently pushed to the second terminal equipment. And finally, after the open server marks the first message as read, sending a receipt message to the second terminal device, and informing the second terminal device that the first message is marked as read.
In this embodiment, the second message sent by the target message server to the second terminal device is a TCP message, and the fourth message and the fifth message sent by the second terminal device to the development server are Http messages or RPC messages. And when the development server does not receive the fifth message within the preset time, the development server resends the second message to the second terminal device and resends the first message to the second terminal device. Therefore, reliable transmission and acquisition of the first message are guaranteed by combining TCP with the Http protocol and/or the RPC protocol, and the problem of packet loss transmission of the traditional TCP is greatly reduced.
Optionally, at least one of the fourth message and the fifth message is an Http message or an RPC message.
Optionally, the storage server of this embodiment uses Hbase to store messages and data such as logs, and uses Hbase write operation in a large range to achieve high throughput.
In order to further verify the advantages of the instant messaging method according to the embodiment of the present application, different numbers of concurrent user equipments are used to test the instant messaging system process according to the embodiment, and the test result is shown in fig. 6. As can be seen from fig. 6, as the number of concurrent user equipment connections increases, the stability of the instant messaging system tends to be smooth without glitches while the performance of the instant messaging system is ensured.
Those of ordinary skill in the art will understand that: all or part of the steps for implementing the method embodiments may be implemented by hardware related to program instructions, and the program may be stored in a computer readable storage medium, and when executed, the program performs the steps including the method embodiments; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Fig. 7 is a schematic structural diagram of an instant messaging system method provided in the first embodiment, and as shown in fig. 7, the instant messaging system 100 includes: a proxy server 110 for proxy TCP, N message servers 120, kafka150, a storage server 130 and an open server 140, each of said message servers 120 corresponding to a message queue on said kafka.
The open server 140 is configured to receive a first message sent by a first terminal device, generate a token of the first terminal device, store the first message and a mapping relationship between the first message and the token in the storage server 130, and send the token to the first terminal device;
the proxy server 110 is configured to receive a second message sent by the first terminal device according to the token, determine a target message server 120 for the first terminal device from the N message servers 120, and store the second message into a message queue corresponding to the target message server 120, where the second message includes the token;
the target message server 120 is configured to send a third message to a second terminal device, where the third message includes the token; so that the second terminal device obtains the first message according to the token.
The instant messaging system of the embodiment of the present application may be configured to implement the technical solutions of the above-described method embodiments, and the implementation principles and technical effects thereof are similar and will not be described herein again.
In a possible implementation manner, the open server 140 is specifically configured to receive a fourth message sent by the second terminal device according to the token, acquire the first message corresponding to the token from the storage server 130 according to the token included in the fourth message, and send the first message to the second terminal device.
In a possible implementation manner, the target message server 120 is configured to receive a second message sent by the proxy server 110, and store the second message in the common message queue;
the storage server 130 is configured to consume a second message from the common message queue, pre-process the second message, and store the pre-processed second message in a message queue corresponding to the target message server 120.
In a possible implementation manner, the open server 140 is further configured to receive a fifth message sent by the second terminal device, where the fifth message includes the token, and the fifth message is used to indicate that the first message corresponding to the token has been received; and marking the first message as read according to the fifth message, and sending a receipt message to the second terminal equipment.
Optionally, the open server 140 includes an Http and/or RPC interface.
Optionally, at least one of the first message, the fourth message, and the fifth message is an Http message or an RPC message.
Optionally, at least one of the second message and the third message is a TCP message.
Optionally, the storage server 130 employs Hbase storage.
The instant messaging system of the embodiment of the present application may be configured to implement the technical solutions of the above-described method embodiments, and the implementation principles and technical effects thereof are similar and will not be described herein again.
Fig. 8 is a schematic structural diagram of a terminal device provided in an embodiment of the present application, and as shown in fig. 8, a terminal device 200 of this embodiment may be a first terminal device described in the foregoing embodiment, where the terminal device 200 includes:
a memory 210 for storing a computer program;
a processor 220 for executing the computer program;
a transmitter 230, configured to send a first message to an open server, so that the open server generates a token of the first terminal device, and stores the first message and a mapping relationship between the first message and the token to a storage server;
a receiver 240 for receiving the token transmitted by the open server;
the sender 230 is further configured to send a second message to the proxy server according to the token, so that the proxy server determines a target message server for the first terminal device from the N message servers, and stores the second message into a message queue corresponding to the target message server, where the second message includes the token.
The terminal device of the embodiment of the present application may be configured to execute the technical solution of the above-described method embodiment, and the implementation principle and the technical effect are similar, which are not described herein again.
Fig. 9 is a schematic structural diagram of a terminal device according to a first embodiment of the present application, and as shown in fig. 9, a terminal device 300 according to this embodiment may be a second terminal device according to the foregoing embodiment, where the terminal device 300 includes:
a memory 310 for storing a computer program;
a processor 320 for executing the computer program;
a transmitter 330, configured to send a third message to a target message server, where the third message includes the token;
the processor 320 is further configured to obtain the first message according to the token.
The terminal device of the embodiment of the present application may be configured to execute the technical solution of the above-described method embodiment, and the implementation principle and the technical effect are similar, which are not described herein again.
Fig. 10 is a schematic structural diagram of a terminal device according to a second embodiment of the present application, and as shown in fig. 10, the terminal device 300 further includes a receiver 340.
The transmitter 330 is specifically configured to transmit a fourth message to the open server, where the fourth message includes the token; enabling the open server to acquire the first message corresponding to the token from the storage server according to the token;
the receiver 340 is specifically configured to receive the first message sent by the open server.
In a possible implementation manner of this embodiment, the transmitter 330 is specifically configured to send a fifth message to the open server, where the fifth message includes the token, and the fifth message is used to indicate that the first message corresponding to the token has been received; so that the open server marks the first message as read according to the fifth message;
the receiver 340 is configured to receive a response piece message sent by the open server, where the response piece message is used to indicate that the first message is marked as read.
The terminal device of the embodiment of the present application may be configured to execute the technical solution of the above-described method embodiment, and the implementation principle and the technical effect are similar, which are not described herein again.
The instant messaging method may be embodied in a form and stored in a computer readable storage medium when sold or used as a stand-alone product. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, a network device, or the like) or a processor (processor) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the application to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
Finally, it should be noted that: the above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present application.

Claims (16)

1. An instant messaging method, wherein the method is applied to an instant messaging system, and the instant messaging system comprises: the server comprises a proxy server, N message servers, a distributed publish-subscribe message system kafka, a storage server and an open server, wherein the proxy server is used for proxy TCP, each message server corresponds to a message queue on the kafka, and N is a positive integer;
the open server receives a first message sent by first terminal equipment, generates a token of the first terminal equipment, stores the first message and the mapping relation between the first message and the token to the storage server, and sends the token to the first terminal equipment;
the proxy server receives a second message sent by the first terminal device according to the token, determines a target message server for the first terminal device from the N message servers, and stores the second message into a message queue corresponding to the target message server, wherein the second message comprises the token;
the target message server sends a third message to second terminal equipment, wherein the third message comprises the token; so that the second terminal device obtains the first message according to the token.
2. The method of claim 1, wherein said causing the second terminal device to obtain the first message according to the token comprises:
and the open server receives a fourth message sent by the second terminal device according to the token, acquires the first message corresponding to the token from the storage server according to the token included in the fourth message, and sends the first message to the second terminal device.
3. The method of claim 1 or 2, wherein the kafka comprises a common message queue, and wherein the step of the proxy server saving the second message to the message queue corresponding to the target message server comprises:
the target message server receives a second message sent by the proxy server and stores the second message in the common message queue;
and the storage server consumes a second message from the common message queue, pre-processes the second message and stores the pre-processed second message into a message queue corresponding to the target message server.
4. The method of claim 2, wherein after the open server sends the first message to the second terminal device, the method further comprises:
the open server receives a fifth message sent by the second terminal device, wherein the fifth message includes the token, and the fifth message is used for indicating that the first message corresponding to the token has been received;
and the open server marks the first message as read according to the fifth message and sends a receipt message to the second terminal equipment.
5. The method of claim 1, wherein the open server comprises a hypertext transfer protocol Http and/or a remote procedure call protocol RPC interface.
6. The method of claim 1, wherein at least one of the first message, the fourth message, and the fifth message is an Http message or an RPC message.
7. The method of claim 1, wherein at least one of the second message and the third message is a TCP message.
8. The method of claim 1, wherein the storage server employs Hbase storage.
9. An instant messaging method is applied to a first terminal device, and comprises the following steps;
sending a first message to an open server so that the open server generates a token of the first terminal device, and storing the first message and a mapping relation between the first message and the token to a storage server;
receiving the token sent by the open server;
and sending a second message to the proxy server according to the token, so that the proxy server determines a target message server for the first terminal device from the N message servers, and stores the second message into a message queue corresponding to the target message server, wherein the second message comprises the token.
10. An instant messaging method is applied to a second terminal device, and comprises the following steps;
sending a third message to a target message server, wherein the third message comprises the token;
and acquiring the first message according to the token.
11. The method of claim 10, wherein the second terminal device obtains the first message according to the token, and wherein the obtaining comprises:
sending a fourth message to the open server, the fourth message including the token; enabling the open server to acquire the first message corresponding to the token from the storage server according to the token;
and receiving the first message sent by the open server.
12. The method according to claim 11, wherein after the second terminal device receives the first message sent by the open server, the method further comprises:
sending a fifth message to the open server, wherein the fifth message comprises the token and is used for indicating that the first message corresponding to the token is received; so that the open server marks the first message as read according to the fifth message;
receiving a receipt message sent by the open server, wherein the receipt message is used for indicating that the first message is marked as read.
13. An instant messaging system, comprising: the server comprises a proxy server, N message servers, a distributed publish-subscribe message system kafka, a storage server and an open server, wherein the proxy server is used for proxy TCP, each message server corresponds to a message queue on the kafka, and N is a positive integer;
the open server is configured to receive a first message sent by a first terminal device, generate a token of the first terminal device, store the first message and a mapping relationship between the first message and the token in the storage server, and send the token to the first terminal device;
the proxy server is configured to receive a second message sent by the first terminal device according to the token, determine a target message server for the first terminal device from the N message servers, and store the second message in a message queue corresponding to the target message server, where the second message includes the token;
the target message server is used for sending a third message to a second terminal device, wherein the third message comprises the token; so that the second terminal device obtains the first message according to the token.
14. A terminal device, comprising;
a transmitter, configured to send a first message to an open server, so that the open server generates a token of the first terminal device, and stores the first message and a mapping relationship between the first message and the token in a storage server;
a receiver for receiving the token transmitted by the open server;
the sender is further configured to send a second message to the proxy server according to the token, so that the proxy server determines a target message server for the first terminal device from the N message servers, and stores the second message into a message queue corresponding to the target message server, where the second message includes the token.
15. A terminal device, comprising;
a sender, configured to send a third message to a target message server, where the third message includes the token;
and the processor is used for acquiring the first message according to the token.
16. A computer storage medium, characterized in that the storage medium has stored therein a computer program which, when executed, implements the instant messaging method according to any one of claims 1-8.
CN201811533331.6A 2018-12-14 2018-12-14 Instant messaging method, system, terminal equipment and storage medium Active CN111327511B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811533331.6A CN111327511B (en) 2018-12-14 2018-12-14 Instant messaging method, system, terminal equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811533331.6A CN111327511B (en) 2018-12-14 2018-12-14 Instant messaging method, system, terminal equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111327511A true CN111327511A (en) 2020-06-23
CN111327511B CN111327511B (en) 2022-04-12

Family

ID=71171080

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811533331.6A Active CN111327511B (en) 2018-12-14 2018-12-14 Instant messaging method, system, terminal equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111327511B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115225715A (en) * 2022-06-30 2022-10-21 深圳市云洲创新科技有限公司 Data interaction method and data interaction system

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130086199A1 (en) * 2011-09-30 2013-04-04 Oracle International Corporation System and method for managing message queues for multinode applications in a transactional middleware machine environment
WO2014035194A1 (en) * 2012-08-30 2014-03-06 Samsung Electronics Co., Ltd. Push message service system and method
WO2014165152A1 (en) * 2013-03-12 2014-10-09 Burnett J Stephen Electronic message aggregation and sharing system and apparatus
CN104584489A (en) * 2012-08-30 2015-04-29 三星电子株式会社 Push message service system and method
CN105721274A (en) * 2014-12-03 2016-06-29 中国移动通信集团公司 Method and device for integrating variety of instant messaging
WO2016156256A1 (en) * 2015-03-30 2016-10-06 British Telecommunications Public Limited Company Data communications
CN106201705A (en) * 2016-07-25 2016-12-07 东软集团股份有限公司 Process the method and device of message
CN106911544A (en) * 2017-01-20 2017-06-30 深圳市沃特玛电池有限公司 Communication system and the means of communication

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130086199A1 (en) * 2011-09-30 2013-04-04 Oracle International Corporation System and method for managing message queues for multinode applications in a transactional middleware machine environment
WO2014035194A1 (en) * 2012-08-30 2014-03-06 Samsung Electronics Co., Ltd. Push message service system and method
CN104584489A (en) * 2012-08-30 2015-04-29 三星电子株式会社 Push message service system and method
WO2014165152A1 (en) * 2013-03-12 2014-10-09 Burnett J Stephen Electronic message aggregation and sharing system and apparatus
CN105721274A (en) * 2014-12-03 2016-06-29 中国移动通信集团公司 Method and device for integrating variety of instant messaging
WO2016156256A1 (en) * 2015-03-30 2016-10-06 British Telecommunications Public Limited Company Data communications
CN106201705A (en) * 2016-07-25 2016-12-07 东软集团股份有限公司 Process the method and device of message
CN106911544A (en) * 2017-01-20 2017-06-30 深圳市沃特玛电池有限公司 Communication system and the means of communication

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115225715A (en) * 2022-06-30 2022-10-21 深圳市云洲创新科技有限公司 Data interaction method and data interaction system
CN115225715B (en) * 2022-06-30 2024-01-26 深圳市云洲创新科技有限公司 Data interaction method and data interaction system

Also Published As

Publication number Publication date
CN111327511B (en) 2022-04-12

Similar Documents

Publication Publication Date Title
CN108833950B (en) Barrage message issuing method, server, system and storage medium
US8544075B2 (en) Extending a customer relationship management eventing framework to a cloud computing environment in a secure manner
CN115004673B (en) Message pushing method, device, electronic equipment and computer readable medium
US10623450B2 (en) Access to data on a remote device
CN111770002B (en) Test data forwarding control method and device, readable storage medium and electronic equipment
EP3028437A1 (en) Messaging api over http protocol to establish context for data exchange
Sharvari et al. A study on modern messaging systems-kafka, rabbitmq and nats streaming
CN116303608A (en) Data processing method and device for application service
CN110798495B (en) Method and server for end-to-end message push in cluster architecture mode
CN111327511B (en) Instant messaging method, system, terminal equipment and storage medium
US8949344B2 (en) Asynchronous queued messaging for web applications
CN112527530B (en) Message processing method, device, apparatus, storage medium and computer program product
CN108989404B (en) Barrage message issuing method, server, system and storage medium
US20140164523A1 (en) Automated enabling of instant messaging communications in a client system
CN112948138A (en) Method and device for processing message
CN114390239B (en) Communication method, device, system, electronic device, and storage medium
CN108076111B (en) System and method for distributing data in big data platform
US20090282367A1 (en) Method and system for electronic communication management
CN106899652A (en) A kind of method and device of transmission service result
CN108471375B (en) Message processing method, device and terminal
KR102367017B1 (en) Communication network system and control method thereof
Kirsan et al. Improved access speed of the Codeigniter framework and REST APIs for the implementation of SIAKAD: Academic information system in Balikpapan schools
US11736336B2 (en) Real-time monitoring of machine learning models in service orchestration plane
CN113132480B (en) Data transmission method, device and system
CN116232739A (en) Data multi-terminal sharing method, device, equipment and 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