Reputation: 1874
I want to build a system that has the following architecture:
+------------------+ +------------------+
| App1. 0mq client | <------> | App2. 0mq server |
+------------------+ +------------------+
whereApp2
is a ZeroMQ
server and it's a black box,
and
App1
is a ZeroMQ
client, but it is in fact a frontend server. The frontend server will process some requests from the clients and then will communicate with the App2 server.
Given that:
Is it possible to implement 3. only using ZeroMQ
builtins, or do I need to use a different mechanism to notify App1 that App2 is up ?
Upvotes: 4
Views: 1702
Reputation: 65
Though I am not expert but I once implemented a similar platform.
An additional layer of signaling (REQ/REP
) from App2
->
App1
could do that.
Everytime App2
comes online, a msg
should be conveyed to App1
.
A separate thread in App1
would be able to receive this msg
from App2
anytime.
Upvotes: 1
Reputation: 1
Item 3
: using pure ZeroMQ
built-insFig.1:
Why it is wrong to use a naive REQ/REP
XTRN_RISK_OF_FSA_DEADLOCKED ~ { NETWORK_LoS
: || NETWORK_LoM
: || SIG_KILL( App2 )
: || ...
: }
:
[App1] ![ZeroMQ] : [ZeroMQ] ![App2]
code-control! code-control : [code-control ! code-control
+===========!=======================+ : +=====================!===========+
| ! ZMQ | : | ZMQ ! |
| ! REQ-FSA | : | REP-FSA! |
| !+------+BUF> .connect()| v |.bind() +BUF>------+! |
| !|W2S |___|>tcp:>---------[*]-----(tcp:)--|___|W2R |! |
| .send()>-o--->|___| | | |___|-o---->.recv() |
| ___/ !| ^ | |___| | | |___| ^ | |! \___ |
| REQ !| | v |___| | | |___| | v |! REP |
| \___.recv()<----o-|___| | | |___|<---o-<.send()___/ |
| !| W2R|___| | | |___| W2S|! |
| !+------<BUF+ | | <BUF+------+! |
| ! | | ! |
| ! ZMQ | | ZMQ ! |
| ! REQ-FSA | | REP-FSA ! |
~~~~~~~~~~~~~ DEADLOCKED in W2R ~~~~~~~~ * ~~~~~~ DEADLOCKED in W2R ~~~~~~~~~~~~~
| ! /\/\/\/\/\/\/\/\/\/\/\| |/\/\/\/\/\/\/\/\/\/\/! |
| ! \/\/\/\/\/\/\/\/\/\/\/| |\/\/\/\/\/\/\/\/\/\/\! |
+===========!=======================+ +=====================!===========+
Fig.2:
How to implement requirement Item 3
, using pure ZeroMQ
builtins.
App1.PULL.recv( ZMQ.NOBLOCK )
and App1.PULL.poll( 0 )
are obvious
[App1] ![ZeroMQ]
code-control! code-control
+===========!=======================+
| ! |
| !+----------+ |
| .poll()| W2R ___|.bind() |
| ____.recv()<----o-|___|-(tcp:)--------O
| PULL !| |___| | :
| !| |___| | :
| !| |___| | :
| !+------<BUF+ | :
| ! | : ![App2]
| ! | : [ZeroMQ] ! code-control
| ! | : [code-control ! once gets started ...
| ! | : +=====================!===========+
| ! | : | ! |
| ! | : | +----------+! |
| ! | : | |___ |! |
| ! | : | |___| <--o-<.send()____ |
| ! | :<<-------<tcp:<|___| W2S|! PUSH |
| ! | : .connect() <BUF+------+! |
| ! | : | ! |
| ! | : | ! |
+===========!=======================+ : +=====================!===========+
Upvotes: 2