Messaging

A messaging architecture is an alternative to an API architecture when two programs want to exchange data. In an API architecture, the sending program directly calls the services of the receiving program. In a messaging architecture, the sending program hands off the data (referred to as a message in this context) to an intermediary program (which is known as the message broker). The message broker queues up the messages. The receiving program (the processor) connects to the message broker and picks up the data/messages from the queue and processes it. In the context of an IoT solution, the gateway can be designed to be a message broker.

There are two reasons why this architecture works well for IoT solutions. One, sensors often need to read data continuously in real-time and cannot afford to waste resources and time waiting for the receiver to accept data. And two, sensors do not need a response from the receiver, their job is to read and forward and move on.

The other advantage of a messaging architecture is that multiple receivers can pick up data/messages from the message broker queues for processing, unlike an API architecture where it is one sender to one receiver.

This architectural pattern is highly decoupled, minimising the mutual awareness that applications need to have of each other (in terms of technology, design, data formats, etc.) to be able to exchange messages.

It could be a confusing detail but important to understand that the communication between the sensors and processors and the message broker (or gateway) still uses API.

Messaging Architecture