Applications & Databases

Apr 6 ’11

Lightweight Messaging Middleware

6 Pages

No man is an island, and these days that goes for information systems, too. Getting systems to talk with one another reliably, efficiently, and simply has been the goal of multiple efforts over the years. Approaches have varied from mailboxes, simple socket programming, Distributed Computing Environment (DCE), Common Object Request Broker Architecture (CORBA), and Message-Oriented-Middleware (MOM). Associated with each approach are attributes of complexity, cost, and standards.

There are many good commercial, proprietary messaging offerings available today, and also some good open source offerings, one of which we’ll explore in this article. Several open source MOM options are available such as RabbitMQ and Apache’s ActiveMQ. A recent addition to the open source field is ZeroMQ or 0MQ.

The key attributes a messaging system should support include:

  • Low overhead; small footprint and minimal processor requirements
  • Ease of setup
  • The ability to send messages when the receiver isn’t yet ready.

Both RabbitMQ and ActiveMQ provide a complete “out of the box” system: just configure and go. 0MQ is more a library of routines you can use to “roll your own” messaging system, although that’s a simplistic description. 0MQ also has adapters (aka devices) ready to be incorporated into a service. The 0MQ authors define 0MQ with these terms:

  • Exploits socket library as a concurrency framework
  • Carries messages across in process, Inter-Process Communication (IPC), Transmission Control Protocol (TCP), and multicast
  • Connects n-to-n via fan-out, publish/subscribe, pipeline, request-reply
  • Is fast enough for clustered products and supercomputing
  • Uses asynchronous I/O for scalable, multi-core message-passing applications
  • Enjoys a large, active open source community
  • Supports more than 20 languages, including C, C++, Java, Microsoft .NET, and Python
  • Runs on most operating systems, including Linux, Windows, and OS X
  • Licensed under GNU Lesser General Public License (LGPL) free software with full commercial support.

To this set of definitions, we’d add that 0MQ has a small footprint with componentry that enables development of sophisticated messaging systems.

Socket Library

Writing distributed programs is one of the hardest things programmers do. We seem poorly suited to reason about processes running in parallel, and the normal tools such as mutexes, conditional variables, and semaphores can sometimes be fragile and hard to use.

0MQ is a messaging library used programmatically that provides a “pimped” socket interface (i.e., “sockets on steroids”) that supports building messaging systems (see Nicholas Piël’s excellent tutorial “ZeroMQ an Introduction” at http://nichol.as/zeromq-an-introduction).

Martin Lucina and Martin Sustrik, two of the main forces behind 0MQ, put it best in their January 20, 2010, article “0MQ: A New Approach to Messaging” (http://lwn.net/Articles/370307/):

“The low-level nature of the socket API leads developers to re-implement[ing] the same functionality on top of sockets over and over again. Alternatives exist in the form of various ‘I/O frameworks’ and ‘enterprise messaging systems’ but both of these approaches have their own set of drawbacks. The former are generally bound to certain programming languages or paradigms, while the latter tend to be bloated, proprietary solutions with resident daemons that hog system resources.”

6 Pages