“Server” to “Server” ZeroMQ communication

前端 未结 2 1643
栀梦
栀梦 2020-12-16 07:51

I want to build a system that has the following architecture:

+------------------+          +------------------+
| App1. 0mq client | <------> | App2.          


        
相关标签:
2条回答
  • 2020-12-16 08:16

    Item 3: using pure ZeroMQ built-ins

    Fig.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+------+!           |
    |           !                       |   :     |                     !           |
    |           !                       |   :     |                     !           |
    +===========!=======================+   :     +=====================!===========+
    
    0 讨论(0)
  • 2020-12-16 08:31

    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.

    0 讨论(0)
提交回复
热议问题