[erlang-questions] 0MQ libraries

Ciprian Dorin Craciun ciprian.craciun@REDACTED
Sat Feb 8 14:39:33 CET 2014


    (Sorry for "reviving" this thread, but only now I've managed to
drain the mail queue.)  :)


On Fri, Jan 31, 2014 at 9:12 AM, Joe Armstrong <erlang@REDACTED> wrote:
> Why don't we just use gen_tcp and interact with 0MQ peers using the
> wire-line protocol. Erlang is good at getting data in and out of sockets,
> and good at parsing binary packets.
>
> I'm not suggesting implementing all the protocols and transports to start
> with just the REQ - REP protocols of TCP
>
> [...]


    Implementing a pure Erlang ZeroMQ library that understands only
TCP and some of the basic patterns (such as (X)REQ/REP, PULL/PUSH), as
Joe has suggested, could easily be a weekend project (within some
acceptable performance limits), as the wire protocol is almost
trivial, and the routing logic for the mentioned patterns is simple.


    However ZeroMQ offers two orthogonal set of "abstractions":
    * the patterns, which can be natively implemented in Erlang;
    * the transports, some of which can't be implemented in pure
Erlang (e.g. UNIX socket domains);
    * (let alone the other features such as HVM, and the new additions in 4.x);

    And the true power of ZeroMQ lies in the various ways we can
combine the above features, all interoperable from one language to the
other.  Thus having a myriad of partial implementations would just
break the ecosystem into isolated islands  (like I guess happened with
AMQP).


    However...

> ( actually all I want to do is get Erlang talking to Julia - Julia speaks
> 0MQ and I found that I
> couldn't build the Erlang 0MQ bindings with the latest 0MQ - so I'm again
> back to
> "fixing stuff thats broken" in order to do what I want.

    For such a use-case, and other situations where a full ZeroMQ
library is not needed, one could take the following shortcut:
    * he limits the usage to only (X)REQ/REP or PULL/PUSH, with only
one frame per interaction (plus the "destination" one in case of XREP,
and a "correlation" in case of parallel request / reply sessions);
    * he builds a simple C application which reads / writes on stdin /
stdout messages in the well-supported format <payload-size payload>
(maybe one per "destination", "correlation" and "payload") and
translates that to a ZeroMQ `send` / `recv`;
    * he then just uses this executable with `open_port` with `packet`
option;  (which in fact it could be reused in other non-Erlang
environments;)

    Of course if more about the application is known, one could make
other "simplifications", like use only JSON without embedded newlines,
and transform the protocol into one line per message  (such an
application could be used even from `sh`).  Moreover such an
application could be used at both ends, thus obtaining a poor-man's
messaging solution.  :)


    As such I would definitely see the need of both kind of ZeroMQ
interfaces for Erlang (or other languages): a binding based one, and a
"process" based one.

    Ciprian.



More information about the erlang-questions mailing list