Unlock Low-Latency IoT Messaging with mica-mqtt: Features, Use Cases, and Updates

The article introduces mica-mqtt, a Java AIO‑based low‑latency MQTT component, outlines its extensive features and typical IoT scenarios, and details the latest v2.3.0 release notes, code examples, and its role in the BladeX Links platform.

Java Architecture Diary
Java Architecture Diary
Java Architecture Diary
Unlock Low-Latency IoT Messaging with mica-mqtt: Features, Use Cases, and Updates

1. Introduction

mica-mqtt is a simple, low‑latency, high‑performance MQTT IoT open‑source component built on java aio . It is easy to integrate into existing services and to extend, reducing the cost of building a custom IoT platform.

2. Features

Supports MQTT v3.1, v3.1.1 and v5.0 protocols.

Supports WebSocket MQTT sub‑protocol (compatible with mqtt.js).

Provides HTTP REST API (documentation referenced).

Offers MQTT client library.

Offers MQTT server implementation.

Supports MQTT Last Will messages.

Supports retained MQTT messages.

Custom message (mq) processing and forwarding for clustering.

Demo for connecting to Alibaba Cloud MQTT.

Supports GraalVM compilation to native executable.

Spring Boot starter for quick integration (mica-mqtt-spring-boot-starter).

Prometheus + Grafana integration via the starter.

Cluster support based on Redis pub/sub (see mica-mqtt-broker module).

3. Use Cases

IoT cloud‑side MQTT broker.

Edge‑side IoT message communication.

Group‑based instant messaging.

Message push services.

Simple, easy‑to‑use MQTT client.

4. Release Notes

v2.3.0 – 2024‑05‑26

Optimized MqttQoS enum to MqttQoS.QOS0 (breaking change).

Added stop method to fully halt mica-mqtt-client.

Added schedule and scheduleOnce methods to MqttClient (requires custom thread pool for long‑running tasks).

Optimized device offline handling in mica-mqtt-server.

Added user binding via Tio.bindUser(context, username) in server.

Fixed @MqttClientSubscribe type error in spring‑boot starter.

Fixed reconnection failure issue reported by @YYGuo.

5. Update Details

5.1 mqtt‑client stop

The client now supports a stop operation using a time‑wheel based heartbeat thread, making it usable in more scenarios.

5.2 mqtt‑client schedule

MqttClient client = MqttClient.create()
    .ip("127.0.0.1")
    .port(1883)
    .username("mica")
    .password("mica")
    .connectSync();
// Use schedule to publish periodically
client.schedule(() -> {
    client.publish("/test/client", "mica最牛皮".getBytes(StandardCharsets.UTF_8));
}, 2000);

5.3 mqtt‑server username binding

Version 2.3.0 uses Tio.bindUser(context, username) to bind the connection username. Retrieve it with context.getUserId(). Get the set of connections for a username via:

Set<ChannelContext> usernameSet = Tio.getByUserid(context.tioConfig, "username");

6. BladeX Links Preview

Thanks to WingShen for adopting mica-mqtt as the foundation of the BladeX‑Links IoT platform. BladeX‑Links is now feature‑complete and in the polishing stage; interested parties can follow its progress.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Java Architecture Diary
Written by

Java Architecture Diary

Committed to sharing original, high‑quality technical articles; no fluff or promotional content.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.