Understanding zeromq `zmq_msg_send` with `ZMQ_SNDMORE`

73 views
Skip to first unread message

Ashish Negi

unread,
Jun 1, 2016, 12:14:30 PM6/1/16
to zeromq
Hello,
Thanks for amazing library. I am going through the documentation at zguide. :)

I am at "Shared Queue (DEALER and ROUTER sockets)".
The code of rrbroker.c has following code while sending multiple parts of the message from frontend to backend :

                           while (1) {
// Process all parts of the message
zmq_msg_init (&message);
zmq_msg_recv (&message, frontend, 0);
int more = zmq_msg_more (&message);
zmq_msg_send (&message, backend, more? ZMQ_SNDMORE: 0);
zmq_msg_close (&message);
if (!more)
break; // Last message part
}

My question is :
1. Is the while loop required to get 1 complete message ?
2. If we send message to `backend`, when their are multiple backends, would all messages be received by same backend ?

Looking on my own, i think answer is "Yes" for 1 and should be "Yes" for 2.
However, how is 2) implemented ? Where is this information stored about sending the next parts of the messages to a particular backend ?
I would not find anything in "msg_t" for this thing.

The questions may be simple (stupid.. ?) but please do give me some hints.
Thanks.
 

Ashish Negi

unread,
Jun 1, 2016, 12:39:32 PM6/1/16
to zeromq
I did ran some tests with `multiple workers` and `multiple clients`.
I am sending msg via `s_sendmore` in two chunks and it seems that each worker is getting the message correctly but via two `s_recv`.

So, my question now boils down to how is it implemented that messages in chunks are received by same backend ?

Reply all
Reply to author
Forward
0 new messages