description |
---|
Running these Zilla samples will introduce some MQTT features. |
Get started with Zilla by deploying our Docker Compose stack. Before proceeding, you should have Docker Compose installed.
Running this Zilla sample will create a simple API to create and list items. All of the data will be stored on a Kafka topic.
Create these files, zilla.yaml
and docker-compose.yaml
, in the same directory.
::: code-tabs#yaml
@tab zilla.yaml
<!-- @include: ./zilla.yaml -->
@tab docker-compose.yaml
<!-- @include: ./docker-compose.yaml -->
:::
docker-compose up --detach
Using eclipse-mosquitto subscribe to the zilla
topic.
docker run -it --rm eclipse-mosquitto \
mosquitto_sub --url mqtt://host.docker.internal:7183/zilla
In a separate session, publish a message on the zilla
topic.
docker run -it --rm eclipse-mosquitto \
mosquitto_pub --url mqtt://host.docker.internal:7183/zilla --message 'Hello, world'
Send messages with the retained flag.
docker run -it --rm eclipse-mosquitto \
mosquitto_pub --url mqtt://host.docker.internal:7183/zilla --message 'Hello, retained' --retain
Then restart the mosquitto_sub
above. The latest retained message is delivered, and the other messages are not.
docker-compose down
::: tip See more of what Zilla can do Go deeper into this concept with the Running an MQTT Kafka broker example. :::
Try out more MQTT examples: