How to use MQTT for IoT messaging

Ordinary Web applications may not need reliable messaging, but the multiplicity of endpoints represented by the Internet of things demands a messaging protocol that measures up

Architectural patterns come and go, but if there's one constant, it's the need for the reliable delivery of messages.

Message queuing may have had its heyday in the client/server world, handling communications with mainframes and gluing together our financial networks, but it never really went away -- despite the fact that direct access to APIs is the hallmark of much modern development.

Direct access to APIs works well for much of what we do on the Web, where a limited number of servers and processes communicate with a back end. Things change, however, when we move to microservices architectures and the cloud -- and particularly when we factor in the Internet of things.

Suddenly, with the Internet of things, we're dealing with systems made up of an unknown number of components, deployed by algorithms, and handling messages sent by thousands, if not millions, of endpoints. The familiar MVC design patterns break down at that sort of scale, so we need to shift to microservice-safe patterns, bring back computer science concepts like actors, and use actor/message patterns to handle how our services communicate with each other and any number of endpoints.

Publish/subscribe to the rescue

That's where message queuing tools come into play, providing reliable ways to deliver data to services using publish/subscribe methods. Microservice actors can subscribe to published connections and then receive messages that trigger appropriate actions. It's a model that works well, providing a way to connect devices to services, ensuring that a service scales and that as new devices are added, their messages get through.

To continue reading this article register now