Open-Source: Asynchronous Messaging Service (AMS)

I’ve recently open-sourced my side project on GitHub that is Asynchronous Messaging Service (AMS).

In summary, it is a message passing framework based on ZeroMQ for low latency distributed systems seeking loose-coupling, fault-tolerance, dynamic discovery and scalability.


Asynchronous message passing systems deliver a message from sender to receiver, without waiting for the receiver to be ready. The advantage of asynchronous communication is that the sender and receiver can overlap their computation because they do not wait for each other.

The reactor used in AMS handles requests delivered concurrently by multiple event resources. Message dispatcher handles registering and unregistering of application-defined message handlers, and dispatches messages from the demultiplexer to the associated handlers. Event demultiplexer uses an event loop to block on all resources.

In a data system based on AMS, any module may be introduced into or removed from the system at any time without inhibiting the ability of any other module to continue sending and receiving messages. The system’s modules have no inter-dependency to become or stay operational.

By publish–subscribe pattern used in AMS, senders of messages called publishers do not program the messages to be sent directly to specific receivers. Instead, published messages are characterized into classes, without knowledge of subscribers. Similarly, subscribers express interest in one or more classes, and only receive messages that are of interest, without knowledge of publishers.

AMS-based systems are highly robust, lacking any single point of failure and tolerant of unplanned module termination.

AMS provides dynamic discovery of publishers and subscribers that makes your applications extensible. This means the application does not have to know or configure the endpoints for communications because they are automatically discovered. AMS will also discover the type of the data being published. If multicast is not supported for target environment or dynamic discovery is not preferred method, AMS also uses a configuration file (config.xml) during initialization to determine peers in the network topology.

Communication within an AMS-based system is rapid and efficient because;

  • Messages are exchanged directly between modules rather than through any central message dispatching nexus (i.e. brokers).
  • Messages are automatically conveyed using the most suitable underlying transport service (TCP/IP) to which the sending and receiving modules both have access.

Finally, AMS provides high scalability; hundreds or thousands of cooperating modules have no significant impact on application performance.


Below is the application programming interface of the AMS C++ library:


Example Usage

We should define message classes first. AMS message classes can be composed from primitive types, other classes and standard containers (only vector and map).

Here is the example publisher that sends hundred messages containing the message order as a value.

Here is the example subscriber that (if enough waited) receives hundred messages published and handles them according to custom defined operation in message handler class.

Complete source code of this example project can be found here.


Licensed under the Apache 2.0 license.

Originally published at on December 9, 2013.

Software engineer. Distributed systems enthusiast. #data, #iot, #mobile, #scalability, #cplusplus, #java

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store