[zeromq-dev] multiple REQ-REP sockets, polling responses

Prasad Ghawate prasad.ghawate at anzu.org
Tue Jul 19 11:44:21 CEST 2016

Hi Maciej,

I had a same issue and go it worked with following approach.

*Let’s consider Module A is a requester who will request for some data .*

*Module B is responder who needs to respond with some data.*

Step 1 : Module A sends a request to Module B with some unique Id .

Setp2 : Module B  respond immediately with “OK” response which notifies
“A”  that “B” has received the request successfully.

*Now Module “A” is free to send other requests to Module B  *

Step3 :  Module B  Processes the request and will send another ZMQ Req to
Module A as a response for the request which it has received in step 1. It
provides same request id along with the processed data in payload.

Step4 : Module A has to respond with “Ok” messaged to notify Module B that
it has received the response.

*Now Module “B” is free to send other responses to Module A .  *

Let me know if this helps .

[image: cid:image003.png at 01D1E1CE.F45B6D00]



*From:* zeromq-dev [mailto:zeromq-dev-bounces at lists.zeromq.org] *On Behalf
Of *Maciej Wewior
*Sent:* Tuesday, July 19, 2016 2:22 PM
*To:* zeromq-dev at lists.zeromq.org
*Subject:* [zeromq-dev] multiple REQ-REP sockets, polling responses

Hi all

I have 2 nodes communicating by means of multiple ZMQ sockets. The way they
talk to each other is request-response, from some reasons I want to have
separate sockets for each established connection.
Since they communicate in the classic request-response manner I thought I
could use REQ-REP ZMQ socket pair for each socket connection. But then I
realised that due to synchronous nature of REQ-REP I will have to wait for
each single response till I'm able to send a request on another ZMQ socket
(and I don't want this restriction).

Could someone give me an advice how to deal with that using ZMQ?
I would like to be able to send some number of requests through separate
sockets one after another (without waiting for response) and then poll all
the responses and process them one after another (order doesn't matter).
(I now I could for example use PUB-SUB socket pair instead of one REQ-REP
socket and fire requests using the 1st ones from the pair and poll the
responses from the 2nd ones, but that seems more complex than I would like
it to be)

Thanks in advance.

Maciej Wewior
Senior Software Developer

fixed +48 22 213 8297
[image: cid:part1.05090909.08020906 at is-wireless.com]
ul. Pulawska 45b
05-500 Piaseczno/near Warsaw
Poland, EU
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20160719/80d435b8/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 10213 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20160719/80d435b8/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 4341 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20160719/80d435b8/attachment-0001.png>

More information about the zeromq-dev mailing list