I want to create a proxy server which routes incoming packets from REQ
type sockets to one of the REP
sockets on one of the computers in a cluster. I have been reading the guide and I think the proper structure is a combination of ROUTER
and DEALER
on the proxy server. Where the ROUTER
passes messages to the dealer to be distributed. However, I cannot figure out how to create this connection scheme. Is this the correct architecture? If so how to I bind a dealer to multiple addresses. The flow I envision is like this REQ->ROUTER|DEALER->[REP, REP, ...]
where only one REP
socket would handle a single request.
ZeroMQ is rather an abstract layer for certain communication-behavioral patterns, so while terms alike socket do sound similar to what one has read/used previously, the ZeroMQ-world is by far different from many points of view.
This very formalism allows ZeroMQ Formal-Communication-Patterns to grow in scale, to get assembled in higher-order-patterns ( for load-balancing, for fault-tolerance, for performance-scaling ). Mastering this style of thinkign, you forget about packets, thread-sync-issues, I/O-polling and focus on your higher-abstraction-based design -- on Behaviour -- rather than on underlying details. This makes your design both free from re-inventing wheel & very powerful, as you re-use a highly professional tools right for your problem-domain tasks.
That said, your DEALER
-node ( in fact a ZMQsocket-access-node, having The Behaviour called a "DEALER
" to resemble it's queue/buffering-style, it's round-robin dispatcher, it's send-out&expect-answer-in model ) may .bind()
to multiple localhost
address:port
-s and these "service-points" may also operate over different TransportClass
-es -- one working over tcp://
, another over inproc://
, if that makes sense for your Design Architecture -- ZeroMQ empowers you to use this transparently abstracted from all the "awfull&dangerous" lower level gritty-nitties.
In principle, where helpfull, one may reverse the .bind()
and .connect()
from DEALER
to a known target address of the respective REP
entity.