But what if the C applications were publishing on 2 topics "animals.mammals\0" and "animals.mammals.kitty\0" and I wanted ONLY the ones on "animals.mammals\0"? I would have to change all the existing c++ listeners and publishers to use a different delimeter e.g. "animals.mammals|" and "animals.mammals.kitty|" because the java api doesn't handle specifying "\0" right?
Looking at the JNI api I see a there are methods like GetStringUTFLength. Instead of int rc = zmq_setsockopt (s, option, value, strlen (value)); maybe do int rc = zmq_setsockopt (s, option, value, env->GetStringUTFChars (optval, NULL)); And then you can subscribe using "animals.mammals\u0000" in the java code? I'm happy to try this out if we agree it's a better approach. Robin -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Martin Sustrik Sent: Wednesday, May 12, 2010 3:40 AM To: 0MQ development list Subject: Re: [zeromq-dev] Subscribing in JAVA api 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. > What's the Java way of doing that? s.setsockopt (ZMQ.SUBSCRIBE, "animals.mammals"); HTH Martin _______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev _______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
