[zeromq-dev] Issues with Java bindings on Mac OS X 10.6.8

Tero Paananen tpp.paananen at gmail.com
Mon Aug 29 23:03:42 CEST 2011


I'm having issues with getting pub / sub working on a Mac OS X 10.6.8
using the Java bindings.

Compiled and installed zeromq and jzmq using these instructions:

http://antoniogarrote.wordpress.com/2010/09/08/zeromq-and-clojure-a-brief-introduction/

(obviously with the latest versions of everything).

Simple pub / sub example is not working:


import org.zeromq.ZMQ;
import org.zeromq.ZMQ.Context;
import org.zeromq.ZMQ.Socket;

public class subs {
	public static void main(String[] args) throws InterruptedException {
		
		Context context = ZMQ.context(1);

		Socket listener = context.socket(ZMQ.SUB);
		listener.bind("tcp://127.0.0.1:5560");

		byte[] message = listener.recv(0);
		String msg = new String(message);
		System.out.println(msg);

		listener.close();
		context.term();
	}
}



import org.zeromq.ZMQ;
import org.zeromq.ZMQ.Context;
import org.zeromq.ZMQ.Socket;

public class publ {
	public static void main(String[] args) throws InterruptedException {
		Context context = ZMQ.context(1);
		Socket messenger = context.socket(ZMQ.PUB);
		messenger.connect("tcp://127.0.0.1:5560");

		messenger.send(args[0].getBytes(), 0);

		messenger.close();
		context.term();
	}
}

I start the subs, and run the publ. Publ executes, subs doesn't report
receiving the message.

I change the socket type on subs to ZMQ.PULL and everything works marvelously.

Any ideas?

I'm currently installing the same stack on a Ubuntu to see if it works
on that platform.

-TPP



More information about the zeromq-dev mailing list