ZeroMQ is a simple and robust asynchronous messaging layer.1 Unfortunately, using it with Clojure is far from simple. The steps below are the magic key that worked for me:
- Starting out nice and slow, install the core zmq libraries and command line tools with homebrew:2
- With ZMQ installed, you’re ready to start building jzmq, the Java bindings. You’ll need to patch the homebrew formula for pkg-config, as jzmq requires the latest-and-greatest to build correctly3
- At this point, you’ll need to copy one of the essential pkg-config files into a location that jzmq’s build tools can find.4
- Now we’re ready to build jzmq. This will build the dylib you’ll need to actually use the bindings, and places it in
/usr/local/lib
.5
- Getting closer! We’ll need the zmq.jar file produced during the build, so copy that into your project’s lib directory:6
- Now we can actually start setting up Clojure for ZMQ. Edit your leiningen project.clj file:
- Collect the leiningen dependencies:
- Start your swank server:
- Bask in the results with the canonical example:
This process is definitely rough around the edges, but I hope it helps you get started quickly!
-
Read this excellent ZeroMQ introduction if you’re not familiar with ZMQ. You’ll love it. ↩
-
This guide is EXTREMELY
brew
-centric. If you’re running OS X, you should be using homebrew for dependency management. ↩ -
There’s an open ticked to update pkg-config in the homebrew backlog, so this may be unnecessary soon. ↩
-
This step should either be taken care of by homebrew, or by jzmq’s
./configure
, but I wasn’t able to get it working. Please leave a note if you know how I could resolve this step! ↩ -
This is another step that seems problematic. It would be best to just install the dylib straight into OS X’s Java extensions directory. Again, please leave a comment if you can help! ↩
-
Another hacky step. I gather it’s possible to build jzmq with leiningen, but the
native-deps
dependency doesn’t seem to work with lein 1.3.0. Suggestions? ↩