Enterprise Integration Zone is brought to you in partnership with:

Mitch Pronschinske is a Senior Content Analyst at DZone. That means he writes and searches for the finest developer content in the land so that you don't have to. He often eats peanut butter and bananas, likes to make his own ringtones, enjoys card and board games, and is married to an underwear model. Mitch is a DZone Zone Leader and has posted 2569 posts at DZone. You can read more from them at their website. View Full User Profile

ØMQ - Fast, Broker-Free Messaging

07.27.2010
| 16489 views |
  • submit to reddit
ZeroMQ (or ØMQ) is an open source messaging library supported by the iMatix Corporation.  It has been described as messaging middleware, TCP on steroids, and now is just "a new layer on the networking stack."  Basically it allows you to design a complex communication system simply and programmatically by giving you a special socket interface.  Nicholas Piël recently introduced this new 'MQ' that fills a different use case than complete messaging systems such as RabbitMQ or ActiveMQ.  Here are a few basic descriptive points:

  • Sends and receives messages asynchronously (a.k.a. "message queueing").
  • Supports different messaging patterns such as point-to-point, publish-subscribe, request-reply, paralellized pipeline and more.
  • Is fast. 13.4 usec end-to-end latencies and over 8M messages a second today (InfiniBand).
  • Is thin. The core requires just a couple of pages in resident memory.
  • Supports different transport protocols: TCP, PGM, IPC, and more.
  • Runs on HP-UX, Linux, Mac OS X, NetBSD, OpenVMS, Solaris, Windows, AIX, and more.
  • Supports microarchitectures such as x86, AMD64, SPARC, IA-64, ARM, and more.
  • Is fully distributed: no central servers to crash, millions of WAN and LAN nodes.
  • ZeroMQ bindings exist for: Ada, C, C++, Common Lisp, Erlang, Go, Haskell, Java, Lua, .NET, OOC, Perl, PHP, Python, and Ruby.

ZeroMQ is between a low level Berkeley socket interface and a high level messaging system.  It takes the ease of implementation from the high level and some of the flexibility and performance from the low level.  It's also a lot faster than most AMQP messaging systems because it can use intelligent message batching and efficient transports like reliable Multicast or the Y-suite IPC transport.

Sending messages with ZeroMQ is very simple compared to raw socket implementations (where you must constantly feed the socket buffer).  When you fire an asynchronous send call, ZeroMQ will queue the message in a separate thread and handle all of the work - perfect for an event-based framework.  ZeroMQ is also versatile enough to let you encode the message however you like (JSON, BSON, Protocol Buffers, or Thrift).

This Python code shows you how you could create a broadcasting server for live football/soccer events:
import zmq
from random import choice
context = zmq.Context()
socket = context.socket(zmq.PUB)
socket.bind("tcp://127.0.0.1:5000")

countries = ['netherlands','brazil','germany','portugal']
events = ['yellow card', 'red card', 'goal', 'corner', 'foul']

while True:
msg = choice( countries ) +" "+ choice( events )
print "->",msg
socket.send( msg )
In terms of scalability, ZeroMQ sockets may look low level, but they actually have quite a few features and can, for example, connect to multiple end points and automatically load balance messages over those points.  It can also collect messages from multiple sources through a single socket.  Because of ZeroMQ's brokerless design, it has no single point of failure.  

You should really take a look at Nicholas Piël's blog post, which describes how to implement a message layer with ZeroMQ using several common paradigms.

ZeroMQ is distributed under the LGPL and contributions are made under the MIT (X11) license.

Comments

Amin Abbaspour replied on Wed, 2010/07/28 - 12:30am

Good unless one needs persistent messaging (which is a must in many use-cases.)

Mitch Pronschinske replied on Wed, 2011/11/30 - 1:13pm in response to: Amin Abbaspour

Some just add one to their stack and use ZeroMQ for what it's good at.  I've seen a use case that included ZeroMQ and Kafka, the distributed persistent message queue that Linkedin uses.

Jhon Andrew replied on Tue, 2013/06/11 - 7:24am

 

 sales online 

Congrats for making it possible for creating this blog. I may not always visit this blog to see more updates but i will consider every valuable information i read here. Please keep up the good work and good luck for the upcoming post.



Uchenna Ani-Okoye replied on Sun, 2013/12/22 - 5:13pm

Sounds like an interesting messaging library, can see why someone may want to use it. Though it's not something I've yet to put to use.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.