[zeromq-dev] What ZMQ will do when I use the multipart message

Joshua Foster jhawk28 at gmail.com
Thu Sep 22 05:15:13 CEST 2011


A multipart message is just a message of many parts. You create a 
multipart message by sending with the ZMQ.SNDMORE flag like this:
socket.send(myfirstbytes, ZMQ.SNDMORE);
socket.send(mysecondbytes, 0);

That would create a 2 part message. Its usually helpful for adding flags 
for context switching (knowing what type of message is sent). You can 
see this in some of the protocols like the paranoid pirate protocol 
(http://rfc.zeromq.org/spec:6).

ZeroMQ looks at the multipart message atomically so it either all 
arrives or it doesn't at all. The other implication is that you can't 
"stream" parts of a message. It all needs to fit in memory.

You can determine if you have more parts to a message by using the 
socket.hasRecvMore() method like this:
data = socket.recv(0);
while (socket.hasRecvMore()) {
   moredata = sockect.recv(0);
   // do something with moredata...
}
// no more parts to the message anymore

Joshua

On 9/21/2011 9:55 PM, jjmilk13 wrote:
> Hi all
>     I'm using ZMQ in java.
>     And now I'm confusing about what ZMQ will do when I use the 
> multipart message.
>     Does it cut the messages piece by piece automatically?
>     What if id does,//I still don't know how big is piece it been cut 
> into?
>     And what if id does not, how can I deal with it?
> Thanks
> jinjing wu
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110921/78901309/attachment.htm>


More information about the zeromq-dev mailing list