ZeroMQ - Multiple Publishers and Listener -
i'm starting understanding , trying zeromq.
it's not clear me how have 2 way communication between more 2 actors (publisher , subscriber) each component able both read , write on mq.
this allow create event-driven architecture, because each component listening event , reply event.
is there way zeromq straight or should implement own solution on top of that?
if want simple two-way communication set publishing socket on each node, , allow each connect other.
in many many setup becomes tricky handle. basically, sounds want kind of central node nodes can "connect" to, receive messages and, if conditions on subscriber met, send messages to.
since zeromq simple "power-socket", , not message queue (hence name, zeromq - 0 message queue) not feasible out-of-the-box.
a simple alternative allow each node set udp broadcast socket (not using zeromq, regular sockets). nodes can hear in whatever takes place , "publish" own messages on socket, sending nodes listening. setup works on lan , in setting ok messages lost (like periodical state updates). if messages needs reliable (and perchance durable) need more advanced full-blown message queue.
if can without durable message queues, can create solution based on central node, central message handler, nodes can subscribe , send info to. basically, create "server" 1 rep (response) socket (for incoming data) , 1 pub (publisher) socket (for outgoing data). each client publishes info servers rep socket on req (request) socket , sets sub (subscriber) socket servers pub socket.
check out zeromq guide regarding various message patterns available.
to spice bit, add together event "topics", including server side filtering, splitting outgoing messages (on servers pub socket) 2 message parts (see multi-part messages) first part specifies "topic" , sec part contains payload (e.g. temp|46.2, speed|134). way, each client can register involvement in topic (or all) , allow server filter out matching messages. see this example details.
basically, zeromq "just" abstraction on regular sockets, providing couple of messaging patterns build solution on top of. however, relieves of lot of tedious work , provides scalability , performance out of ordinary. takes getting used though. check out zeromq guide more details.
zeromq
No comments:
Post a Comment