---
title: Deploy Mosquitto with AI on Blossom
url: "/deploy/mosquitto/"
canonical_url: https://blossom88.com/deploy/mosquitto/
markdown_url: https://blossom88.com/deploy/mosquitto.md
summary: Run a private MQTT broker and read its retained device status after a Container
  update.
categories:
- deployment
- databases
stack:
- C
- MQTT
---

# Deploy Mosquitto with AI on Blossom

[Mosquitto](https://mosquitto.org/) is an MQTT broker. Devices publish
to a topic, and applications subscribe to the topics they need.

## Ask Your Agent

> **Ask your AI agent:** Deploy Mosquitto on Blossom and help me publish a device status that new subscribers can read.
>
> Follow this guide: https://blossom88.com/deploy/mosquitto/

[Install the Blossom CLI and skill](https://docs.blossom88.com/learn/getting-started/install/) on your agent's machine and [choose a Location in your cloud account](https://docs.blossom88.com/learn/getting-started/choose-your-cloud/#connect-your-provider).

## How It Runs

| Part | Role | Where |
|---|---|---|
| Mosquitto | Route MQTT messages and store the retained status | Private Persistent Service |
| MQTT client | Publish and observe the sample status | Blossom Job |

## Deploy Mosquitto

Use the official Mosquitto image with a private listener on port
`1883`. Create separate publisher and observer credentials and
mount a [Persistent Service Volume](/docs/apps/persistent-services/).

<details class="optional-reading" markdown="1">
<summary>Notes for your agent</summary>

Use the Mosquitto 2.1 authentication, topic ACL and SQLite persistence
plugins. Set the storage location to `/mosquitto/data/`. Give the
publisher write access and the observer read access to
`workshop/status`. Store passwords in Blossom Variables and Links.

    blossom environment:deploy --id environment-100 --follow

</details>

## Publish the Retained Status

Publish `ready` as a retained message on `workshop/status`. Check
that the observer can receive the status and its attempted publish
is denied.

> **Ask your AI agent:** Help me publish a retained device status and check that the observer can read it but can't change it.

> Follow this guide: https://blossom88.com/deploy/mosquitto/



![Publish the retained status and verify observer access.](/deploy/assets/images/mosquitto/publish-retained-status.webp)

## Subscribe After an Update

Replace the broker Container on the same Volume. Start a new
subscriber and check that it receives the same retained status.

> **Ask your AI agent:** Replace Mosquitto and confirm a new subscriber receives the same retained message.

> Follow this guide: https://blossom88.com/deploy/mosquitto/



![Subscribe and receive the saved status after replacing the broker.](/deploy/assets/images/mosquitto/retain-status-after-replacement.webp)

## What You Get

A private MQTT broker with a saved device status and two accounts
with distinct permissions.

## What You Get

- A private MQTT broker
- A retained status with separate publisher and observer permissions
- The same retained message after replacing the Container

Tested on Blossom: A fresh subscriber received the same retained status after replacing the broker Container.
