[zeromq-dev] Need help with Request-Reply Message Broker
Chernyshev Vyacheslav
astellar at ro.ru
Tue Aug 14 13:11:29 CEST 2012
Hello.
I'm currently trying to use zeromq as a message-passing layer in a
single process to deliver messages from clients to worker threads that
represent a single service. Each client's request results in either 0 or
1 reply from server. After reading the guide I still have something
unclear. As I understood, in case of REQ-REP message broker, we have
fully synchronous communication between clients and worker threads, that
means handling of one message at a time and sending empty replies in
some cases just to keep REQ socket happy. In case of ROUTER-DEALER
solutions we have fully asynchronous communication, where messages from
single client are processed in arbitrary order. But what should I do if
I want to ensure that messages from client are processed in the same
order they are received without rolling back to single message at a time?
I think that I can "fake" what I want using multipart messages and
REQ-REP message broker. As clients communicate with server using a
custom protocol on top of TCP, I still have to parse packets from
clients without zeromq's help, so I can buffer these packets and send
them all as a single multipart zeromq message. After worker replies
back, I'll send everything that was buffered while worker was busy, and
this cycle is repeated. But may be there is a cleaner way to "tell"
zeromq to buffer requests from clients and drain everything that was
buffered when worker can accept its work.
Thanks in advance.
More information about the zeromq-dev
mailing list