Traditional Web applications may not require reliable messaging services, but the various terminals currently represented by the Internet of Things need a message protocol to provide services.
Architectural patterns come and going, if there is an immutable thing, it is necessary to have a reliable message transmission.
Message Queuing may have had its peak in the client/server world, it handles information exchange between mainframes and connects to our financial network, but it never leaves us---despite the fact that direct access to the API is the main feature of most current developments.
The Direct Access API works well in most of our web systems, with limited server resources and the back end of process communication. But when we move to the micro-service architecture and the cloud---especially when we face the internet of things, things change.
Suddenly, due to the internet of things, we will deal with countless component systems deployed by different rules, as well as thousands of business messages from terminals that may not be tens of thousands. In this case, the famous MVC design pattern will not be used, so we need to switch to microservices-safe mode, go back to the computer scene concept as a participant, use the participant/message mode to handle how our service communicates with any number of terminals.
Release a subscription for rescue
This is what Message Queuing tools do, and using the Publish/Subscribe model provides a reliable way to transfer data to the server side. A microservices contributor can subscribe to a published connection and trigger a corresponding action on the received message. This model is ideal for connecting devices and services, and ensuring a stable service when new devices are growing.
The MQTT (Message Queuing Transport Protocol) developed by IBM is a lightweight publish/Subscribe messaging protocol that is now standardized by Oasis. Originally designed as a large-scale WebSphere MQ system link to a SCADA device, MQTT evolved into a general purpose Message Queuing system that allowed one server to manage thousands of endpoints, a simple messaging protocol that is not limited to TCP/IP, Can be used by devices with limited processing capacity.
The Publish/Subscribe agreement is not unfamiliar. But it may be in the bottom of most developer toolboxes, a simple way to create a message bus for a service architecture. Mqtt is a simple execution of publish/Subscribe modules, published to a topic by a message, and the subject will be subscribed to by the client application. Topics are hierarchical, so you can subscribe to different levels of information elements in a resource.
Classification of topics
For example, a series of sensors in a freezer in a truck can form a hierarchical theme format: Freezer sensor/truck/temperature/area, where trucks and zones can be used to identify filtering information: Multiple vehicle information in a vehicle or area.
Applications can subscribe to the topics available on the MQTT server, use explicit subscriptions to get the specified message seed, or use wildcards to get messages clustered at different levels of the topic. You can use wildcards to replace one or all of the remaining elements in a hierarchical schema.
In our case, the meter truck + freezer sensor + temperature allows us to see the temperature of all the trucks in all areas, while the freezer sensor/Truck # will get the data on all the refrigeration sensors named Truck 1. This approach means that you may be using multiple microservices to handle different topics-one that handles specific sensors or data on a daily basis, another that handles observation errors, and so on.
MQTT provides the option to keep the last message sent, so when the current client connects to the server, it is possible to download the initial message at the same time as the subscription without waiting for a new message to be sent from the source. The source also has an option of "will"-a message that is pre-stored on the server for delivery when disconnected. The client can disconnect in will mode, but if they do not empty the sesssion tag, they can reconnect and view the existing subscriptions. Joint use of the session flags and wills allows you to deal with problems originating from unstable networks and the scale of automated services.
Set Quality of service
One of the most useful features in MQTT is the ability to set QoS rules for your messages. There are three QoS levels available:
Level 0: Is the best labor option, which is an unconditional retry after an error. This approach is well suited for continuous monitoring like trending transactions rather than actual messages. As part of the control system, you may use level 0 to connect to a stream processor or a machine learning system to handle a large number of messages.
Level 1: Is the "at least once (at least once)" option for messages that can be guaranteed to be delivered, although multiple deliveries may occur. If you are dealing with fewer messages, you will have the best option to process duplicates programmatically. Very fast, low impact, and can work with a variety of application modules.
Only once: the most computationally emphasized level, but it guarantees that each message is received and only once.
Internally, Mqtt is a very simple protocol that provides ideas for building the processing power in IoT applications or hyper-scale clouds. When new devices are added to the network, they can quickly become a new theme resource while new clients can create them to subscribe to the topic at the same time. The URI scheme makes it very easy for the connection server to receive messages. There are a number of tools available to help test MQTT connections, including desktop and mobile apps---even apps that use WebSockets.
Using MQTT to create message-driven services for the internet of Things is simple, with a variety of services including well-known Mosquitto and case code for Arduino and other manufacturers. At the client, MQTT is supported by well-known tools, including node.js-based on the Secene microservices framework and Visual node-red programming environment, Get started creating your app with a growing community forum.
Worried about how the MQTT protocol can be implemented in the real world? Here's a good proof: it supports the biggest and busiest apps on the Internet: Facebook's Messenger
This article from: http://www.totcms.com/html/201508-7/20150807133726.htm
How to apply the MQTT protocol to the Internet of Things (IoT)