[zeromq-dev] Difference between NetMQ and jeromq
Daniel Cleyne
D.Cleyne at qsrinternational.com
Wed Dec 4 09:22:15 CET 2013
Folks,
We are just starting out with ZMQ and have been working with Pub/Sub examples to help us in one of our applications. I wrote a Java test application and it works ok on the subscribe side. I've spend today trying to port it to NetMQ without any success. Doesn't matter what I try with the subscription calls on the socket, I don't get messages. I'll post the code from the different languages in the hope that someone can tell me what I'm doing wrong...
Java (using jeromq):
public void run()
{
_Running = true;
Context context = ZMQ.context(2);
ZMQ.Socket socket = context.socket(ZMQ.SUB);
socket.connect (_ConnectionString);
socket.subscribe(new byte[0]);
while (_Running)
{
ByteBuffer reply = ByteBuffer.wrap(socket.recv(0));
if (reply.hasRemaining())
{
reply.order(ByteOrder.BIG_ENDIAN);
switch (reply.getInt())
{
case 0:
notifyStatusMessage(reply);
break;
case 1:
notifyLogMessage(reply);
break;
}
}
}
socket.close();
context.term();
}
C-Sharp (using NetMQ)
public void Start()
{
var task = Task.Factory.StartNew(() =>
{
var context = NetMQContext.Create();
var socket = context.CreateSubscriberSocket();
socket.Connect(_ConnectString);
socket.ReceiveReady += socket_ReceiveReady;
socket.Subscribe(new byte[0]);
_Poller = new Poller();
_Poller.AddSocket(socket);
_Poller.Start();
}, _TokenSource.Token);
}
Any help would be appreciated.
Cheers,
Dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20131204/1f08d77f/attachment.htm>
More information about the zeromq-dev
mailing list