You can also build and run it as a Docker image (we love Docker and recommend this approach):
TARGET_IMAGE=yourUsername/rhiot-cloudlets-mqtt
mvn install docker:build docker:push -Ddocker.image.target=${TARGET_IMAGE}
docker run -it ${TARGET_IMAGE}
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:
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: