In a decoupled architecture where are, modules are working independently but closely, they need interaction. Today is the world of real-time and all modules should get sync in real time only.
We have used MQTT for such cases. MQTT is very lightweight, fast and highly scalable. It’s an amazing framework and protocol developed by IBM. It’s a publisher/subscriber framework.
A module can subscribe to multiple channels, and all those modules which want to send some message to those modules they can publish the message to the same channel.
To read about: PHP Vs Node Performance
The protocol has two major modules:
Publishers publish messages on the system on a channel. This can listen to all clients who have subscribers on same
Subscribers subscribe messages on a channel. They are listening to channels which they have subscribed and all messages on the same channel reached to them.
Brokers are the main module, it is keeping all information with itself for publisher and subscribers and send the message accordingly.
There are three QOS (Quality of Service) parameters :
1.QOS = 0
It will deliver the message but the guarantee is not there. Let’s say a client is not connected and the message is lost there is no way it can receive the message again. It’s the lightest in weights in terms of speed and performance.
2. QOS = 1
It will deliver the message and guarantee is there. But there are chances that client can receive one message more than once.
3. QOS = 2
It will deliver the message and guarantee is not there. The client will receive only one copy of the message. This is little costly in terms of scalability.
For free consultation Contact Us
MQTT can store messages in DB like MongoDB (We have used MongoDB) or it may not retain messages at all is also an option.
We have used MQTT at multiple projects: Clients are there in Node, Python, Java and.NET and others.
You can also take a look at Content Consumption Pattern through Mobile Apps
There are two brokers which have tried out:
And both are very good.
MQTT protocol is used heavily in IOT industry because of it being lightweight and scalable.