MQTT Cloudlet quickstart
The MQTT cloudlet quickstart can be used as a base for the fat-jar MQTT microservices.
Creating and running the MQTT cloudlet project
In order to create the MQTT cloudlet project execute the following commands:
To start the MQTT cloudlet execute the following command:
You can also build and run it as a Docker image (we love Docker and recommend this approach):
MQTT broker
By default MQTT cloudlet quickstart starts embedded ActiveMQ MQTT broker (on 1883 port). If you would like to connect your cloudlet application to the external ActiveMQ broker (instead of starting the embedded one), run the cloudlet with the BROKER_URL
environment variable or system property, for example:
...or...
Sample chat application
The MQTT cloudlet quickstart is in fact a simple chat application. Clients can send the messages to the chat channel by subscribing to the broker and sending the messages to the chat
MQTT topic. To send some messages to the chat you can use the standalone MQTT.js client:
The clients can subscribe to the chat updates by listening on the chat-updates
MQTT topic - whenever the new message has been sent to the chat, the clients registered to the chat-updates
will receive the updated chat history.
The quickstart also exposed the simple REST API that can be used to read the chat history using the HTTP GET
request:
Architectural overview
When MQTT cloudlet is started with the embedded ActiveMQ broker, the architecture of the example is the following:
When you connect to the external ActiveMQ broker (using BROKER_URL
option), the architecture of the example becomes more like the following diagram:
Last updated