MQTT Broker Migration Skills

EMQX Migration Skills: Move from EMQX to ConnectMQ with an AI Agent, Rules and ACLs Included

emqx-migration-skills gives Claude Code or any SKILL.md-aware agent two skills and a set of tested scripts for moving from EMQX 4, EMQX 5 or EMQX Cloud to ConnectMQ: authorization conversion, rule-engine replacement, an EMQX bridge and client waves with rollback.

EMQX migration skills: an AI agent converts EMQX ACLs and rules and bridges EMQX to the ConnectMQ MQTT broker
Run this on your own MQTT brokerGet a private, managed MQTT broker on the Free plan and start from ready-made code samples.
Try it free Code samples No card required

An EMQX migration is rarely about the broker alone. Teams pick EMQX for its scale and its built-in features, and over time the broker takes on real application logic: SQL rules that write to databases, MQTT bridges, delayed messages, topic rewrites, $queue consumers and an authorization file that nobody has read since it was copied from the docs. Moving the MQTT traffic to another broker takes a day. Finding and moving that hidden logic is where projects slip.

emqx-migration-skills is an open-source repository that gives an AI agent everything it needs to do that work with you. It contains two agent skills, one for planning and one for execution, plus scripts tested against real brokers. Load them in Claude Code, or any agent that understands SKILL.md skills, and ask for an EMQX migration plan in plain language.

Who This Is For

The skills cover three starting points:

  • Self-hosted EMQX 5 (HOCON emqx.conf, Dashboard Integration menu, REST API v5).
  • Self-hosted EMQX 4 (key-value emqx.conf, plugins, emqx_ctl).
  • EMQX Cloud, both Serverless and Dedicated deployments.

The target is ConnectMQ, a managed MQTT broker with a private instance per customer, a live dashboard, access control and alerting. If you are still comparing options, EMQX Cloud alternative and the open-source MQTT broker comparison give the wider picture.

Two Skills, One Migration

Skill Job
emqx-migration-planner Exports and audits the EMQX setup, measures load, maps identities and ACLs, designs replacements for broker-side logic and writes migration/plan.md
emqx-migration-executor Prepares ConnectMQ, builds the EMQX bridge or a relay, copies retained state, runs waves with go/no-go checks, rolls back when needed and decommissions EMQX

Both skills share a reference sheet on ConnectMQ itself: endpoints, how generated credentials and issued client IDs work, the ordered ACL model, plan limits and reason codes. The agent reasons from those facts rather than from general MQTT knowledge, so its advice matches the target.

Step 1: Export What EMQX Knows

The planner starts by pulling data out of EMQX instead of asking you to describe it. On EMQX 5 it uses the REST API with an API key from the Dashboard:

A="-u $EMQX_API_KEY:$EMQX_API_SECRET"; E=http://EMQX_HOST:18083/api/v5
curl -s $A "$E/authorization/sources/built_in_database/rules/users?limit=1000" > migration/authz-users.json
curl -s $A "$E/clients?limit=1000&page=1" > migration/clients-1.json
curl -s $A "$E/rules" > migration/rules.json

Then it runs the audit script over the configuration, the authorization file, the built-in database exports and the client list:

python scripts/emqx_audit.py --conf /etc/emqx/emqx.conf --acl /etc/emqx/acl.conf \
  --builtin migration/authz-users.json --clients migration/clients-1.json --out migration/

The audit understands both HOCON blocks and EMQX 4 key-value lines. Each setting it recognises is sorted into blockers, actions, plan checks or information. In a typical EMQX 5 deployment it finds:

  • Blockers: rule_engine rules and data integrations, delayed, exhook, webhooks, QUIC listeners, and TLS listeners with verify_peer and fail_if_no_peer_cert (client certificates).
  • Actions: authenticators to replace with ConnectMQ credentials, rewrite rules, auto_subscribe, allow_anonymous, and the authorization no_match policy.
  • Plan checks: max_packet_size, max_mqueue_len, session_expiry_interval, max_connections and shared subscriptions, compared with the ConnectMQ plans.

From the client list it also flags MQTT 3.1 clients and sessions with queued messages, and it writes clients.csv as input for client ID mapping.

Step 2: Convert EMQX Authorization to ConnectMQ Rules

EMQX acl.conf is a file of Erlang terms such as {allow, {username, "backend"}, all, ["devices/#"]}. The script parses the terms directly, for both EMQX 4 and 5 syntax, and keeps their order. Like ConnectMQ, the file is evaluated first match wins, so order carries over. The trickier cases get explicit handling:

  • The final {allow, all}. or {deny, all}. becomes the ConnectMQ no-match policy. EMQX defaults to allow; the planner recommends deny with explicit allow rules.
  • %c and %u (EMQX 4) and ${clientid} and ${username} (EMQX 5) become ConnectMQ placeholders. With a client map they expand into per-client rules that keep the old IDs in your topic tree.
  • Simple regex subjects such as {username, {re, "^gw-.*$"}} become gw-* globs.
  • ipaddr subjects, and combinations and placeholders like ${peerhost} cannot be expressed. They are skipped and listed in the notes.
  • EMQX's default {deny, all, subscribe, [{eq, "#"}]} blocks only the literal # filter. A ConnectMQ deny on # would block every subscription, so the script skips it and explains the safer pattern.
  • Built-in database rules exported from the API are converted per username, per client ID and for all clients.

You get migration/acl-rules.md, a numbered rule table to enter in the ConnectMQ console. Background on rule design: MQTT ACL.

Step 3: Replace the Rule Engine and Other Broker Logic

This is the part an EMQX migration cannot skip. ConnectMQ deliberately keeps the broker a broker, so every EMQX rule becomes a small subscriber service. The planner reads rules.json, lists each rule's SQL and actions, and proposes a replacement:

  1. Subscribe with a shared subscription, for example $share/ingest/devices/+/telemetry, so several instances share the load. See MQTT shared subscriptions.
  2. Move the SQL filter and transformation into code.
  3. Write to the same Kafka topic, database or HTTP endpoint the rule used.

Threshold rules that only raise alerts often need no code at all: ConnectMQ's built-in Rules and Alerts match conditions on JSON payload fields. The planner also searches client code for $queue/ subscriptions, which become $share/<group>/, and $delayed/ publishes, which must be scheduled by the application. Each item gets an owner and a deadline: it must be live before the wave that moves its publishers.

Step 4: Identities and Plan Fit

ConnectMQ generates credentials, and each credential carries an issued client ID. Clients connect as that ID or as <ISSUED_ID>_<suffix>. The planner runs client_id_map.py over clients.csv, so sensor-0042 becomes c7f3k2_sensor-0042. Unsafe characters and IDs that collide are fixed before rollout, which avoids client ID takeovers.

Sizing uses numbers from /api/v5/stats and /api/v5/metrics sampled over a busy day. Connections and session minutes are checked separately, because EMQX fleets are often always connected. 590 always-on devices fit Scale's 1,000 connections but use about 25 million session minutes a month. The planner flags that early, so you can request a custom plan instead of finding out during a wave.

Step 5: Bridge, Validate, Move in Waves

The executor builds the parallel run. On EMQX 5.4 and later it creates an MQTT Broker connector to ConnectMQ, an egress rule with an MQTT action for device topics (remote topic ${topic}, QoS ${qos}, retain ${flag.retain}), and an ingress source for commands. EMQX 5.0 to 5.3 data bridges and the EMQX 4 bridge plugin are covered too. Two settings matter most: the ClientID prefix must start with the issued client ID, and the pool size should be 1. EMQX Serverless has no outbound bridge, so the executor runs relay.py instead. The relay has loop protection and supports TLS and MQTT 5 properties.

Before any device moves, the executor:

  • smoke-tests ConnectMQ with verify_connectmq.py (QoS 0/1/2, retained, Last Will, sessions, ACL denies),
  • copies retained state with copy_retained.py (see MQTT retained messages),
  • runs replacement services in shadow mode next to the EMQX rules,
  • confirms with compare_streams.py that both brokers see the same topics and message counts.

Then come the waves: consumers first, then canary devices, then growing groups. Each wave has a go/no-go checklist and watches for 0x85, 0x86, 0x87, 0x8A and 0x97. Rollback means pointing the wave back to EMQX and re-enabling the rule actions, while the bridge keeps both sides in sync. Every step goes into migration/log.md.

Installing the Skills

/plugin marketplace add connectmq/emqx-migration-skills
/plugin install emqx-migration-skills@connectmq-emqx-migration

You can also copy the skills/ folders into ~/.claude/skills/, or zip one folder and upload it to Claude.ai. The audit script uses only the Python standard library; the MQTT scripts need paho-mqtt 2.x.

Good first prompts: "Audit our EMQX 5 cluster and plan a move to ConnectMQ", "List every EMQX rule we use and propose a replacement", or "We are on EMQX Serverless, start a relay and compare both sides".

The same approach exists for Mosquitto, HiveMQ, VerneMQ, AWS IoT Core and Azure IoT Hub.

Frequently Asked Questions

Does the EMQX migration work for EMQX 4 as well as EMQX 5?

Yes. The audit reads both configuration formats and both acl.conf dialects ({user, ...}, pubsub and %c/%u in EMQX 4, {username, ...} and ${clientid} in EMQX 5). The bridge guide covers the EMQX 4 bridge plugin, EMQX 5 data bridges and the newer connector, rule and action model.

What happens to my EMQX rule engine rules?

ConnectMQ has no broker-side rule engine. The planner lists every rule and turns it into a subscriber service that uses a shared subscription, or into a ConnectMQ alert rule when it only raises alerts. Replacements run in shadow mode during the parallel run and go live before their publishers move.

Can I keep EMQX usernames, passwords and client IDs?

No. ConnectMQ issues new credentials in the console, and client IDs must start with the credential's issued ID. The skills plan host, credentials and client ID as one config change per client and generate the mapping files for you.

We use EMQX Serverless. Can we still bridge?

EMQX Serverless cannot open an outbound bridge, so the executor runs the included relay.py between your Serverless deployment and ConnectMQ. It forwards device topics, sends commands back, and protects against message loops.

Are the skills free to use?

Yes. Everything is MIT licensed on GitHub. Pull requests with new EMQX options, authorization sources or migration patterns are welcome.

Related articles

Azure IoT Hub Migration Skills: Move from IoT Hub to a Standard MQTT Broker with an AI Agent

azure-iot-hub-migration-skills gives Claude Code or any SKILL.md-aware agent a tested playbook for leaving Azure IoT Hub: it converts the device registry and twins, redesigns IoT Hub's fixed topics into a standard MQTT tree, relays telemetry through the Event Hubs-compatible endpoint so backends can move first, and rolls devices over in waves.

8 min read

HiveMQ Migration Skills: Migrate from HiveMQ to ConnectMQ with an AI Agent

hivemq-migration-skills gives Claude Code and other SKILL.md-aware agents everything needed to migrate from HiveMQ CE, Enterprise or HiveMQ Cloud to ConnectMQ: an audit of config.xml and extensions, File RBAC conversion, a relay or bridge for the parallel run, and client waves with rollback.

8 min read

All articles →

Your private MQTT broker is a few clicks away

Create an account, get your broker credentials and connect your first device — no servers to install, patch or scale.