The Latest State of Perl ZMQ Bindings

I just uploaded the latest batch of zeromq (libzmq) bindings for Perl. They will eventually replace the current binding, ZeroMQ.pm. It's a big refactor, but it's one that will allow me to provide a far more stable bindings.

Note: they are still all dev releases, so will not show up by default in your CPAN client.

If you have comments, please speak up now!

WTF is 0MQ/ZMQ/ZeroMQ ?

Read it here. It's a fairly complicated library, one that allows for a fairly complex networking framework with ease. One thing that people often get confused is that it's not a "message queue" a.la RabbitMQ/ActiveMQ/Q4M. It's a "message oriented" networking framework.

Mongrel2 is a good real-life use case. While I haven't actually seen the code, I hear that dotCloud also builds their auto-deploy infrastructure around ZMQ.

Rationale For Making All This Change

  • I had been asked to rename the bindings to "zmq" something by the maintainers of libzmq, so a rename was bound to happen
  • Following up with the incompatible changes between the various libzmq versions was /really/ hard. I really wanted to separate out libzmq2 and libzmq3 out
  • Constants kept appearing and disappearing, therefore auto-generating these caused great havoc. I need a static list of constants.
  • The original interface provided by ZeroMQ sucked ( I can't remember now, but it's probably my fault ). Some functions threw exceptions, some functions returned error codes. This needed to be cleaned up

Repository

The main repository is now at p5-ZMQ. All of the related modules that I control are now in this repo.

LibZMQ2 and LibZMQ3 - The Raw Bindings

Now the "raw" bindings are named ZMQ-LibZMQ2 and ZMQ-LibZMQ3. Their task is simple: to provide an as-close-as-possible one-to-one mapping to libzmq's interface. There are small exceptions, but now almost all of the functions should accept and return values that the underlying libzmq promises to accept and return. I took care of some corner cases where $! wasn't properly set, too, so you should be able to expect this to work like libzmq as well. These modules supercede ZeroMQ::Raw.

Constants

ZMQ::Constants has been ripped apart from the main binding, because I wanted a consistent list of constants that doesn't rely on the underlying version of libzmq the binding was compiled with.

Perl-ish Interface

ZeroMQ.pm used to provide a Perl-ish interface, but that also relied heavily on the underlying libzmq version. Now we have a pure Perl wrapper around LibZMQ2 and LibZMQ3 that makes calls to the Perl bindings: ZMQ.pm

I think the JSON serializer was a cool idea, but I ripped it apart so that only the hooks are in the ZMQ distribution.

CZMQ

There's also an experimental CZMQ (http://czmq.zeromq.org) wrapper. I haven't quite tested this, and I currently don't plan to use it. If you are interested, I'd greatly appreciate test cases. Please see ZMQ-CZMQ

2 Comments

Thank you for working on this!

I'm working on a higher-level API for declarative/configuration-driven setup of networks of 0MQ components (devices in 0MQ speak). It's not quite ready for prime time yet as I'm still beating the actual configuration file's spec into shape (http://rfc.zeromq.org/spec:17), but it's probably good enough for other devs to play with: https://github.com/tsee/ZMQ-Declare-Perl

Right now, I'm rewriting it to incorporate the changes I've done to the ZDCF spec (see above), so the examples and docs are out of whack, but I plan to fix that in the upcoming couple of commutes.

Leave a comment

About lestrrat

user-pic Japan Perl Association director; LINE, Inc; Tokyo, Japan