CN109379443A - A kind of implementation method of the Distributed Message Queue of internet of things oriented - Google Patents

A kind of implementation method of the Distributed Message Queue of internet of things oriented Download PDF

Info

Publication number
CN109379443A
CN109379443A CN201811548642.XA CN201811548642A CN109379443A CN 109379443 A CN109379443 A CN 109379443A CN 201811548642 A CN201811548642 A CN 201811548642A CN 109379443 A CN109379443 A CN 109379443A
Authority
CN
China
Prior art keywords
message
agent
sink end
implementation method
connection
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201811548642.XA
Other languages
Chinese (zh)
Other versions
CN109379443B (en
Inventor
王伟
华园伟
韩凯
朱立松
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
CCTV INTERNATIONAL NETWORKS WUXI Co Ltd
Original Assignee
CCTV INTERNATIONAL NETWORKS WUXI 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 CCTV INTERNATIONAL NETWORKS WUXI Co Ltd filed Critical CCTV INTERNATIONAL NETWORKS WUXI Co Ltd
Priority to CN201811548642.XA priority Critical patent/CN109379443B/en
Publication of CN109379443A publication Critical patent/CN109379443A/en
Application granted granted Critical
Publication of CN109379443B publication Critical patent/CN109379443B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks
    • H04L67/1044Group management mechanisms 
    • H04L67/1046Joining mechanisms
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services

Abstract

The invention discloses a kind of implementation methods of the Distributed Message Queue of internet of things oriented, it include message sending end, Message Agent and message sink end in Distributed Message Queue system, between message sending end and message sink end, message sending end/between message sink end and Message Agent communicates to connect in such a way that long connection mixes short connection, it include: to judge whether to need to send message request to message sink end in the implementation method, if so, initiating P2P connection according to the address at message sink end;Judge whether P2P connection succeeds, if unsuccessful, established by Message Agent and connect with the TURN at message sink end;The needs of sending a message to message sink end by Message Agent, on the basis of can be realized message queue function, while making system cost less campus network, provide higher terminal device access capability, meeting more than internet-of-things terminal quantity.

Description

A kind of implementation method of the Distributed Message Queue of internet of things oriented
Technical field
The present invention relates to field of computer technology more particularly to a kind of realizations of the Distributed Message Queue of internet of things oriented Method.
Background technique
Distributed Message Queue early has become the common method of each submodule inter-block communication and decoupling inside large scale system, Unified communication mode is provided in internal system, and the flexibility of system design is increased while increasing system reliability, is System provides higher peak value processing capacity.Distributed nature is that message queue increases scalability, and it is difficult also to bring design Degree.Common Distributed Message Queue design scheme is as shown in Figure 1, include several producers (APP in diagram), Message Agent (Broker, Broker Leader is the central node of Message Agent in diagram) and consumer (APP in diagram), Message Agent The core functions such as forwarding, the persistence for providing message for the producer, consumer, the producer by news release to Message Agent, Consumer subscribes to agency and consumes message, and the producer/between consumer and Message Agent passes through TCP between Message Agent (Transmission Control Protocol, transmission control protocol) connection.
In general, the producer, consumer and Message Agent are in identical local area network in existing system, to band It is wide that there is no limit can be realized message all between producers and consumers and all forwarded by Message Agent, still, in Internet of Things In net, quite a few producer, consumer and Message Agent are in different local area networks, if adopting existing scheme, A large amount of bandwidth paid undoubtedly can be all generated in terminal device and Message Agent.
Summary of the invention
In view of the above shortcomings of the prior art, the present invention provides a kind of realities of the Distributed Message Queue of internet of things oriented Existing method, efficiently solves the technical issues of generating a large amount of bandwidth paids in the prior art.
To achieve the goals above, the invention is realized by the following technical scheme:
A kind of implementation method of the Distributed Message Queue of internet of things oriented includes message in Distributed Message Queue system Transmitting terminal, Message Agent and message sink end, between message sending end and message sink end, message sending end/message sink end It is communicated to connect in such a way that long connection mixes short connection between Message Agent, the implementation method is sent applied to message End, comprising:
Judge whether to need to send message request to message sink end, if so, initiating P2P according to the address at message sink end Connection;
Judge whether P2P connection succeeds, if unsuccessful, established by Message Agent and connect with the TURN at message sink end;
Message sink end is sent a message to by Message Agent.
It is further preferred that in step judges whether P2P connection successful, if judging P2P successful connection, directly by message It is sent to message sink end.
It is further preferred that after sending a message to message sink end, further includes:
Judge whether not communicated with Message Agent/message sink end within a preset period of time, if so, disconnecting and disappearing Cease the communication connection of agency/message sink end.
It is further preferred that judging whether to need to send message request into message sink end in step, if judgement needs Send message request, further includes:
Persistence processing is carried out to the message request of transmission.
It is further preferred that judging whether to need to send message request to message sink end, further comprise:
Periodically whether there is information updating to the theme of Message Agent query subscription, if so, determining to need to send message request To message sink end.
It is further preferred that before whether step periodically has information updating to the theme of Message Agent query subscription, packet It includes:
Judge whether to need to subscribe to message, if so, the theme subscribed to will be needed to be sent to Message Agent.
It is further preferred that in the implementation method further include:
Judging whether there is new information will issue, if so, will give out information is sent to Message Agent.
The implementation method of the Distributed Message Queue of internet of things oriented provided by the invention can at least be brought following beneficial Effect:
1. preferentially straight using P2P technology between sender of the message (the corresponding producer) and message recipient (corresponding consumer) Capable communication is tapped into succession, and Message Agent transfer message is used in P2P connection failure, it is middle compared with the existing technology all to have message It acts on behalf of for transfer message, has greatly saved the flow of Message Agent.It in practical applications, can if P2P connection is successfully established To save the flow close to half, i.e., implementation method provided by the invention makes on the basis of can be realized message queue function While system cost less campus network, higher terminal device access capability is provided, internet-of-things terminal quantity is met More demands;
2. the message sent directly carries out persistence sending message sending end, compared with the existing technology in by strange land Message Agent realize persistence for, ensure that message can unreachable message receiving end while, significantly reduce Message Agent Pressure;
3. message sending end and between Message Agent, between message sending end and message sink end, mixed using long connection The mode for closing short connection communicates, middle all using growing for connection compared with the existing technology, greatly reduces the negative of Message Agent Load, while providing more terminal device access capabilities.
Detailed description of the invention
In conjunction with attached drawing, and by reference to following detailed description, it will more easily have more complete understanding to the present invention And its adjoint advantage and feature is more easily to understand, in which:
Fig. 1 is Distributed Message Queue system schematic in the prior art;
Fig. 2 is a kind of embodiment process signal of implementation method of the Distributed Message Queue of internet of things oriented in the present invention Figure;
Fig. 3 is Distributed Message Queue system schematic in the present invention;
Fig. 4 is that the implementation method another embodiment process of the Distributed Message Queue of internet of things oriented in the present invention is shown It is intended to.
Specific embodiment
To keep the contents of the present invention more clear and easy to understand, below in conjunction with Figure of description, the contents of the present invention are made into one Walk explanation.Certainly the invention is not limited to the specific embodiment, general replacement known to those skilled in the art It is included within the scope of protection of the present invention.
Such as a kind of embodiment stream of implementation method for the Distributed Message Queue that Fig. 2 is internet of things oriented provided by the invention Journey schematic diagram, it can be seen from the figure that including: in the implementation method
S10 judges whether to need to send message request to message sink end, if so, initiating according to the address at message sink end P2P connection;
S20 judges whether P2P connection succeeds, if unsuccessful, established by Message Agent and is connected with the TURN at message sink end It connects;
S30 sends a message to message sink end by Message Agent.
It in the present embodiment, include message sending end (corresponding existing distributed message in Distributed Message Queue system The producer in queue system), (consumption in corresponding existing Distributed Message Queue system of Message Agent and message sink end Person), as shown in figure 3, two HOST respectively correspond message sending end and message sink end, Broker corresponds to Message Agent, Broker Leader is the central node of Message Agent, short by long connection mixing between message sending end and message sink end The P2P mode of connection communicates to connect (Temporary P2P Connection in diagram), message sending end/message sink end and (Temporary Optimized in diagram is communicated to connect between Message Agent in such a way that long connection mixes short connection Connection).In practical applications, sending and receiving for message is realized by client (Client in diagram), usually come It says, the reception of message also may be implemented in the transmission that message can be thus achieved in the same client.Client and concrete application (diagram Middle APP) between pass through shared drive or TCP or HTTP (Hyper Text Transfer Protocol, Hyper text transfer association View) mode communicated, specifically, when client and when being particularly applicable on the same host, by shared drive (in diagram Shared Memory) mode communicated, to improve the speed of data exchange, and when concrete application needs to send message, It is realized by client;When client is with being particularly applicable in different hosts, the mode using TCP or HTTP is led to Letter.
In Message Agent cluster, unique central node is elected by paxos algorithm, message generation is responsible for by central node It manages cluster internal and needs synchronous data, equity is independent between other Message Agent, and action is identical;If central node can not It works normally, then re-elects.
During the work time, when message sending end judgement needs to send message request to message sink end, then according to message It attempts to initiate P2P (Peer-to-Peer, point-to-point) connection in the address of receiving end;If P2P successful connection, message sending end are straight It connects and sends a message to message sink end;If P2P connection is unsuccessful, the TURN with message sink end is established by Message Agent Connection, and then message request is sent to by message sink end by Message Agent.Message sink end is receiving message sending end After the message request of transmission, the message of feedback is sent to message sending end.For message sink end address, in message sending end It is obtained when being communicated for the first time by Message Agent with message sink end (during Distributed Message Queue system is established, respectively Message sending end/corresponding client in message sink end is registered in Message Agent respectively, with this in communication process, message hair Sending end/corresponding client in message sink end obtains the address of other side by Message Agent).
During message sending end and Message Agent/message sink end are communicated, message sending end is also judged Whether do not communicated within a preset period of time with Message Agent/message sink end, if so, description messages transmitting terminal is for a long time It does not connect, then disconnects and the communication connection of Message Agent/message sink end with Message Agent/message sink end.Preset time Section is set according to the actual situation, e.g., is set as 2min (minute), 5min, 10min etc..Similarly, message sink end with During Message Agent/message sink end is communicated, same operation also will do it, to reduce the burden of Message Agent.
Above embodiment is improved to obtain present embodiment, in the present embodiment, message sending end end is being sentenced It is disconnected that persistence processing directly is carried out to the message request of transmission when needing to send message request, compared with the existing technology in pass through The Message Agent in strange land realizes for persistence, ensure that message can unreachable message receiving end while, significantly reduce and disappear Cease the pressure of agency.
Above embodiment is improved to obtain present embodiment, in the present embodiment, as shown in figure 4, the realization Include: in method
Whether S11 periodically has information updating to the theme of Message Agent query subscription, if so, determining that needing to send message asks It asks to message sink end;
S12 initiates P2P connection according to the address at message sink end;
S20 judges whether P2P connection succeeds, if unsuccessful, established by Message Agent and is connected with the TURN at message sink end It connects;
S30 sends a message to message sink end by Message Agent.
In this embodiment, it when the concrete application in client needs to subscribe to message, is operated by client, The theme (Topic) subscribed to will be needed to be sent to Message Agent;When the concrete application in client has new information to issue, lead to It crosses client and will give out information and be sent to Message Agent (including needing the theme etc. that gives out information), client is as message at this time Transmitting terminal.
During the work time, whether client periodically has information updating to the theme of Message Agent query subscription, if message There are information updatings for agency's feedback, then the address of the client of message source is obtained from Message Agent, disappear at this point, client is used as It ceases transmitting terminal (hereinafter referred to as the first client), the client of message source is as message sink end (hereinafter referred to as the second client).
Later, the first client is attempted to initiate P2P connection according to the address of the second client;If P2P successful connection, the One client directly sends a message to the second client;If P2P connection is unsuccessful, established and the second visitor by Message Agent TURN connection between the end of family, and then message request is sent to by the second client by Message Agent.Second client is receiving After the message request sent to the first client, the message of feedback is sent to the first client.
Hereafter, during the first client and Message Agent/second client are communicated, the first client can also Judge whether not communicated with Message Agent/second client within a preset period of time, if so, the first client of explanation is long Time does not connect with Message Agent/second client, then disconnects and the communication connection of Message Agent/second client.

Claims (7)

1. a kind of implementation method of the Distributed Message Queue of internet of things oriented, which is characterized in that Distributed Message Queue system In include message sending end, Message Agent and message sink end, between message sending end and message sink end, message sending end/ It is communicated to connect in such a way that long connection mixes short connection between message sink end and Message Agent, the implementation method application In message sending end, comprising:
Judge whether to need to send message request to message sink end, connects if so, initiating P2P according to the address at message sink end It connects;
Judge whether P2P connection succeeds, if unsuccessful, established by Message Agent and connect with the TURN at message sink end;
Message sink end is sent a message to by Message Agent.
2. implementation method as described in claim 1, which is characterized in that in step judges whether P2P connection is successful, if judgement P2P successful connection directly sends a message to message sink end.
3. implementation method as claimed in claim 1 or 2, which is characterized in that after sending a message to message sink end, also Include:
Judge whether not communicated with Message Agent/message sink end within a preset period of time, if so, disconnecting and message generation The communication connection of reason/message sink end.
4. implementation method as described in claim 1, which is characterized in that judge whether to need to send message request to disappearing in step It ceases in receiving end, if judgement needs to send message request, further includes:
Persistence processing is carried out to the message request of transmission.
5. the implementation method as described in claims 1 or 2 or 4, which is characterized in that judge whether to need to send message request to disappearing Receiving end is ceased, further comprises:
Periodically whether there is information updating to the theme of Message Agent query subscription, if so, determining to need to send message request to disappearing Cease receiving end.
6. implementation method as claimed in claim 5, which is characterized in that in step periodically to the theme of Message Agent query subscription Before whether having an information updating, comprising:
Judge whether to need to subscribe to message, if so, the theme subscribed to will be needed to be sent to Message Agent.
7. the implementation method as described in claims 1 or 2 or 4 or 6, which is characterized in that in the implementation method further include:
Judging whether there is new information will issue, if so, will give out information is sent to Message Agent.
CN201811548642.XA 2018-12-18 2018-12-18 Method for realizing distributed message queue facing to Internet of things Active CN109379443B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811548642.XA CN109379443B (en) 2018-12-18 2018-12-18 Method for realizing distributed message queue facing to Internet of things

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811548642.XA CN109379443B (en) 2018-12-18 2018-12-18 Method for realizing distributed message queue facing to Internet of things

Publications (2)

Publication Number Publication Date
CN109379443A true CN109379443A (en) 2019-02-22
CN109379443B CN109379443B (en) 2022-02-15

Family

ID=65374219

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811548642.XA Active CN109379443B (en) 2018-12-18 2018-12-18 Method for realizing distributed message queue facing to Internet of things

Country Status (1)

Country Link
CN (1) CN109379443B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111740872A (en) * 2020-05-06 2020-10-02 北京百度网讯科技有限公司 Message passing test method and device, electronic equipment and storage medium

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050160424A1 (en) * 2004-01-21 2005-07-21 International Business Machines Corporation Method and system for grid-enabled virtual machines with distributed management of applications
CN101221435A (en) * 2006-09-28 2008-07-16 洛克威尔自动控制技术股份有限公司 Message engine searching and classification
CN101431464A (en) * 2007-11-06 2009-05-13 阿里巴巴集团控股有限公司 Method and apparatus for optimizing data transmission route between clients
CN102883293A (en) * 2012-10-12 2013-01-16 杭州东信北邮信息技术有限公司 System and method for achieving intelligent management of mobile telephone incoming call
CN103702062A (en) * 2013-12-27 2014-04-02 Tcl集团股份有限公司 Audio and video communication method, device and system
CN104363291A (en) * 2014-11-19 2015-02-18 中国航天科工集团第二研究院七〇六所 Network communication middleware implementation method
CN104486107A (en) * 2014-12-05 2015-04-01 曙光信息产业(北京)有限公司 Log collection device and method
CN105007313A (en) * 2015-07-03 2015-10-28 许继集团有限公司 Terminal access method and mass data transmission system for energy saving service
CN106331115A (en) * 2016-08-26 2017-01-11 深圳市同为数码科技股份有限公司 Distributed expandable server system in support of multi-device connection
CN107231290A (en) * 2017-04-19 2017-10-03 中国建设银行股份有限公司 A kind of instant communicating method and system

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050160424A1 (en) * 2004-01-21 2005-07-21 International Business Machines Corporation Method and system for grid-enabled virtual machines with distributed management of applications
CN101221435A (en) * 2006-09-28 2008-07-16 洛克威尔自动控制技术股份有限公司 Message engine searching and classification
CN101431464A (en) * 2007-11-06 2009-05-13 阿里巴巴集团控股有限公司 Method and apparatus for optimizing data transmission route between clients
CN102883293A (en) * 2012-10-12 2013-01-16 杭州东信北邮信息技术有限公司 System and method for achieving intelligent management of mobile telephone incoming call
CN103702062A (en) * 2013-12-27 2014-04-02 Tcl集团股份有限公司 Audio and video communication method, device and system
CN104363291A (en) * 2014-11-19 2015-02-18 中国航天科工集团第二研究院七〇六所 Network communication middleware implementation method
CN104486107A (en) * 2014-12-05 2015-04-01 曙光信息产业(北京)有限公司 Log collection device and method
CN105007313A (en) * 2015-07-03 2015-10-28 许继集团有限公司 Terminal access method and mass data transmission system for energy saving service
CN106331115A (en) * 2016-08-26 2017-01-11 深圳市同为数码科技股份有限公司 Distributed expandable server system in support of multi-device connection
CN107231290A (en) * 2017-04-19 2017-10-03 中国建设银行股份有限公司 A kind of instant communicating method and system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111740872A (en) * 2020-05-06 2020-10-02 北京百度网讯科技有限公司 Message passing test method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN109379443B (en) 2022-02-15

Similar Documents

Publication Publication Date Title
WO2019205907A1 (en) Intelligent device communication platform based on mqtt message protocol
US9560111B2 (en) System and method to transport HTTP over XMPP
US7827275B2 (en) Method and system for remotely accessing devices in a network
US9762675B2 (en) System and method for secure real-time cloud services
CN107800621B (en) Novel intelligent home gateway supporting multiple access protocols
Sutton et al. Supporting disconnectedness-transparent information delivery for mobile and invisible computing
EP1703701B1 (en) APIs to build peer to peer messaging applications
KR100978336B1 (en) Remote access
US9100424B1 (en) System and method for secure real-time cloud services
CA2355462A1 (en) A method and apparatus for supporting a multicast response to a unicast request for a document
CA2778980A1 (en) Hierarchical publish and subscribe system
CN104009938A (en) Method and system for long connections based on router level
US20080208959A1 (en) Hanging request system and method for client/server communication
US8239548B2 (en) Endpoint discriminator in network transport protocol startup packets
CN109379443A (en) A kind of implementation method of the Distributed Message Queue of internet of things oriented
CN108259576B (en) Software and hardware real-time information transmission system and method
WO2007022685A1 (en) Method for realizing the notification service, distributed web manage system and notification sending service device
CN114051030A (en) Communication method, communication device, smart community system and storage medium
CN113098826A (en) Internet of things data transmission method, terminal and storage medium
CN110474781A (en) A kind of method and device of transmitting multicast data
KR20030089364A (en) Method and system of access gateway for integrating wireless internet service on mobile network
CN115190354B (en) Audio and video transmission method and device, electronic equipment and storage medium
CN110932874B (en) Distributed message broadcast notification implementation method
Sriashalya et al. Smart Vehicle Tracking System through IoT
JP4510632B2 (en) Data acquisition source management method and system

Legal Events

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