Skip to content

Latest commit

 

History

History
79 lines (51 loc) · 1.93 KB

mqtt-intro.md

File metadata and controls

79 lines (51 loc) · 1.93 KB
description
Running these Zilla samples will introduce some MQTT features.

MQTT Intro

Get started with Zilla by deploying our Docker Compose stack. Before proceeding, you should have Docker Compose installed.

MQTT Broker onto Kafka event streams

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.

Setup

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 -->

:::

Run Zilla and Kafka

docker-compose up --detach

Send a greeting

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.

Remove the running containers

docker-compose down

::: tip See more of what Zilla can do Go deeper into this concept with the Running an MQTT Kafka broker example. :::

Going Deeper

Try out more MQTT examples: