[zeromq-dev] Subscribing in JAVA api

Chris Wong chris at chriswongstudio.com
Fri May 14 05:39:45 CEST 2010

On May 12, 2010, at 2:40 AM, Martin Sustrik wrote:

> Hi Chris,
>> I think Robin meant that the subscriber wants to subscribe to
>> messages of topic "animals.mammals" and not receiving message of
>> topic "animals.mammals.cats"
>> In C, we'd call setsockopt with "animals.mammals\0"
> Nope, you should do it this way:
> zmq_setsockopt (s, ZMQ_SUBSCRIBE, "animals.mammals", 15);
> Note that the data passed to the socket option do not contain the 
> terminal zero.
> Any message starting with "animals.mammals" will match the subscription.

Hi Martin, that's why I said "not" receiving animals.mammals.cats.  There are cases we'd want to subscribe to an *exact* topic.  ZeroMQ's prefix topic matching is similar to AMQ's topic.prefix.# pattern matching.  But AMQ by default let you do exact topic match so that animals.mammals will only match animals.mammals.

>> What's the Java way of doing that?
> s.setsockopt (ZMQ.SUBSCRIBE, "animals.mammals");
> Martin
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev

More information about the zeromq-dev mailing list