[zeromq-dev] Multi-part messages

Martin Sustrik sustrik at 250bpm.com
Mon Apr 5 08:58:02 CEST 2010


>>>> zmq_msg_t msg;
>>>> ...
>>>> int tbc = msg.flags & ZMQ_MSG_TBC ? 1 : 0;
>>> I guess this is the API then :)  I will think about how to represent
>>> this in Python.
>> Any idea is welcome. I've made up a list of requirements to figure out 
>> how the API should look like:
> We should define this ASAP. Your suggesting the workaround that people peek
> inside zmq_msg_t is just horrible and we really don't want to go that way.
> Ever. It directly contradicts all of the documentation which explicitly
> tells people to never access a zmq_msg_t directly.

Horrible, eh? :)

> I'd like to propose the following:
> 1) We see that "message options" is a possible extension point. So, let's
> define it with zmq_getmsgopt() and zmq_setmsgopt(). Even if we don't use it
> for anything other than ZMQ_MSG_MORE for the next two years, at least it's
> defined.
> 2) Given the above, the construct
>     zmq_getmsgopt (&msg, ZMQ_MSG_MORE, &have_more, sizeof have_more);
> is going to be used extremely frequently. So, we define an additional
> *alias* which is
>     int /* (boolean TRUE/FALSE) */ zmq_msg_more (&msg);
> this is not inconsistent with the other zmq_msg_* functions such as
> zmq_msg_size (), and leads to a nice way of expressing code such as
>     do {
>         rc = zmq_recv (socket, &msg, 0);
>         /* process message part */
>     } while (zmq_msg_more (&msg));
> I think that this fulfills all your defined requirements nicely and can map
> to OO-style language bindings also as msg.more().

The main question here is how to access the functionality from 
individual languege bindings. Note that in most of them the message is a 
simple BLOB with no flags.

On the send side ZMQ_MORE makes using it from any language easy. Not 
sure about recv side...


More information about the zeromq-dev mailing list