[zeromq-dev] Subscribing in JAVA api
Robin Weisberg
robin at scout-trading.com
Wed May 12 14:25:52 CEST 2010
Oops I meant
Instead of
int rc = zmq_setsockopt (s, option, value, strlen (value));
maybe do
int rc = zmq_setsockopt (s, option, value, env-> GetStringUTFLength (optval));
-----Original Message-----
From: zeromq-dev-bounces at lists.zeromq.org [mailto:zeromq-dev-bounces at lists.zeromq.org] On Behalf Of Robin Weisberg
Sent: Wednesday, May 12, 2010 8:24 AM
To: 0MQ development list
Subject: Re: [zeromq-dev] Subscribing in JAVA api
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: zeromq-dev-bounces at lists.zeromq.org [mailto:zeromq-dev-bounces at lists.zeromq.org] 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
zeromq-dev at lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
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