---
title: Deploy EMQX with AI on Blossom
url: "/deploy/emqx/"
canonical_url: https://blossom88.com/deploy/emqx/
markdown_url: https://blossom88.com/deploy/emqx.md
summary: Give an MQTT device a private broker and recover its retained heartbeat after
  a Container update.
categories:
- deployment
- databases
stack:
- Erlang
- MQTT
---

# Deploy EMQX with AI on Blossom

[EMQX](https://github.com/emqx/emqx) is an MQTT broker for devices and
applications. A device can retain its last heartbeat so a subscriber
receives it when it connects.

## Ask Your Agent

> **Ask your AI agent:** Deploy EMQX on Blossom and help me publish a device heartbeat that a new subscriber can read.
>
> Follow this guide: https://blossom88.com/deploy/emqx/

[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).

## Have Ready

- **Community License eligibility** (Required): Use one broker node internally. Check the [license terms](https://github.com/emqx/emqx/blob/6.3.3/LICENSE) for hosted or embedded use and clusters.

## How It Runs

| Part | Role | Where |
|---|---|---|
| EMQX | Route messages and store accounts and retained payloads | Private Persistent Service |
| MQTT client | Publish and subscribe to a test heartbeat | Blossom Job |

## Deploy EMQX

Use the [official EMQX image](https://docs.emqx.com/en/emqx/latest/get-started/deploy/install-docker.html)
and a [Persistent Service Volume](/docs/apps/persistent-services/).
Keep the MQTT listener private and require a named login.

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

Attach the Volume at `/opt/emqx/data`. Keep the Erlang node name
stable, enable disk-backed message retention, and bind management
to loopback. Seed one client login in the built-in authentication
database. Store credentials through Blossom Variables and Links.

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

</details>

## Publish a Heartbeat

Publish a retained `green` message to `workshop/heartbeat` as an
authenticated client. Connect a new subscriber and check what it
receives. Confirm the broker rejects an anonymous connection.

> **Ask your AI agent:** Help me publish a retained heartbeat and read it as an authenticated subscriber.

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



![Publish and read a retained heartbeat as an authenticated client.](/deploy/assets/images/emqx/publish-retained-heartbeat.webp)

## Subscribe After an Update

Replace the Container on the same Volume. Connect with the same
account and check the retained heartbeat without publishing it again.

> **Ask your AI agent:** Replace the Container and check that the existing MQTT login and heartbeat still work.

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



![Job output confirms the same account read the heartbeat after replacement.](/deploy/assets/images/emqx/authenticated-subscriber-after-replacement.webp)

## What You Get

A private MQTT broker with a client login and a heartbeat that
survive a Container update.

## What You Get

- A private single-node MQTT broker with a named client account
- A retained heartbeat available to newly connected subscribers
- The same MQTT login and heartbeat after replacing the Container

Tested on Blossom: The MQTT login and retained heartbeat survived replacing the broker Container without reseeding the user.
