CN106209996A - Communication processing method and device - Google Patents
Communication processing method and device Download PDFInfo
- Publication number
- CN106209996A CN106209996A CN201610505084.3A CN201610505084A CN106209996A CN 106209996 A CN106209996 A CN 106209996A CN 201610505084 A CN201610505084 A CN 201610505084A CN 106209996 A CN106209996 A CN 106209996A
- Authority
- CN
- China
- Prior art keywords
- thread
- node
- communication
- agent
- instance
- 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
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/14—Session management
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer And Data Communications (AREA)
Abstract
The invention discloses a kind of communication processing method and device.Wherein, the method includes: create one or more communication thread in node, and wherein, this communication thread is for communicating with the thread in peer node, and this communication thread includes at least one of: service end thread, client thread;By in these one or more communication thread at least one between this node and this peer node, carry out inter-thread communication.The present invention solves communications framework of the prior art and does not support that the communication between thread can make the technical problem processing underaction of communication, and the process making communication is more flexible.
Description
Technical field
The present invention relates to data processing field, in particular to a kind of communication processing method and device.
Background technology
The core of distributed system is distributed communication, is introduced existing distributed communication framework below, is being situated between
Continue before distributed communication framework, first Distributed Communication Protocol is illustrated.
Present Distributed Communication Protocol substantially has four types: the first, communication based on TCP/IP;The second, base
Communication protocol (RPC, CORBA, RMI) in object;The third, communication protocol based on Http+xml (Web Service);The
Four kinds, communication protocol (RESTful) based on Http.
In these communication protocols, RPC can exist distributed in the prior art based on HTTP or Transmission Control Protocol based on RPC
Communications framework, such as, ZeroRPC, this framework distributed communication based on ZeroMQ and MessagePack framework.This communication frame
Frame has a characteristic that speed is fast, and response time is short, the highest, across language, is RPC frame the most outstanding in distributed communication
Frame.
Inventor finds, in the prior art, and the communication between the minimum support process of various communications frameworks.Such as, exist
In ZeroRPC framework, although this framework is a high-performance, supports the communications framework between striding course on TCP based on ZeroMQ,
But communicate between the cross-thread do not supported.If not supporting that the communication between thread can make the process underaction of communication.
For above-mentioned problem, effective solution is the most not yet proposed.
Summary of the invention
Embodiments provide a kind of communication processing method and device, at least to solve communication frame of the prior art
Frame does not support that the communication between thread can make the technical problem processing underaction of communication.
An aspect according to embodiments of the present invention, it is provided that a kind of communication processing method, including: create one in node
Individual or multiple communication thread, wherein, described communication thread is used for communicating with the thread in peer node, described communication thread
Including at least one of: service end thread, client thread;By in the one or more communication thread at least one
Inter-thread communication is carried out between described node and described peer node.
Further, described node creates the one or more communication thread to include;Described node passes through
The instance of agent arranged creates the one or more communication thread;By in the one or more communication thread at least it
One carries out inter-thread communication between described node and described peer node: described instance of agent uses the one or more to lead to
Letter thread at least one between described node and described peer node, carry out inter-thread communication.
Further, during described instance of agent uses the one or more communication thread at least one at described node
And carrying out inter-thread communication between described peer node: described instance of agent is by the one or more communication thread
At least one message be sent to described peer node;Described instance of agent will be from described peer node according to thread identifier
Message be routed in described node correspondence thread.
Further, before described instance of agent creates the one or more communication thread, described method also includes:
Instance of agent described in information creating according to described node in described node;Described instance of agent is according to described peer node
Peer node described in information registering.
Further, the information of described node includes at least one of: the identification information of described node, described node
IP address, the port of described node;And/or, the information of described peer node includes at least one of: described peer node
Identification information, the IP address of described peer node, the port of described peer node.
Further, carried out between described node and described peer node by the one or more communication thread
After communication, described method also includes: described instance of agent closes the communication thread of sign off;And/or, in one
Or after the communication of all communication thread in multiple communication thread terminates the most, described instance of agent is nullified described to end segment
Point.
Further, after described instance of agent nullifies described peer node, described method also includes: at described node
Close described instance of agent.
Another aspect according to embodiments of the present invention, additionally provides a kind of communication processing apparatus, is positioned in node, bag
Including: creation module, be used for creating one or more communication thread, wherein, described communication thread is used for and the line in peer node
Journey communicates, and described communication thread includes at least one of: service end thread, client thread;Communication module, is used for leading to
Cross in the one or more communication thread at least one carry out between described node and described peer node cross-thread lead to
Letter.
Further, described creation module and described communication module, it is positioned in instance of agent.
Further, described communication module includes: transmitting element, for will be from the one or more communication thread
At least one message be sent to described peer node;And/or, receive unit, being used for will be from institute according to thread identifier
The message stating peer node is routed in described node the thread of correspondence.
Further, described creation module, for according to instance of agent described in the information creating of described node;Described device
Also include: Registering modules, be positioned in described instance of agent, for according to described in the information registering of described peer node to end segment
Point.
Further, the information of described node includes at least one of: the identification information of described node, described node
IP address, the port of described node;And/or, the information of described peer node includes at least one of: described peer node
Identification information, the IP address of described peer node, the port of described peer node.
Further, described device also includes: thread closes module, is positioned in described instance of agent, the most logical for closing
The thread that letter terminates;And/or, cancellation module, it is positioned in described instance of agent individual, in the one or more communication thread
In the communication of all communication thread the most terminate after, nullify described peer node.
Further, described device also includes: instance of agent closes module, described right for nullifying at described cancellation module
After end node, close described instance of agent.
In embodiments of the present invention, employing creates one or more communication thread, wherein, described communication thread in node
For communicating with the thread in peer node, described communication thread includes at least one of: service end thread, client
Thread;By in the one or more communication thread at least one between described node and described peer node, carry out line
Communicate between journey.Solve communications framework of the prior art by the embodiment of the present invention and do not support that the communication between thread can make to lead to
The technical problem processing underaction of letter, the process making communication is more flexible.
Accompanying drawing explanation
Accompanying drawing described herein is used for providing a further understanding of the present invention, constitutes the part of the application, this
Bright schematic description and description is used for explaining the present invention, is not intended that inappropriate limitation of the present invention.In the accompanying drawings:
Fig. 1 is the flow chart of communication processing method according to embodiments of the present invention;
Fig. 2 is the structured flowchart of communication processing apparatus according to embodiments of the present invention;
Fig. 3 is the structured flowchart of communication processing apparatus according to embodiments of the present invention;
Fig. 4 is received server-side client's request processing flow figure according to embodiments of the present invention;
Fig. 5 is client request processing flow figure according to embodiments of the present invention;
Fig. 6 is the overall architecture schematic diagram according to alternative embodiment of the present invention;
Fig. 7 is each module communication data flow diagram according to embodiments of the present invention;And,
Fig. 8 is the ZeroMQ transmission mode schematic diagram that communications framework according to embodiments of the present invention is used.
Detailed description of the invention
In order to make those skilled in the art be more fully understood that the present invention program, below in conjunction with in the embodiment of the present invention
Accompanying drawing, is clearly and completely described the technical scheme in the embodiment of the present invention, it is clear that described embodiment is only
The embodiment of a present invention part rather than whole embodiments.Based on the embodiment in the present invention, ordinary skill people
The every other embodiment that member is obtained under not making creative work premise, all should belong to the model of present invention protection
Enclose.
It should be noted that term " first " in description and claims of this specification and above-mentioned accompanying drawing, "
Two " it is etc. for distinguishing similar object, without being used for describing specific order or precedence.Should be appreciated that so use
Data can exchange in the appropriate case, in order to embodiments of the invention described herein can with except here diagram or
Order beyond those described is implemented.Additionally, term " includes " and " having " and their any deformation, it is intended that cover
Cover non-exclusive comprising, such as, contain series of steps or the process of unit, method, system, product or equipment are not necessarily limited to
Those steps clearly listed or unit, but can include the most clearly listing or for these processes, method, product
Or intrinsic other step of equipment or unit.
According to embodiments of the present invention, it is provided that the embodiment of a kind of communication processing method, it should be noted that at accompanying drawing
Step shown in flow chart can perform in the computer system of such as one group of computer executable instructions, and, although
Flow chart shows logical order, but in some cases, can perform shown with the order being different from herein or retouch
The step stated.
Providing a kind of communication processing method in the present embodiment, Fig. 1 is communication process side according to embodiments of the present invention
The flow chart of method, as it is shown in figure 1, this flow process comprises the steps:
Step S102, creates one or more communication thread in node, wherein, communication thread for in peer node
Thread communicate.In the case of using client and service end communication pattern, the communication thread of establishment can include with
At least one lower: service end thread, client thread.By described step, can be as desired to create in a node
Multiple communication process, so can accomplish that a node not only serves as service end but also serve as client, such that it is able to make the place of communication
Manage more flexible.Here node can be understood as the node of a physical entity, it is understood that for be one in logic
Node, any logic that can generate multithreading or physical entity can be referred to as node.
Step S104, by create one or more communication thread at least one between node and peer node
Carry out inter-thread communication.
Peer node can also use the processing mode that the thread in above-mentioned steps S102 communicates, so this node and opposite end
Node can be carried out the communication of cross-thread.Certainly, peer node can also use other mode to realize and this node
Thread communication, the most do not limit the communication mode of the thread that peer node is used.
The thread communicated can be created in node by above-mentioned steps, it is achieved thereby that the communication of cross-thread.On
The method of stating may apply in various communications framework, so that various communications framework can support the communication of cross-thread.Certainly, on
The step stated can also be applied in other communication process, and it is a kind of than preferably processing mode for being applied in communications framework.
Owing to a node can create multiple communication thread, in order to preferably manage these communication thread, Ke Yishe
Put an instance of agent (Agent example), by this instance of agent, communication thread is managed.It is of course also possible to do not make
Use this instance of agent, as long as creating that thread communication just can solve can not be asking that cross-thread communicates in prior art
Topic.
Communication below in conjunction with an optional embodiment cross-thread to using Agent example illustrates.
One or more communication thread above can be triggered by instance of agent and generate.Then this instance of agent makes
In these communication thread at least one between node and peer node, carry out inter-thread communication.Can be made by instance of agent
The communication of communication thread and generation obtain a preferable management, are architecturally more favorable for using.
In another optional embodiment, instance of agent not only can generate thread, and the management to thread,
Reception message between thread and/or transmission message can also be processed.If employing instance of agent, then Ke Yiyou
Instance of agent by from these communication thread at least one message be sent to peer node, receive message when,
According to thread identifier, the message from peer node can also be routed in this node the thread of correspondence by instance of agent.Logical
Crossing each instance of agent to control the transmission of message, being more prone to of also making that the transmitting-receiving of message becomes controls, and, owing to being logical
Cross what instance of agent was carried out, shield the process between communication process on upper strata, thus the most advantageously in developing.
In another optional embodiment, instance of agent can also have more function, and such as, instance of agent is permissible
Information according to peer node registers peer node in this node, and the now establishment of instance of agent also can be according to node
Information produces.The information of node can have a lot of type, and the information of peer node can also have a lot of type, such as, joint
The information of point can include at least one of: the identification information of node, the IP address of node, the port of node;And/or, right
The information of end node can include at least one of: the identification information of peer node, the IP address of peer node, peer node
Port.
After solving the communication between thread, the closedown for the thread of communication can be entered based on communications framework
OK, it is also possible to be controlled by other mode.
In an optional embodiment, it is provided that the closedown to thread, for example, it is also possible to closed by instance of agent
The thread of sign off;And/or, the communication of all communication thread in one or more communication thread has terminated it the most
After, this instance of agent can also nullify peer node.By which, additionally provide the process of the thread to sign off.This
This optional embodiment of sample is after being applied in communications framework, it is also possible to control the closedown of thread very easily.As more
Excellent embodiment, node can also close instance of agent.The resource of node can be saved in this way, such that it is able to enter
Other process of row.
Additionally providing a kind of communication processing apparatus in the present embodiment, the modules in this communication processing apparatus corresponds to
Step in above-described embodiment and optional embodiment, had carried out the most just repeating no more of explanation.
Fig. 2 is the structured flowchart of communication processing apparatus according to embodiments of the present invention, and this device is positioned in node, such as Fig. 2
Shown in, this device includes:
Creation module 22, is used for creating one or more communication thread, wherein, communication thread for in peer node
Thread communicates, and communication thread includes at least one of: service end thread, client thread;
Communication module 24, for by one or more communication thread at least one between node and peer node
Carry out inter-thread communication.
The thread communicated can be created in node by above-mentioned module, it is achieved thereby that the communication of cross-thread.On
The method of stating may apply in various communications framework, so that various communications framework can support the communication of cross-thread.Certainly, on
The module stated can also be applied in other communication process, and it is a kind of than preferably processing mode for being applied in communications framework.
As an optional embodiment, creation module 22, it is positioned in instance of agent, is used for creating one or more leading to
Letter thread;Communication module 24 is positioned in instance of agent.
As an optional embodiment, communication module 24 includes:
Transmitting element, for by from one or more communication thread at least one message be sent to end segment
Point;And/or, receive unit, for the message from peer node being routed in node according to thread identifier the line of correspondence
Journey.
As an optional embodiment, creation module 22, for the information creating instance of agent according to node;Fig. 3
It is the optional structured flowchart of communication processing apparatus according to embodiments of the present invention, as it is shown on figure 3, this device can also include: note
Volume module 32, is positioned in instance of agent, for the information registering peer node according to peer node.
As an optional embodiment, Fig. 3 is the optional structure of communication processing apparatus according to embodiments of the present invention
Block diagram, as it is shown on figure 3, this device also includes: thread closes module 34, is positioned in instance of agent, is used for closing sign off
Thread;And/or, cancellation module 36, it is positioned in instance of agent, for all order wires in one or more communication thread
After the communication of journey terminates the most, nullify peer node.
As an optional embodiment, Fig. 3 is the optional structure of communication processing apparatus according to embodiments of the present invention
Block diagram, as it is shown on figure 3, this device can also include: instance of agent closes module 38, for nullifying end segment at cancellation module 36
After Dian, close instance of agent.
Registering modules 32, thread closedown module 34, cancellation module 36, instance of agent are closed these modules of module 38 and can be made
It is arranged in instance of agent for the optional module of one.
Above-described embodiment and optional embodiment may apply in multiple communications framework, usual below in conjunction with one
The communications framework that the comparison of use is many illustrates.
In the present embodiment, illustrate to be implemented into above-described embodiment and optional embodiment the communications framework of ZeroMQ
In.
Communications framework in the present embodiment, can support the communication of distinct device striding course, cross-thread, and the most dry
Disturb.And, the bottom communication in the present embodiment is fully transparent to user, easy to use, has relatively low coupling between communication module
Degree, can support heat extension.
Technical scheme in the present embodiment makes full use of the multiple message transmission of the efficient feature of ZeroMQ light weight and offer
Model and powerful communication pattern hide the communication details of bottom, support have lower coupling, can dynamically join across
The communication of thread.Technical scheme in the present embodiment can utilize TCP transmission model construction request-answer-mode in ZeroMQ
(DEALER-ROUTER), it is achieved the network service of multithreading between different nodes.
Further, DEALER end socket can also be created by registration (register) operation in the present embodiment to register
Other nodes, by go register (unregister) operation close DEALER socket nullify node, dynamic implement and other
Communication between node processes.
In terms of sending message, node processes is internal pushes-route by INPROC traffic model structure in ZeroMQ
(PUSH-ROUTER) pattern, creates ROUTER server side socket, each line between node in collecting (Collector) module
Journey uses PUSH socket to transmit the message to the Collector module in node, after Collector module receives message,
Each node of registration it is sent to by DEALTER client socket.In terms of receiving message, by INPROC in ZeroMQ
Traffic model structure Publish-subscribe pattern (PUB-SUB), sets up request-allotter (request-respectively at PUB end
Dispatcher), response-allotter (response-dispatcher) socket.Reception when ROUTER server end
(Acceptor) after module receives the message that other nodes send, according to type (request type or the reply class of message
Type) given out information by corresponding request-dispatcher or response-dispatcher socket respectively.Each thread
(client thread or service end server thread) creates corresponding SUB end socket, needs subscription relevant to oneself
Theme, it is possible to receive the message that other node threads send over.Thread can by subscribe to or unsubscribe and dynamically
Join in reception message communicating, and by sending message at DEALER end socket.
Fig. 4 is received server-side client's request processing flow figure according to embodiments of the present invention, as shown in Figure 4, this stream
Journey comprises the steps:
Step S401, ID (node identifier) according to this node place, node IP address, node communication port, create
One communication Agent process.
Step S402, starts Agent example.
Step S403, the registration of Agent example needs the node with other node communications, including the node ID of other nodes,
Node IP address, node port.
Step S404, Agent example produces thread-level other server line according to identifier (such as BUCKET_ID)
Journey.
Step S405, step S406, server thread receives and processes message, then sends message.
Step S407, it is judged that whether service logic completes, wherein, if it is judged that service logic completes, then performs step
Rapid S408.
Step S408, closes server thread.
Step S409, Agent example nullifies other nodes.
Step S410, closes Agent example.
Fig. 5 is client request processing flow figure according to embodiments of the present invention, as it is shown in figure 5, this flow process includes as follows
Step:
Step S501, according to the ID (node identifier) at this node place, node IP address, node communication port, creates
One communication Agent process.
Step S502, starts Agent example.
Step S503, the registration of Agent example needs the node with other node communications, including the node ID of other nodes,
Node IP address, node port.
Step S504, Agent example produces thread-level other client line according to identifier (such as BUCKET_ID)
Journey.
Step S505, step S506, client thread sends and receives message.
Step S507, it is judged that whether service logic completes, wherein, in the case of judging that service logic is completed, then
Perform step S508, in the case of judging that non-service logic is not fully complete, return and perform step S505.
Step S508, closes client thread.
Step S509, Agent example nullifies other nodes.
Step S510, closes Agent example.
In the present embodiment, each node can pass through node tlv triple (node identification ID, node IP, node side slogan
PORT) identify, after creating Agent example, if to need Agent to pass through other node ternarys with other node communications
Group information is registered.For routing messages to certain concrete thread, need in process, message to be forwarded, its thread
The identifier BUCKET_ID of rank is used for routing messages to the thread of correspondence.So can produce in an Agent example
Arbitrary server thread and client thread.If service logic completes, certain client thread or server can be closed
Thread.If need not and certain node communication, unregister operation can be performed and nullify this node.If being no longer necessary to lead to
Letter, can close Agent example.
Fig. 6 is the overall architecture schematic diagram according to alternative embodiment of the present invention, as shown in Figure 6, this communication framework hides
The ins and outs of inter-node communication, user feels all right as communicating with peer node.It practice, data are by instance of agent (i.e.,
Agent example) it is collected and forwards, utilize mode and the communication pattern in ZeroMQ bottom communication storehouse, be transferred to relatively
The peer node (that is, node 1 or node 2) answered.
Below ZeroMQ message library is illustrated.
ZeroMQ is an embeddable concurrent network service storehouse, and it provides different types of socket (socket), this
A little sockets can by different transmission mode such as INPROC (intra process communication), IPC (interprocess communication), TCP,
Multicast (multicast) transmits message with carrying out atomicity.The socket that developer can use various pattern to realize N:N connects,
These patterns include the distribution of fan-out, Publish-subscribe, task and request-response.The transmission speed of ZeroMQ is sufficiently fast, therefore may be used
Serve as the communications component of cluster product.Its asynchronous I/O model provides extendible multinuclear application program, comes with asynchronous message
Process task.
ZeroMQ has the advantage such as high-performance, simple, scalability.It does not has the expense of extra agreement such as AMQP, fills
Dividing utilizes some efficient transmission means such as reliabilities to multicast, and utilizes smart message batch mechanism, effectively utilizes TCP/IP to connect,
Maximum program ground reduces protocol overhead and system is called.ZeroMQ make use of the simple API of ZeroMQ, and sending message only needs to initiate
One asynchronous call, it by single for message queue to thread, completes all remaining work automatically.Itself do not support
The serializing of message, in coded message, to the great motility of developer, message itself will be considered binary block data.
Four kinds of modes that ZeroMQ offer is basic: 1) INPROC: the traffic model in process;2) IPC: between process
Traffic model;3) MULTICAST: effective multicast model, may be encapsulated in UDP;4) TCP: traditional TCP socket pattern.
ZeroMQ regards four classes as the demand of communication.One type is the most peering communication, is used for supporting traditional TCP
Socket model, but do not recommend.Conventional communication mode only has three classes.
1) (REQ-REP) pattern is responded in request.Initiated request by request end, and the end that awaits a response responds request.From request
From the point of view of Duan, must be a pair transmitting-receiving to be matched;Otherwise, must be that a receipts is right responding end.Request end and response end can
It it is the model of 1:N.Generally it is considered server, N 1 and is considered Client.ZeroMQ can well support that routing function is (real
The assembly of existing routing function is called Device), 1:N is expanded to N:M (having only to add some routing nodes).From this model
Seeing, upper strata is hidden by the end-point addresses of more bottom.Each request is implied with response address, and application is then indifferent to it.
2) distribution subscription (PUB-SUB) pattern.In this pattern, publishing side is unidirectional and sends data, and is indifferent to
Whether whole information is all sent to subscription end.If publishing side starts to release news, subscription end not yet connects
Coming, these information directly abandon.The most once subscription end connects, and centre can ensure do not have information dropout.Equally, subscription end
The most only it is responsible for reception, and can not feed back.If publishing side and subscription end need alternately, (subscriber to be confirmed has connected
Connect), then use extra socket to use request to respond model and meet this demand.
3) pipeline (PUSH-PULL) pattern.In this pattern, pipeline is unidirectional, from PUSH end unidirectional to PULL end
Propelling data stream.Any distributed, parallel demand, can solve altogether by these three model group, as generated us originally
Required DEALER-ROUTER, the PUSH-ROUTER pattern used of technological invention.DEALER-ROUTER, PUSH-ROUTER mould
Formula can realize choke free REQ-REP mode capabilities.
The message used in the present embodiment can identify certain thread in node to be sent and node and message
Type (reply or request).Fig. 7 is the overall architecture schematic diagram according to alternative embodiment of the present invention, is divided into 5 as shown in Figure 7
Individual module:
Receive (Acceptor) module to be used for being responsible for receiving the message that other nodes send, after receiving a piece of news,
Acceptor module is that request message (request) is still receiveed the response (reply) according to type of message, message is given accordingly
Request-allotter (request-dispatcher) or response-allotter (response-dispatcher) module.
Request-dispatcher module is used for processing server (server) line that the request message of client is sent to correspondence
Journey, this bucket used in message identifies the server thread of correspondence.Response-dispatcher module is used for locating
The response message of server end is sent to client (client) thread of correspondence by reason, the most also by message
Bucket identifies the client thread of correspondence.Collect (Collectors) module and maintain other that registered with this node
Node socket gathers.Server thread or client thread need the message that sends by Collector module collection, by
In socket set, corresponding socket is sent to peer node.In this technological invention communications framework, control
(Controller) module is used for dynamically controlling the addition of communication node and removing.
Fig. 8 is the ZeroMQ transmission mode schematic diagram that communications framework according to embodiments of the present invention is used, and shows in Fig. 8
Message is sent to node 1 (node1) from node 2 (node2), and message can be by server (server) thread of node2
It is sent to client (client) thread of node1, it is also possible to be the client thread of the node2 server that is sent to node1
Thread.INPROC traffic model structure is used to push-route (PUSH-between communication thread and collection (Collector) module
ROUTER) pattern socket, the data that the asynchronous receiving thread without blocking of collector ROUTER end socket sends.Two joints
TCP transmission model construction request-answer-mode (DEALER-ROUTER) is used, at request (DEALER) end sending module between point
(senders) set maintains this node TCP socket collection to other communication nodes.According to node corresponding in message
ID, finds corresponding socket, transmits the message to node response (ROUTER) the end socket of correspondence.Node1 is receiving
(acceptor) after module receives message, according to the type of message, by corresponding request-allotter (request-
Dispatcher) process with response-allotter (response-dispatcher) module.Request-dispatcher
Resume module client thread request, uses INPROC traffic model structure Publish-subscribe pattern (PUB-with server thread
SUB), server thread, by subscribing to the theme (bucket in corresponding message structure) relevant to this thread, receives correspondence main
The message of topic.The response of Response-dispatcher resume module server thread, uses INPROC to lead to client thread
Letter model construction Publish-subscribe pattern (PUB-SUB), client thread (corresponding is disappeared by the subscription theme relevant to this thread
Bucket in breath structure), receive the message of corresponding theme.This completes the message communicating between a different threads.Joint
INPROC traffic model structure pipeline (PUSH-PULL) pattern is used between some process and controller (controller) module,
Controller module creation PULL socket, receives the registration (register) of node process transmission or goes registration
(unregister) request of node.When receiving register request, controller module can create corresponding node
DEALER end socket, be connected to correspondence node, then socket is joined senders set in;When receiving
During unregister request, controller module can nullify the DEALER end socket of correspondence, and by socket from senders
Set removes.
The communication of cross-thread between the communications framework support different node in the present embodiment, without interfering, meanwhile, with
The affair logic of process has the relatively low degree of coupling, supports that dynamic interpolation communicates with deletion of node simultaneously.
The shortcoming that current distributed communication framework is complicated, huge, too fat to move is avoided by above-described embodiment.Utilize ZeroMQ
The efficient feature of communication pool light weight, at this fundamental construction distributed communication framework, this results in advantages below at least one:
(1) lightweight, the distributed communication of efficient fast and reliable are provided.Make full use of the many modes in ZeroMQ
Communication pattern with unique, reduces complexity.
(2) bottom communication is fully transparent to user, easy to use.We are on the basis of ZeroMQ, it is provided that succinct
API, easy to use cut simple.
(3) different machines striding course, the communication of cross-thread, and non-interference are supported.
(4) there is the relatively low degree of coupling between communication module, heat extension can be supported.
In the above embodiment of the present invention, the description to each embodiment all emphasizes particularly on different fields, and does not has in certain embodiment
The part described in detail, may refer to the associated description of other embodiments.
In several embodiments provided herein, it should be understood that disclosed technology contents, can be passed through other
Mode realizes.Wherein, device embodiment described above is only schematically, the division of the most described unit, Ke Yiwei
A kind of logic function divides, actual can have when realizing other dividing mode, the most multiple unit or assembly can in conjunction with or
Person is desirably integrated into another system, or some features can be ignored, or does not performs.Another point, shown or discussed is mutual
Between coupling direct-coupling or communication connection can be the INDIRECT COUPLING by some interfaces, unit or module or communication link
Connect, or other form.
The described unit illustrated as separating component can be or may not be physically separate, shows as unit
The parts shown can be or may not be physical location, i.e. may be located at a place, or can also be distributed to multiple
On unit.Some or all of unit therein can be selected according to the actual needs to realize the purpose of the present embodiment scheme.
It addition, each functional unit in each embodiment of the present invention can be integrated in a processing unit, it is also possible to
It is that unit is individually physically present, it is also possible to two or more unit are integrated in a unit.Above-mentioned integrated list
Unit both can realize to use the form of hardware, it would however also be possible to employ the form of SFU software functional unit realizes.
If described integrated unit realizes and as independent production marketing or use using the form of SFU software functional unit
Time, can be stored in a computer read/write memory medium.Based on such understanding, technical scheme is substantially
The part that in other words prior art contributed or this technical scheme completely or partially can be with the form of software product
Embodying, this computer software product is stored in a storage medium, including some instructions with so that a computer
Equipment (can be for personal computer, server or the network equipment etc.) perform the whole of method described in each embodiment of the present invention or
Part steps.And aforesaid storage medium includes: USB flash disk, read only memory (ROM, Read-Only Memory), random access memory are deposited
Reservoir (RAM, Random Access Memory), portable hard drive, magnetic disc or CD etc. are various can store program code
Medium.
The above is only the preferred embodiment of the present invention, it is noted that for the ordinary skill people of the art
For Yuan, under the premise without departing from the principles of the invention, it is also possible to make some improvements and modifications, these improvements and modifications also should
It is considered as protection scope of the present invention.
Claims (14)
1. a communication processing method, it is characterised in that including:
Creating one or more communication thread in node, wherein, described communication thread is for entering with the thread in peer node
Row communication, described communication thread includes at least one of: service end thread, client thread;
By in the one or more communication thread at least one between described node and described peer node, carry out line
Communicate between journey.
Method the most according to claim 1, it is characterised in that
In described node, create the one or more communication thread include: by the instance of agent arranged in described node
Create the one or more communication thread;
By in the one or more communication thread at least one between described node and described peer node, carry out line
Between journey communication include: described instance of agent use in the one or more communication thread at least one in described node and institute
State and between peer node, carry out inter-thread communication.
Method the most according to claim 2, it is characterised in that described instance of agent uses the one or more order wire
In journey at least one between described node and described peer node, carry out inter-thread communication include:
Described instance of agent by from the one or more communication thread at least one message be sent to described opposite end
Node;
Message from described peer node is routed in described node correspondence according to thread identifier by described instance of agent
Thread.
Method the most according to claim 2, it is characterised in that create the one or more communication in described instance of agent
Before thread, described method also includes:
Instance of agent described in information creating according to described node in described node;
Described instance of agent is according to peer node described in the information registering of described peer node.
Method the most according to claim 4, it is characterised in that
The information of described node includes at least one of: the identification information of described node, the IP address of described node, described joint
The port of point;And/or,
The information of described peer node includes at least one of: the identification information of described peer node, described peer node
IP address, the port of described peer node.
6. according to the method according to any one of claim 2 to 5, it is characterised in that communicated by the one or more
After thread communicates between described node and described peer node, described method also includes:
Described instance of agent closes the communication thread of sign off;And/or,
After the communication of all communication thread in the one or more communication thread terminates the most, described instance of agent is noted
Sell described peer node.
Method the most according to claim 6, it is characterised in that after described instance of agent nullifies described peer node,
Described method also includes:
Described instance of agent is closed at described node.
8. a communication processing apparatus, is positioned in node, it is characterised in that including:
Creation module, is used for creating one or more communication thread, and wherein, described communication thread is used for and the line in peer node
Journey communicates, and described communication thread includes at least one of: service end thread, client thread;
Communication module, for by the one or more communication thread at least one at described node and described to end segment
Inter-thread communication is carried out between point.
Device the most according to claim 8, it is characterised in that described creation module and described communication module, is positioned at agency
In example.
Device the most according to claim 9, it is characterised in that described communication module includes:
Transmitting element, for by from the one or more communication thread at least one message be sent to described opposite end
Node;And/or,
Receive unit, for the message from described peer node being routed in described node correspondence according to thread identifier
Thread.
11. devices according to claim 9, it is characterised in that
Described creation module, for according to instance of agent described in the information creating of described node;
Described device also includes: Registering modules, is positioned in described instance of agent, for the information registering according to described peer node
Described peer node.
12. devices according to claim 11, it is characterised in that
The information of described node includes at least one of: the identification information of described node, the IP address of described node, described joint
The port of point;And/or,
The information of described peer node includes at least one of: the identification information of described peer node, described peer node
IP address, the port of described peer node.
13. according to the device according to any one of claim 9 to 12, it is characterised in that described device also includes:
Thread closes module, is positioned in described instance of agent, for closing the thread of sign off;And/or,
Cancellation module, is positioned in described instance of agent individual, for all order wires in the one or more communication thread
After the communication of journey terminates the most, nullify described peer node.
14. devices according to claim 13, it is characterised in that described device also includes:
Instance of agent closes module, after nullifying described peer node at described cancellation module, closes described instance of agent.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610505084.3A CN106209996A (en) | 2016-06-27 | 2016-06-27 | Communication processing method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610505084.3A CN106209996A (en) | 2016-06-27 | 2016-06-27 | Communication processing method and device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN106209996A true CN106209996A (en) | 2016-12-07 |
Family
ID=57462787
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610505084.3A Pending CN106209996A (en) | 2016-06-27 | 2016-06-27 | Communication processing method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106209996A (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108600011A (en) * | 2018-04-26 | 2018-09-28 | 百度在线网络技术(北京)有限公司 | Method, apparatus, storage medium and the terminal device of communication network data transmission |
CN109257301A (en) * | 2018-09-07 | 2019-01-22 | 国网江苏省电力有限公司苏州供电分公司 | A kind of message in power system network distributes method and apparatus |
CN109408248A (en) * | 2018-09-19 | 2019-03-01 | 福建星网智慧科技股份有限公司 | Cross-thread communication system under a kind of Linux |
CN113727113A (en) * | 2020-05-26 | 2021-11-30 | 网易(杭州)网络有限公司 | Video decoding method, stream pushing method and system |
CN114629904A (en) * | 2022-02-15 | 2022-06-14 | 广州伊智信息科技有限公司 | Distributed event processing method, system, device and medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1716209A (en) * | 2004-06-28 | 2006-01-04 | 英特尔公司 | Thread to thread communication |
CN103197920A (en) * | 2013-03-25 | 2013-07-10 | 华为技术有限公司 | Concurrency control method, control nodes and system |
CN103744643A (en) * | 2014-01-10 | 2014-04-23 | 浪潮(北京)电子信息产业有限公司 | Method and device for structuring a plurality of nodes parallel under multithreaded program |
CN105786603A (en) * | 2016-02-29 | 2016-07-20 | 青岛海尔智能家电科技有限公司 | High-concurrency service processing system and method based on distributed mode |
-
2016
- 2016-06-27 CN CN201610505084.3A patent/CN106209996A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1716209A (en) * | 2004-06-28 | 2006-01-04 | 英特尔公司 | Thread to thread communication |
CN103197920A (en) * | 2013-03-25 | 2013-07-10 | 华为技术有限公司 | Concurrency control method, control nodes and system |
CN103744643A (en) * | 2014-01-10 | 2014-04-23 | 浪潮(北京)电子信息产业有限公司 | Method and device for structuring a plurality of nodes parallel under multithreaded program |
CN105786603A (en) * | 2016-02-29 | 2016-07-20 | 青岛海尔智能家电科技有限公司 | High-concurrency service processing system and method based on distributed mode |
Non-Patent Citations (1)
Title |
---|
陈小辉, 刘心松, 左朝树, 陈建英: "《分布式并行数据库中基于调度的多线程通信模型之研究》", 《小型微型计算机系统》 * |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108600011A (en) * | 2018-04-26 | 2018-09-28 | 百度在线网络技术(北京)有限公司 | Method, apparatus, storage medium and the terminal device of communication network data transmission |
CN108600011B (en) * | 2018-04-26 | 2020-01-24 | 百度在线网络技术(北京)有限公司 | Communication network data transmission method, device, storage medium and terminal equipment |
CN109257301A (en) * | 2018-09-07 | 2019-01-22 | 国网江苏省电力有限公司苏州供电分公司 | A kind of message in power system network distributes method and apparatus |
CN109408248A (en) * | 2018-09-19 | 2019-03-01 | 福建星网智慧科技股份有限公司 | Cross-thread communication system under a kind of Linux |
CN113727113A (en) * | 2020-05-26 | 2021-11-30 | 网易(杭州)网络有限公司 | Video decoding method, stream pushing method and system |
CN114629904A (en) * | 2022-02-15 | 2022-06-14 | 广州伊智信息科技有限公司 | Distributed event processing method, system, device and medium |
CN114629904B (en) * | 2022-02-15 | 2024-05-24 | 广州伊智信息科技有限公司 | Distributed event processing method, system, equipment and medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106209996A (en) | Communication processing method and device | |
US10795737B2 (en) | Generic distributed processing for multi-agent systems | |
CN112751826B (en) | Method and device for forwarding flow of computing force application | |
CN109144660A (en) | Micro services framework | |
CN111193653B (en) | Data transmission method, device, equipment and storage medium | |
CN111224821B (en) | Security service deployment system, method and device | |
CN115362662A (en) | Flow management for intelligent network interface cards | |
US20150003296A1 (en) | System and method for providing p2p based reconfigurable computing and structured data distribution | |
CN105282191B (en) | SiteServer LBS, controller and method | |
CN103763367A (en) | Method and system for designing distributed virtual network in cloud calculating data center | |
CN105763385B (en) | Traffic scheduling method and device | |
CN102334112A (en) | Method and system for virtual machine networking | |
JP5993817B2 (en) | Routing system and method in carrier network | |
EP2883123B1 (en) | Forwarding packet in stacking system | |
CN110928694B (en) | Computer system | |
Redondi et al. | Towards a scaled iot pub/sub architecture for 5g networks: the case of multiaccess edge computing | |
CN113810206A (en) | Network automation arrangement management method, entity, controller and electronic equipment | |
CN108965134A (en) | Message forwarding method and device | |
CN112527523A (en) | Distributed message transmission method and system for high-performance computing multiple clouds | |
CN103827830B (en) | System and method for preventing "bottleneck" in transactional middleware machine environment | |
CN109474713A (en) | Message forwarding method and device | |
Premkumar et al. | A survey of architecture, framework and algorithms for resource management in edge computing | |
WO2023169374A1 (en) | Routing method and system, and node | |
WO2023179457A1 (en) | Method, apparatus and system for identifying service connection, and storage medium | |
CN109474523B (en) | Networking method and system based on SDN |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20161207 |
|
RJ01 | Rejection of invention patent application after publication |