Message Queue for MQTT is lightweight messaging middleware released by Alibaba Cloud for mobile Internet and Internet of Things (IoT) scenarios. While traditional messaging middleware is generally used between microservices, Message Queue for MQTT, which is designed for IoT scenarios, transmits messages between clients and clouds and realizes the Internet of Everything in a real sense. This topic describes the architecture, scenarios, and benefits of Message Queue for MQTT.
In addition to Internet access, Message Queue for MQTT also supports virtual private clouds (VPCs). You have full control over your own VPCs, including configuring their IP address ranges, routing tables, and gateways. You can also use Alibaba Cloud resources such as Elastic Compute Service (ECS), ApsaraDB for RDS, and Server Load Balancer (SLB) instances in the VPCs you have set up.
- Topic: topic of the message, a level-1 message type. A producer publishes messages to a topic.
- Producer: also known as publisher. A producer produces and publishes messages to a topic.
- Consumer: also known as subscriber. A subscriber subscribes to and consumes messages from a topic.
- Message: the data that the producer publishes to a topic, which is finally transmitted to consumers.
- Rule: the resource that implements data exchanges between Message Queue for MQTT and other Alibaba Cloud services.
Message publish-subscribe models
Message Queue for MQTT supports the following message publish-subscribe models.
- The automatic publish-subscribe model on the device side
This model is applicable to data communication between mobile apps or devices. Its typical scenarios include chatting between users by using instant messaging technology, and app-based control over smart devices. In this model, message producers and consumers are distributed in the mobile environment and connect to Message Queue for MQTT over the MQTT protocol.
- The interaction model between devices and backend services
In this model, interactions between Message Queue for MQTTand other Alibaba Cloud services are implemented by using rules. This model is applicable to the following scenarios.
- A device publishes messages and the backend service subscribes to the messages: This scenario is applicable to data reporting. A typical example is reporting the status data of smart devices or reporting the data collected by mobile apps. In this model, messages are published by massive mobile devices and subscribed to by backend services. Data is generally published based on business scenarios, and backend services are usually deployed in the cloud, such as Alibaba Cloud ECS that consumes reported data in batches. Message Queue for MQTT exports data to other Alibaba Cloud services based on data outbound rules.
- The backend service publishes messages and a device subscribes to the messages: This scenario is applicable to command issuance. A typical example is controlling smart devices from a cloud or pushing messages from a mobile app. In this model, messages are published by backend apps, which are usually deployed in the cloud, such as Alibaba Cloud ECS whose message subscribers are mobile devices or apps. Message Queue for MQTT subscribes to the data from other Alibaba Cloud services based on data inbound rules.
The system technology stack
Message Queue for MQTT supports native persistent TCP connections, SSL encryption, WebSocket, and other transmission modes at the data transmission layer. It also supports mainstream programming languages and platforms including C and C++, Java, iOS, and Android. The following figure shows the system technology stack of Message Queue for MQTT.
Message Queue for MQTT supports a range of protocols, languages, and platforms, and is widely used in mobile Internet and IoT fields. Its applications cover mobile live streaming, the Internet of Vehicles, finance and payment, smart catering, instant messaging, and other scenarios.
The following figure shows the main scenarios of Message Queue for MQTT.
Message Queue for MQTT is similar to a connection gateway with unlimited scalability, which enables not only closed-loop message publish-subscribe and storage, but also rule-based data transmission. You can configure rules and use Message Queue for MQTT together with other Alibaba Cloud services, such as the traditional service-based messaging middleware of Message Queue for Apache RocketMQ or Message Queue for Apache Kafka, to implement two-way data exchanges between the cloud and the client.
Message Queue for MQTT adopts a distributed architecture to eliminate single point of failure (SPOF) and enable unlimited scale-out between components. This architecture ensures dynamic scaling based on your online usage, which is transparent to your users.
The following figure shows the benefits of Message Queue for MQTT.
Message Queue for MQTT delivers the following benefits over other mobile messaging services.
- It supports standard protocols, such as MQTT and STOMP. This means that no technologies are bundled with the apps, so you can use SDKs that are mostly open-source to seamlessly migrate your service to the cloud.
- As a persistent connection gateway used by massive mobile clients, Message Queue for MQTT exchanges data with other Alibaba Cloud messaging services by using backend rule engines. In this way, you do not need to set up your own gateway for your app to implement two-way communication between your client and the cloud.
- It supports device-level permission control and SSL or TLS encryption for communication to ensure improved data transmission security and reliability.