[zeromq-dev] message filtering

Martin Sustrik sustrik at 250bpm.com
Mon Dec 21 14:27:42 CET 2009

Hi all,

As 0MQ is still in alpha (going to switch to beta soon) it's still 
possible to modify the semantics of the API.

The problem experienced by Sebastien made me think of slight 
modification of the filtering mechanism.

The idea is not to prescribe any specific format of the message 
(currently size prefixed topic should be placed at the beginning of the 
message). Instead, filtering algorithm would filter messages on whatever 
content that happens to be at the beginning of the message.


Subscription "abc*" matches following messages

a b c

a b c d

a b c \x00


To match a specific zero-terminated string you would have to match for 
the whole string including the terminal zero:

zmq_setsockopt (x, ZMQ_SUBSCRIBE, "abc\x00", 4);

The advantages are:

1. No special requirements on the format of the message.
2. Topic string can exceed 255 bytes.

If you are not happy with the proposed change, please shout now!


More information about the zeromq-dev mailing list