CN109600302A - A kind of method, apparatus orderly communicated, storage medium and electronic equipment - Google Patents

A kind of method, apparatus orderly communicated, storage medium and electronic equipment Download PDF

Info

Publication number
CN109600302A
CN109600302A CN201811438050.2A CN201811438050A CN109600302A CN 109600302 A CN109600302 A CN 109600302A CN 201811438050 A CN201811438050 A CN 201811438050A CN 109600302 A CN109600302 A CN 109600302A
Authority
CN
China
Prior art keywords
message
client
session
sequence number
conversation message
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201811438050.2A
Other languages
Chinese (zh)
Inventor
尹群虎
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Golden Melon Seed Technology Development (beijing) Co Ltd
Original Assignee
Golden Melon Seed Technology Development (beijing) 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 Golden Melon Seed Technology Development (beijing) Co Ltd filed Critical Golden Melon Seed Technology Development (beijing) Co Ltd
Priority to CN201811438050.2A priority Critical patent/CN109600302A/en
Publication of CN109600302A publication Critical patent/CN109600302A/en
Pending legal-status Critical Current

Links

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]
    • H04L51/046Interoperability with other network applications or services
    • 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]
    • H04L51/043Real-time or near real-time messaging, e.g. instant messaging [IM] using or handling presence information
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/146Markers for unambiguous identification of a particular session, e.g. session cookie or URL-encoding
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L2101/00Indexing scheme associated with group H04L61/00
    • H04L2101/60Types of network addresses
    • H04L2101/618Details of network addresses
    • H04L2101/622Layer-2 addresses, e.g. medium access control [MAC] addresses

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)

Abstract

The present invention provides method, apparatus, storage medium and electronic equipments that one kind orderly communicates, wherein, this method comprises: obtaining the conversation message that the first client is sent, conversation message includes the session identification for receiving address and being generated based on the unique identification information for receiving address and/or the first client;Junior corresponding with session identification connecting node is determined according to session identification, and conversation message is sent to junior's connecting node, and instruction junior's connecting node continues transmission session message, until conversation message is sent to the second client corresponding with address is received.Method, apparatus, storage medium and the electronic equipment that the one kind provided through the embodiment of the present invention orderly communicates, the conversation message that there is same session to identify can be made to transmit along same link, so that the process of transmission message is serialization, the order of distributed system messaging thereby may be ensured that.

Description

A kind of method, apparatus orderly communicated, storage medium and electronic equipment
Technical field
The present invention relates to the technical field of instant messaging, the method, apparatus orderly communicated in particular to one kind is deposited Storage media and electronic equipment.
Background technique
Instant messaging (IM, Instant Messaging) is in distributed network environment, is wrapped in this distributed environment Include client, server-side two large divisions.Client refers to the app being mounted on user mobile phone application or uses pc browser defeated Entering specified IM network address, server end mainly includes application service cluster, function services cluster, storage service cluster etc., these On different physical machines, machine time maintains aggregated pattern mainly by local clock, the clock between different machines node It is not strict conformance, there are a small amount of deviations.
The cluster that each module of server end is made of more machines, message are sent and each from the same client It reaches server to be also not fixed, message needs before sending arrival server by transport network layer, the message that may first send After reach server, even if the message that same client sends every time reaches same server, since each server is more The speed of thread process, every message of processing is also different.
The prior art is mostly based on TimeLine modelling, all message of some user are stored in TimeLine In, each end of user can synchronize respective message from this queue.It cannot not can guarantee heavyly, do not leak in this design theory, but In specific implement, under distributed environment, there is multiple client, has web cluster, service cluster, message-oriented middleware collection Group, data-base cluster etc., they are distributed on different machines, be all between machine using local clock, without one A so-called " global clock ", using " local zone time " come decision message timing when, Yi Fasheng information receiving and transmitting sequence is inconsistent The problem of.
For example, message m sgA and msgB that user A has two time intervals very close, corresponding msgId is respectively 1,2, Due to the cluster features of distributed system, msgB is likely to occur in distributed system, TimeLine is first written, if user at this time Just in synchronization message, msgB (message that msgId is 2) first can be synchronized to client, cause the sequence error of msgA.
Summary of the invention
To solve the above problems, the embodiment of the present invention is designed to provide method, apparatus, the storage that one kind orderly communicates Medium and electronic equipment.
In a first aspect, the embodiment of the invention provides the methods that one kind orderly communicates, comprising:
The conversation message of the first client transmission is obtained, the conversation message includes receiving address and based on the reception ground The session identification that the unique identification information of location and/or first client generates;
Junior corresponding with session identification connecting node is determined according to the session identification, and the session is disappeared Breath is sent to junior's connecting node, indicates that junior's connecting node continues to transmit the conversation message, until will be described Conversation message is sent to the second client corresponding with the reception address.
Second aspect, the embodiment of the invention also provides the devices that one kind orderly communicates, comprising:
Message capturing module, for obtaining the conversation message of the first client transmission, the conversation message includes receiving ground The session identification of location and the unique identification information generation based on the reception address and/or first client;
Processing module, for determining junior corresponding with session identification connecting node according to the session identification, And the conversation message is sent to junior's connecting node, it indicates that junior's connecting node continues to transmit the session and disappears Breath, until the conversation message is sent to the second client corresponding with the reception address.
The third aspect, the embodiment of the invention also provides a kind of storage medium, the storage medium is stored with computer can It executes instruction, method of the computer executable instructions for orderly being communicated described in above-mentioned any one
Fourth aspect, the embodiment of the invention also provides a kind of electronic equipment, comprising:
At least one processor;And
The memory being connect at least one described processor communication;Wherein,
The memory is stored with the instruction that can be executed by least one described processor, and described instruction is by described at least one A processor executes, so that at least one described processor is able to carry out the method orderly communicated described in above-mentioned any one
In the scheme that the above-mentioned first aspect of the embodiment of the present invention provides, the session mark generated based on unique identification information is utilized Selection connecting link is known, so that the conversation message with same session mark is transmitted along same link, so that passing The process of defeated message is serialization, thereby may be ensured that the order of distributed system messaging.
To enable the above objects, features and advantages of the present invention to be clearer and more comprehensible, preferred embodiment is cited below particularly, and cooperate Appended attached drawing, is described in detail below.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this Some embodiments of invention for those of ordinary skill in the art without creative efforts, can be with It obtains other drawings based on these drawings.
Fig. 1 shows the flow chart for the method that one kind provided by the embodiment of the present invention orderly communicates;
Fig. 2 shows the flow charts for the method that another kind provided by the embodiment of the present invention orderly communicates;
Fig. 3 is shown in the method orderly communicated provided by the embodiment of the present invention, determines the specific of junior's connecting node The flow chart of method;
Fig. 4 shows the flow diagram of another method orderly communicated provided by the embodiment of the present invention;
Fig. 5 shows the structural schematic diagram for the device that one kind provided by the embodiment of the present invention orderly communicates;
Fig. 6 shows the structural schematic diagram for the device that another kind provided by the embodiment of the present invention orderly communicates;
Fig. 7 is shown in the device orderly communicated provided by the embodiment of the present invention, the specific structure signal of processing module Figure;
The structure that Fig. 8 shows the electronic equipment provided by the embodiment of the present invention for executing the method orderly communicated is shown It is intended to.
Specific embodiment
In the description of the present invention, it is to be understood that, term " center ", " longitudinal direction ", " transverse direction ", " length ", " width ", " thickness ", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom" "inner", "outside", " up time The orientation or positional relationship of the instructions such as needle ", " counterclockwise " is to be based on the orientation or positional relationship shown in the drawings, and is merely for convenience of The description present invention and simplified description, rather than the device or element of indication or suggestion meaning must have a particular orientation, with spy Fixed orientation construction and operation, therefore be not considered as limiting the invention.
In addition, term " first ", " second " are used for descriptive purposes only and cannot be understood as indicating or suggesting relative importance Or implicitly indicate the quantity of indicated technical characteristic.Define " first " as a result, the feature of " second " can be expressed or Implicitly include one or more of the features.In the description of the present invention, the meaning of " plurality " is two or more, Unless otherwise specifically defined.
In the present invention unless specifically defined or limited otherwise, term " installation ", " connected ", " connection ", " fixation " etc. Term shall be understood in a broad sense, for example, it may be being fixedly connected, may be a detachable connection, or be integrally connected;It can be machine Tool connection, is also possible to be electrically connected;It can be directly connected, two members can also be can be indirectly connected through an intermediary Connection inside part.For the ordinary skill in the art, above-mentioned term can be understood in this hair as the case may be Concrete meaning in bright.
The method that one kind provided in an embodiment of the present invention orderly communicates, can be applied in distributed system.Referring to Fig. 1 institute Show, this method comprises:
Step 101: obtaining the conversation message that the first client is sent, conversation message includes receiving address and being based on receiving ground The session identification that the unique identification information of location and/or the first client generates.
In the embodiment of the present invention, the first client is transmitting terminal, and the second following clients is receiving end.For example, user A Message is sent to user B, then client used in user A is the first client, and client used in user B is the second client End.Wherein, client (including the first client and the second client) is the equipment with message function is sent, and is specifically as follows Smart phone, tablet computer, PC machine, palm PC etc., the present embodiment does not limit this.
Conversation message in the embodiment of the present invention refers to that the first client and other clients carry out hair when information exchange The message sent.The conversation message further includes the reception address of recipient other than the content comprising message itself, such as second The address of client, and the session identification for selecting link, and different clients corresponds to different session identifications, the meeting Words mark is specifically based on the unique identification information generation for receiving address and/or the first client.
In the embodiment of the present invention, the unique identification information of the first client refers to currently can uniquely characterizing first visitor The information at family end, such as MAC Address, current IP address, the User ID for logging in first client of the first client etc..Meeting Words mark can directly be the unique identification information of the first client, for example session identification is User ID;Session identification can also be with It is identified content after handling the unique identification information of the first client, for example the unique identification information is taken off Identified content after quick processing needs to guarantee that the session identification of different clients is different at this time.Meanwhile it may be based on this It receives address and generates session identification, be correspondingly, to need to guarantee at this time different due to receiving address and the second client Second client corresponds to different session identifications.Specifically, address will can directly be received as session identification, or to reception Address generates session identification after being handled, or other unique identification informations of the second client are determined based on the reception address (such as MAC Address etc.) and session identification is generated according to the unique identification information of the second client.Alternatively, based on address is received With both information of the unique identification information of the first client generate session identification, it is ensured that sender's (the first client) with Session between recipient's (the second client) shares the same session identification, it is also ensured that the serialized transport of message.It can Choosing, it, can be based on the unique identification information of the first client during receiving the conversation message that the first client is sent Generate session identification;During sending conversation message to the second client, session identification can be generated based on address is received.
Step 102: junior corresponding with session identification connecting node being determined according to session identification, and conversation message is sent out It send to junior's connecting node, indicates that junior's connecting node continues transmission session message, until conversation message to be sent to and receive Corresponding second client in address.
During conversation message is sent to the second client by the first client, it can pass through in a distributed system multiple Layer, such as gate layers (gateway), service layers of (service layer), message-oriented middleware etc.;Each layer may have multiple nodes, Therefore there are multiple connecting links when conversation message is sent to next layer from the node of current layer.Pass through session in the embodiment of the present invention Mark is to select specific connecting link, to guarantee the order of message.Specifically, the local node of current layer needs downwards When one layer of downstream site sends conversation message, junior's connecting node in downstream site is selected according to session identification, it will Access between local node and junior's connecting node forwards conversation message as selected connecting link.Due to session Mark is generated based on unique identification information, thereby may be ensured that there is the conversation message of the session identification can also use for other Identical connecting link transmission, so that guaranteeing can be with the order of message.
For example, if the User ID based on the first client generates session identification, if customer end A has sent meeting to customer end A 1 Message a1 is talked about, conversation message a2 is had sent to customer end A 1 again later, since the session identification in two conversation messages is base It is generated in the User ID of customer end A, therefore the connecting link of conversation message a1 and a2 is identical, disappears so as to avoid because of different sessions Breath selects processing speed or local zone time difference in different connecting links and different connecting links with node layer to lead to message Transmission sequence different problems.
The method that one kind provided in an embodiment of the present invention orderly communicates utilizes the session mark generated based on unique identification information Selection connecting link is known, so that the conversation message with same session mark is transmitted along same link, so that passing The process of defeated message is serialization, thereby may be ensured that the order of distributed system messaging.
Optionally, the conversation group that the conversation message is presently in is also based on to determine session identification, such as based on The conversation group that the unique identification information and conversation message of one client are presently in generates the session identification, or based on reception ground The conversation group that location and conversation message are presently in generates the session identification.
" conversation group " in the embodiment of the present invention refers to the session-context based on determined by current interaction side, for example, Customer end A sends a conversation message a1 to customer end A 1, then conversation group locating for the conversation message is customer end A and client The session-context formed between A1;If customer end A sends conversation message a2 or customer end A 1 to client to customer end A 1 again later A is held to send conversation message a3 etc., conversation group locating for conversation message a2 and a3 is identical as conversation group locating for conversation message a1, i.e., Three conversation messages are in the same conversation group.If customer end A has sent a conversation message b1, session to customer end B 1 again Message b1 is in another conversation group.Similar, under group chat environment, multiple client collectively constitutes a conversation group, more A client conversation message sent in group chat environment is in identical conversation group.Based on the current institute of the conversation message The conversation group at place determines session identification, transmission link can be selected as unit of conversation group, selection mode is finer.
On the basis of the above embodiments, conversation message further includes session sequence number, and session Serial No. is based on the first visitor Family end generates sequence number orderly determined by the sequence of conversation message.
In the embodiment of the present invention, the first client generates orderly sequence number when generating conversation message, such as can be by It sequentially generates incremental sequence number according to preset step-length, or generates continuous session sequence number (i.e. step-length is 1).It is continuous to generate For incremental session sequence number, customer end A has continuously transmitted three conversation messages a1, a2, a3, three sessions to customer end A 1 The session sequence number seqId of message can be followed successively by 01,02,03.The node for receiving conversation message passes through the session sequence number It can determine that the first client generates the time sequencing of conversation message, so that whether the sequence for verifying reception conversation message is correct. Wherein, the first client can also be sent to clothes according to the dialogue-based mark selection connecting link of the similar process of above-mentioned steps 102 The node (such as gateway) being engaged in device, at this time it is also ensured that receiving the order of conversation message.
Meanwhile in the embodiment of the present invention can also dialogue-based sequence number determine whether there is information drop-out.Specifically, in step After rapid 101 " obtaining the conversation message that the first client is sent ", this method further include: judge whether there is and session sequence number Adjacent historical session sequence number, the historical session sequence number adjacent with session sequence number if it does not exist, according to session sequence number The first session sequence number of missing is determined with historical session sequence number, and superior connecting node is sent for obtaining and the first meeting The request of the corresponding first message of sequence number is talked about, until getting first message.
In the embodiment of the present invention, the session sequence number of the conversation message received before historical session Serial No., due to Session sequence number is ordered into, when the problem of information drop-out is not present, the session sequence number that is currently received sequentially with The session sequence number that last time receives is adjacent;If non-conterminous, illustrate there are problems that information drop-out, it at this time can be true Fixed lost session sequence number, i.e. the first session sequence number, and the corresponding conversation message of the first session sequence number is obtained from new (i.e. first message).For example, local node gets a conversation message a1, session sequence number seqId for customer end A transmission =01, later again get customer end A transmission another conversation message a3, session sequence number seqId=03, due to 03 with There is also 02 between 01, therefore local node can send the meeting for obtaining that session sequence number is 02 with higher level's connecting node of upper layer The request for talking about message, to guarantee the integrality of message.
Optionally, session sequence number can also be that the suitable of conversation message is generated in same conversation group based on the first client Orderly sequence number determined by sequence, i.e. the session sequence number are sequence numbers orderly in conversation group, and different sessions group is not using Same sequence number.Such as above-mentioned example, if also having sent conversation message b1, conversation message to customer end B 1 after customer end A The session sequence number of b1 can be 101, rather than 03 subsequent 04.Orderly sequence number in dialogue-based group of generation group, can be with Other members's (such as second client) in conversation group are facilitated to detect when receiving message with the presence or absence of loss.Shown in example as above, Customer end A has continuously transmitted three conversation message a1, a2, a3, the session sequence number seqId of three conversation messages to customer end A 1 It can be followed successively by 01,02,03, if customer end A 1 has received only conversation message a1 and a3, can determine that conversation message a2 loses, Customer end A 1 (the second client) can send to the respective nodes of server and obtain the request for losing message at this time.
Specifically, this method further include:
Step A1: what the second client of acquisition was sent is used to obtain second message corresponding with the second session sequence number It requests, missing determined by session sequence number of second the second client of session Serial No. according to the conversation message got Session sequence number.
Step A2: after determining second message, being sent to junior's connecting node for second message, and indicates junior's connection section Point continues to transmit second message, until second message is sent to the second client.
In the embodiment of the present invention, when the request of message is lost in the acquisition that local node gets the transmission of the second client, It can determine second message lost in the second client based on the second session sequence number for including in the request, it at this time can be Second message is obtained in local or superior node, and second message is sent to the second client, to guarantee the second client termination Receive the integrality of message.
Optionally, server is after the conversation message for receiving the transmission of the first client, it will words message is stored to storage Node is stored;When the second client need actively obtain message (such as obtain loss message or acquisition offline message Deng) when, it can the conversation message needed for reading the second client in memory node.It wherein, specifically can also be according to session identification It determines memory node corresponding with session identification, facilitates subsequent quick search.
On the basis of the above embodiments, after step 101 " conversation message for obtaining the transmission of the first client ", the party Method further include: add global sequence number for conversation message, global sequence number is is determined based on the sequence for receiving conversation message Orderly sequence number.
In the embodiment of the present invention, when receiving conversation message, the time that conversation message can be received based on node is suitable Sequence determines unique orderly global sequence number.Specifically, global sequence msgId can use snowflake realization, reason It is about 409.6w/s by the QPS (Query Per Second, query rate per second) of upper snowflake scheme, this method of salary distribution It can guarantee in office in any machine of any one IDC (Internet Data Center, Internet data center) The msgId generated in meaning millisecond is different, and temporally trend is incremented by the msgId of all generations, and entire distributed system It is interior to generate duplicate Id (because thering is datacenterId and workerId to distinguish).
Client is facilitated to pull message data based on the global sequence number.Specifically, described conversation message to be sent to After junior's connecting node, this method further include:
Step B1: obtaining the offline message acquisition request that the second client is sent, and offline message acquisition request includes second The current global sequence number of client.
Step B2: the offline message that the second client does not receive is determined according to current global sequence number, and will be disappeared offline Breath is sent to the second client.
When the second client of user needs to obtain offline message (such as conversation message loss being locally stored etc.), the Two clients can send offline message acquisition request, which includes the current overall situation of second client Sequence number;If global sequence number is ordered into incremental, which is the maximum of currently stored conversation message Global sequence number.Server, which is based on the current global sequence number, can determine which conversation message is the second client need to obtain, And determining conversation message (i.e. offline message) is fed back into the second client.Second client can be with one by global sequence number Secondary property obtains required all offline messages, and pulling data is high-efficient.
It should be noted that the first client and the second client in the present embodiment are only intended to distinguish transmitting terminal and connect Receiving end, due in actual scene, client is either transmitting terminal, be also possible to receiving end, i.e., some client both can be with It is the first client, the second client being also possible in other conversation procedures.
The method flow orderly communicated is described in detail below by one embodiment.
In the embodiment of the present invention, distributed system is reduced to two-layer node, i.e. first node layer and second node layer, base Guarantee that message is not lost orderly in the session identification and session sequence number of conversation message.It is shown in Figure 2, this method comprises:
Step 201: the first client sends conversation message to first node, which includes receiving address, session Mark and session sequence number.
Step 202: first node determines corresponding transmission link according to the session identification, and determines that the transmission link is corresponding Next layer of second node.
Wherein, second node is a node in second node layer.In first node after receiving conversation message, the The case where one node can judge whether there is information drop-out with dialogue-based sequence number.
Step 203: first node stores the conversation message to memory node.
In the embodiment of the present invention, illustrate so that first node can store conversation message as an example.If first node and storage save There is no communication between point, then first node is only needed session messaging to junior's connecting node, until subsequent Junior's connecting node can store conversation message into memory node.
Step 204: the conversation message is sent to second node by first node.
Step 205: the conversation message is sent to the second client according to the reception address in conversation message by second node.
In the embodiment of the present invention, since next layer of second node is exactly the second client, therefore second node does not need to select Connecting link is selected, conversation message is directly sent to the second client.
Step 206: the second client receives conversation message, and according to the session sequence number in conversation message and before The historical session sequence number of the conversation message received judges whether session sequence number is continuous.
If session sequence number is discontinuous, illustrate there are problems that information drop-out, i.e. the message that the second client receives is not Completely.
Step 207: when there is information drop-out, the second client, which sends to obtain to second node, loses asking for message It asks.
Step 208: second node obtains message lost in the second client from memory node.
Step 209: the message that the second client is lost is sent to the second client by second node.
On the basis of the above embodiments, shown in Figure 3, step 102 is " according to session identification determination and session identification phase Corresponding junior's connecting node " specifically includes step 1021-1022:
Step 1021: according to session identification generate with the unique corresponding ident value of conversation message, and determine present node and The sum of link between downstream site.
It in the embodiment of the present invention, quantizes to session identification, generates unique corresponding ident value.Specifically, can will The hash value of mark is talked about as corresponding ident value;Other modes can also be used and determine that ident value, the present embodiment do not do this It limits.
Step 1022: modulo operation is carried out as divisor using the ident value of conversation message as the sum of dividend, link, Using link corresponding with the remainder after modulo operation as active link, and using downstream site pointed by active link as Junior's connecting node of present node.
In the embodiment of the present invention, which link the remainder after can use modulo operation selects as active link.Than Such as, local node and next layer of 10 nodes have connection relationship, if remainder is 2 at this time, can be used as active chain for the 2nd article Road;If remainder is 0, can be using the 10th article of link as active link.Due to the link between local node and downstream site Sum is determining, and the ident value of conversation message also has the characteristics that certain random distribution, more than after modulo operation Number can distribute connecting link to determine active link relatively uniformly, can be excessive to avoid certain link load.
Simultaneously as distributed system includes multilayer, select to can be used when active link between each layer above-mentioned Mode determines which link is active link, or selects which downstream site as junior's connecting node.Below with reference to point The cloth system specifics method flow provided in an embodiment of the present invention orderly communicated.
In the embodiment of the present invention, customer end A sends conversation message a1 to customer end A 1, and customer end B is sent to customer end B 1 Conversation message b1, client C send conversation message c1 to client C1.It is shown in Figure 4, firstly, IM customer end A, B, C difference Conversation message a1, a2, a3 are sent to the gate layer of server-side, wherein conversation message a1 and b1 has been sent to gate layers of a section Point (i.e. gate layer 1), conversation message c1 have been sent to another node (i.e. gate layer 2).Wherein, customer end A, B, C are added respectively The message SN of conversation message.For example, customer end A adds session sequence number seqId=1, customer end B adds session sequence number SeqId=11, client C add session sequence number seqId=101, and generating message every time later all can be in respective client Sequence number is incremented by one by one.
Conversation message when being sent to gate layers of customer end A, B, C, the gate layers of any one service of client and server-side Device generates the long connection of a TCP, and the server for receiving conversation message can generate global sequence number for the conversation message MsgId, and be added in message body.Assuming that reaching the sequence of gate layers of message is: the message a1 that customer end A is sent is arrived first, visitor The message b1 that family B is sent is reached again, and the message c1 that client C is sent finally is reached.The global sequence number that server-side generates message It is respectively: adds msgId=1 for the message a1 of customer end A, the message b1 of customer end B adds msgId=2, and client C's disappears It ceases c1 and adds msgId=3, receive message later and be also incremented by one by one.The conversation message for later sending customer end A, B, C is from gate Layer is transmitted to next layer, i.e. and service layers.Wherein, tcp long connection is saved by connection pool gate layers and service layers.Client It holds the conversation message sent after gate layers, generates one by session identification (such as the information such as user Id) by gate layers Hash value, and corresponding some spy for being routed to a service connection pool is selected according to remainder with after the hash value modulus In fixed connection, conversation message is sent to message-oriented middleware layer service layers later.With the selection of gate layer 1 in Fig. 4 Service layer 1, gate layer 2 have selected for service layer 2.
Meanwhile message-oriented middleware layer presses fragment storage, service layer similarly according to passing through the information such as session identification The hash value of user is obtained, and selects a fragment to send data according to remainder after modulus.As shown in figure 4, customer end A, visitor The conversation message a1 and b1 of family end B reaches message-oriented middleware layer fragment 1, and the conversation message c1 of client C is reached in message Between part layer fragment 2.The conversation message that later customer end A, customer end B are sent can all reach fragment 1, the session that client C is sent Message reaches message-oriented middleware fragment 2, and the message sequence that such customer end A, the message of B, C are just received according to server-side is serial Change into message-oriented middleware.
Meanwhile service layers also need to store conversation message into database.The Service layers of multiple databases of connection, Service layers can be with switching at runtime database.Each service layers is also to be connected by connection pool with data storage fragment, because This is in order to guarantee succession, and service layers can also be by the hash value of the acquisition of information user such as Id of user, basis after modulus Remainder selects a data storage fragment connection, guarantees that after the message an of client reaches server-side be also ordered serial in this way Change, it is ensured that customer end A, the data of B, C are stored in different databases.Such as customer end A, the message of B are stored in Data store in fragment 1, and the data of client C are stored in data storage fragment 2.Later customer end A, customer end B are sent Message can all store data storage fragment 1 in sequence, and the message that client C is sent reaches data storage fragment in sequence 2。
Later, need for conversation message to be sent to corresponding second client.At this point, service layers from orderly message Message is pulled in middleware and is pushed to the second client, and message can carry out hash modulus, so according to address is received when pushing Remainder selects link afterwards, can equally guarantee that the message channel at message sink end is also serialization in this way, to guarantee to connect Receiving end can also be sequentially received message.After message reaches gate layer (such as gate layers 3, gate layer 4), gate layers with it is any one There was only a tcp long connection between a receiving end (customer end A 1, B1, C1), therefore the connection that customer end A 1, B1, C1 use is logical Road is that respective independence is different, continues to ensure that message reaches receiving end in this way to be also serialization.
After customer end A 1, B1, C1 receive message, can by transmitting terminal generate seqId value whether continuously perceive whether Lose message.If losing message, it can again attempt to pull, can guarantee that message is not lost in transmission process in this way.
The method that one kind provided in an embodiment of the present invention orderly communicates utilizes the session mark generated based on unique identification information Selection connecting link is known, so that the conversation message with same session mark is transmitted along same link, so that passing The process of defeated message is serialization, thereby may be ensured that the order of distributed system messaging.Based on orderly session Sequence number, server and receiving end can check for the problem of information drop-out, thereby may be ensured that the complete of message Whole property is effectively ensured message and does not lose in consumption.Memory node corresponding with session identification, side are determined according to session identification Continue quick search after an action of the bowels;Client is facilitated quickly to pull message data based on global sequence number, pulling data is high-efficient.
The method flow orderly communicated is described in detail above, this method can also be realized by corresponding device, below The structure and function of the device is discussed in detail.
The device that one kind provided in an embodiment of the present invention orderly communicates, it is shown in Figure 5, comprising:
Message capturing module 51, for obtaining the conversation message of the first client transmission, the conversation message includes receiving The session identification of address and the unique identification information generation based on the reception address and/or first client;
Processing module 52, for determining junior's connection section corresponding with the session identification according to the session identification Point, and the conversation message is sent to junior's connecting node, indicate that junior's connecting node continues to transmit the meeting Message is talked about, until the conversation message is sent to the second client corresponding with the reception address.
On the basis of the above embodiments, the conversation message further includes session sequence number, the session Serial No. base Sequence number orderly determined by the sequence of conversation message is generated in the first client;It is shown in Figure 6, the device further include: Judgment module 53;
After the conversation message that the message capturing module 51 obtains that the first client is sent, the judgment module 53 is used In judging whether there is the historical session sequence number adjacent with the session sequence number, if it does not exist with the session sequence number phase Adjacent historical session sequence number determines the first session sequence of missing according to the session sequence number and historical session sequence number Number, and superior connecting node sends the request for obtaining first message corresponding with the first session sequence number, directly To getting the first message.
On the basis of the above embodiments, the conversation message further includes session sequence number, the session Serial No. base Sequence number orderly determined by the sequence of conversation message is generated in same conversation group in the first client;It is shown in Figure 6, The device further include: the first request module 54;
After conversation message is sent to junior's connecting node by the processing module 52, first request Module 54 is used to obtain the request for being used to obtain second message corresponding with the second session sequence number of the second client transmission, Second client described in the second session Serial No. is according to determined by the session sequence number of the conversation message got The session sequence number of missing;
After determining the second message, the second message is sent to junior's connection section by the processing module 52 Point, and indicate that junior's connecting node continues to transmit the second message, until the second message is sent to described the Two clients.
On the basis of the above embodiments, shown in Figure 7, the processing module 52 includes:
Pretreatment unit 521, for according to the session identification generate with the unique corresponding ident value of the conversation message, And determine the sum of the link between present node and downstream site;
Link determination unit 522, for making the ident value of the conversation message as the sum of dividend, the link Modulo operation is carried out for divisor, using link corresponding with the remainder after modulo operation as active link, and will be described effective Junior connecting node of the downstream site pointed by link as present node.
On the basis of the above embodiments, shown in Figure 6, which further includes sequence number adding module 55;
After the conversation message that the message capturing module 51 obtains that the first client is sent, the sequence number adds mould Block 55 is used to add global sequence number for the conversation message, and the global sequence number is based on the sequence for receiving conversation message Identified orderly sequence number.
On the basis of the above embodiments, shown in Figure 6, the device further include: the second request module 56;
After the conversation message is sent to junior's connecting node by the processing module 52, second request The offline message acquisition request that module 56 is used to obtain the transmission of the second client is obtained, the offline message acquisition request includes institute State the current global sequence number of the second client;
The processing module 52 is also used to determine that second client does not receive according to the current global sequence number Offline message, and the offline message is sent to second client.
On the basis of the above embodiments, shown in Figure 6, which further includes memory module 57;
After the conversation message that the message capturing module 51 obtains that the first client is sent, the memory module 57 is used In determining corresponding with session identification memory node according to the session identification, and the conversation message is sent to institute Memory node is stated to be stored.
The device that one kind provided in an embodiment of the present invention orderly communicates utilizes the session mark generated based on unique identification information Selection connecting link is known, so that the conversation message with same session mark is transmitted along same link, so that passing The process of defeated message is serialization, thereby may be ensured that the order of distributed system messaging.Based on orderly session Sequence number, server and receiving end can check for the problem of information drop-out, thereby may be ensured that the complete of message Whole property is effectively ensured message and does not lose in consumption.Memory node corresponding with session identification, side are determined according to session identification Continue quick search after an action of the bowels;Client is facilitated quickly to pull message data based on global sequence number, pulling data is high-efficient.
The embodiment of the invention also provides a kind of storage medium, the storage medium is stored with computer executable instructions, It includes the program for executing the above-mentioned method orderly communicated, which can be performed above-mentioned any means Method in embodiment.
Wherein, the storage medium can be any usable medium or data storage device that computer can access, packet Include but be not limited to magnetic storage (such as floppy disk, hard disk, tape, magneto-optic disk (MO) etc.), optical memory (such as CD, DVD, BD, HVD etc.) and semiconductor memory (such as it is ROM, EPROM, EEPROM, nonvolatile memory (NAND FLASH), solid State hard disk (SSD)) etc..
Fig. 8 shows the structural block diagram of a kind of electronic equipment of another embodiment of the invention.The electronic equipment 1100 can be the host server for having computing capability, personal computer PC or portable portable computer or end End etc..The specific embodiment of the invention does not limit the specific implementation of electronic equipment.
The electronic equipment 1100 includes at least one processor (processor) 1110, communication interface (Communications Interface) 1120, memory (memory array) 1130 and bus 1140.Wherein, processor 1110, communication interface 1120 and memory 1130 complete mutual communication by bus 1140.
Communication interface 1120 with network element for communicating, and wherein network element includes such as Virtual Machine Manager center, shared storage.
Processor 1110 is for executing program.Processor 1110 may be a central processor CPU or dedicated collection At circuit ASIC (Application Specific Integrated Circuit), or it is arranged to implement the present invention One or more integrated circuits of embodiment.
Memory 1130 is for executable instruction.Memory 1130 may include high speed RAM memory, it is also possible to also wrap Include nonvolatile memory (non-volatile memory), for example, at least a magnetic disk storage.Memory 1130 can also be with It is memory array.Memory 1130 is also possible to by piecemeal, and described piece can be combined into virtual volume by certain rule.Storage The instruction that device 1130 stores can be executed by processor 1110, so that processor 1110 is able to carry out in above-mentioned any means embodiment The method orderly communicated.
The above description is merely a specific embodiment, but scope of protection of the present invention is not limited thereto, any Those familiar with the art in the technical scope disclosed by the present invention, can easily think of the change or the replacement, and should all contain Lid is within protection 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. the method that one kind orderly communicates characterized by comprising
The conversation message of the first client transmission is obtained, the conversation message includes receiving address and based on the reception address And/or the session identification that the unique identification information of first client generates;
Junior corresponding with session identification connecting node is determined according to the session identification, and the conversation message is sent out It send to junior's connecting node, indicates that junior's connecting node continues to transmit the conversation message, until by the session Message is sent to the second client corresponding with the reception address.
2. the method according to claim 1, wherein the conversation message further includes session sequence number, the meeting It talks about Serial No. and generates sequence number orderly determined by the sequence of conversation message based on the first client;
After the conversation message that the first client of the acquisition is sent, this method further include:
Judge whether there is the historical session sequence number adjacent with the session sequence number, if it does not exist with the session sequence number Adjacent historical session sequence number determines the first session sequence of missing according to the session sequence number and historical session sequence number Number, and superior connecting node sends the request for obtaining first message corresponding with the first session sequence number, directly To getting the first message.
3. the method according to claim 1, wherein the conversation message further includes session sequence number, the meeting Words Serial No. generates sequence number orderly determined by the sequence of conversation message based on the first client in same conversation group;
After the conversation message is sent to junior's connecting node, this method further include:
Obtain the transmission of the second client for obtaining the request of second message corresponding with the second session sequence number, described the It is lacked determined by session sequence number of second client described in two session Serial No. according to the conversation message got Session sequence number;
After determining the second message, the second message is sent to junior's connecting node, and indicate the junior Connecting node continues to transmit the second message, until the second message is sent to second client.
4. the method according to claim 1, wherein described according to session identification determination and the session mark Sensible corresponding junior's connecting node includes:
It is generated and the conversation message uniquely corresponding ident value, and determining present node and junior's section according to the session identification The sum of link between point;
Modulo operation is carried out as divisor using the ident value of the conversation message as the sum of dividend, the link, it will be with The corresponding link of remainder after modulo operation as active link, and using downstream site pointed by the active link as Junior's connecting node of present node.
5. the method according to claim 1, wherein it is described acquisition the first client send conversation message it Afterwards, further includes:
Global sequence number is added for the conversation message, the global sequence number is true based on the sequence institute for receiving conversation message Fixed orderly sequence number.
6. according to the method described in claim 5, it is characterized in that, the conversation message is sent to the lower cascade described After connecing node, further includes:
The offline message acquisition request of the second client transmission is obtained, the offline message acquisition request includes second client The current global sequence number at end;
The offline message that second client does not receive is determined according to the current global sequence number, and is disappeared described offline Breath is sent to second client.
7. the method according to claim 1, wherein it is described acquisition the first client send conversation message it Afterwards, further includes:
Memory node corresponding with the session identification is determined according to the session identification, and the conversation message is sent to The memory node is stored.
8. the device that one kind orderly communicates characterized by comprising
Message capturing module, for obtain the first client transmission conversation message, the conversation message include receive address and The session identification that unique identification information based on the reception address and/or first client generates;
Processing module, for determining junior corresponding with session identification connecting node according to the session identification, and will The conversation message is sent to junior's connecting node, indicates that junior's connecting node continues to transmit the conversation message, Until the conversation message is sent to the second client corresponding with the reception address.
9. a kind of storage medium, which is characterized in that the storage medium is stored with computer executable instructions, and the computer can It executes instruction and requires the method orderly communicated described in 1-7 any one for perform claim.
10. a kind of electronic equipment characterized by comprising
At least one processor;And
The memory being connect at least one described processor communication;Wherein,
The memory is stored with the instruction that can be executed by least one described processor, and described instruction is by described at least one It manages device to execute, so that at least one described processor is able to carry out the side orderly communicated described in claim 1-7 any one Method.
CN201811438050.2A 2018-11-27 2018-11-27 A kind of method, apparatus orderly communicated, storage medium and electronic equipment Pending CN109600302A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811438050.2A CN109600302A (en) 2018-11-27 2018-11-27 A kind of method, apparatus orderly communicated, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811438050.2A CN109600302A (en) 2018-11-27 2018-11-27 A kind of method, apparatus orderly communicated, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN109600302A true CN109600302A (en) 2019-04-09

Family

ID=65960551

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811438050.2A Pending CN109600302A (en) 2018-11-27 2018-11-27 A kind of method, apparatus orderly communicated, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN109600302A (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110620699A (en) * 2019-08-02 2019-12-27 北京字节跳动网络技术有限公司 Message arrival rate determination method, device, equipment and computer readable storage medium
CN110839084A (en) * 2019-11-19 2020-02-25 中国建设银行股份有限公司 Session management method, device, equipment and medium
CN111045823A (en) * 2019-12-11 2020-04-21 上海智臻智能网络科技股份有限公司 Context data load distribution method, device, equipment and storage medium
CN112492048A (en) * 2020-12-14 2021-03-12 招商局金融科技有限公司 Message synchronization method and device, electronic equipment and readable storage medium
CN114095465A (en) * 2021-11-17 2022-02-25 北京同城必应科技有限公司 Method for realizing efficient IM message time sequence guarantee mechanism under distributed environment
CN115484563A (en) * 2021-06-16 2022-12-16 中国移动通信有限公司研究院 Session processing method, device, equipment and readable storage medium
WO2024032094A1 (en) * 2022-08-12 2024-02-15 深圳市星卡软件技术开发有限公司 Instant messaging system and method

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101415128A (en) * 2008-11-07 2009-04-22 华为技术有限公司 Method, apparatus for sharing signaling message load, and signaling transmission system
CN102668516A (en) * 2011-12-02 2012-09-12 华为技术有限公司 Method and apparatus for realizing message passing amid cloud information service
CN103051520A (en) * 2013-01-05 2013-04-17 北京小米科技有限责任公司 Method and device for synchronizing offline session messages in instant messaging tool
CN108810116A (en) * 2018-05-29 2018-11-13 Oppo广东移动通信有限公司 Message treatment method and Related product

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101415128A (en) * 2008-11-07 2009-04-22 华为技术有限公司 Method, apparatus for sharing signaling message load, and signaling transmission system
CN102668516A (en) * 2011-12-02 2012-09-12 华为技术有限公司 Method and apparatus for realizing message passing amid cloud information service
CN103051520A (en) * 2013-01-05 2013-04-17 北京小米科技有限责任公司 Method and device for synchronizing offline session messages in instant messaging tool
CN108810116A (en) * 2018-05-29 2018-11-13 Oppo广东移动通信有限公司 Message treatment method and Related product

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110620699A (en) * 2019-08-02 2019-12-27 北京字节跳动网络技术有限公司 Message arrival rate determination method, device, equipment and computer readable storage medium
CN110839084A (en) * 2019-11-19 2020-02-25 中国建设银行股份有限公司 Session management method, device, equipment and medium
CN110839084B (en) * 2019-11-19 2022-04-05 中国建设银行股份有限公司 Session management method, device, equipment and medium
CN111045823A (en) * 2019-12-11 2020-04-21 上海智臻智能网络科技股份有限公司 Context data load distribution method, device, equipment and storage medium
CN112492048A (en) * 2020-12-14 2021-03-12 招商局金融科技有限公司 Message synchronization method and device, electronic equipment and readable storage medium
CN115484563A (en) * 2021-06-16 2022-12-16 中国移动通信有限公司研究院 Session processing method, device, equipment and readable storage medium
CN115484563B (en) * 2021-06-16 2024-06-25 中国移动通信有限公司研究院 Session processing method, device, equipment and readable storage medium
CN114095465A (en) * 2021-11-17 2022-02-25 北京同城必应科技有限公司 Method for realizing efficient IM message time sequence guarantee mechanism under distributed environment
WO2024032094A1 (en) * 2022-08-12 2024-02-15 深圳市星卡软件技术开发有限公司 Instant messaging system and method

Similar Documents

Publication Publication Date Title
CN109600302A (en) A kind of method, apparatus orderly communicated, storage medium and electronic equipment
CN109949111B (en) Electronic bill identification distribution method, electronic bill generation method, device and system
CN106375404B (en) Data storage control method, date storage method, data capture method and device
US9392081B2 (en) Method and device for sending requests
US8903972B2 (en) Method and apparatus for sharing contents using information of group change in content oriented network environment
CN115004673B (en) Message pushing method, device, electronic equipment and computer readable medium
CN106850710A (en) A kind of safe data cloud storage system, client terminal, storage server and application process
CN108123866B (en) Method for message transmission and device
CN105610632A (en) Virtual network device and related method
US9621412B2 (en) Method for guaranteeing service continuity in a telecommunication network and system thereof
CN108347350B (en) Communication method and device
CN110162270A (en) Date storage method, memory node and medium based on distributed memory system
CN107196848B (en) Information push method and device
CN112954406B (en) Data downloading method and device, computer equipment and storage medium
US10802896B2 (en) Rest gateway for messaging
CN114185582A (en) Automobile software online upgrading system and method based on QUIC protocol
CN108965359B (en) Communication method, communication device, readable medium, and electronic apparatus
CN110855424B (en) Method and device for synthesizing asymmetric flow xDR in DPI field
CN109982034A (en) Access request processing method and processing device in video monitoring system
CN115277539A (en) Data transmission method, routing cluster and edge node
WO2021027842A1 (en) Method, device and system for implementing edge computing
CN111404842B (en) Data transmission method, device and computer storage medium
CN108011801A (en) Method, unit and the system of data transfer
CN113966602A (en) Distributed storage of blocks in a blockchain
CN110011909A (en) Store gateway and storage gateway data sending, receiving method and device

Legal Events

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

Application publication date: 20190409

RJ01 Rejection of invention patent application after publication