Boost IoT Performance with mica-mqtt: A High‑Performance Java AIO MQTT Solution

The article introduces mica-mqtt, a Java AIO‑based open‑source MQTT component offering simple, low‑latency, high‑performance IoT messaging, outlines its extensive features, typical use cases, recent updates, migration steps, and provides code examples and documentation links for developers.

Java Architecture Diary
Java Architecture Diary
Java Architecture Diary
Boost IoT Performance with mica-mqtt: A High‑Performance Java AIO MQTT Solution

1. Introduction

mica-mqtt is an open‑source MQTT component built on Java AIO , designed to be simple, low‑latency, and high‑performance for IoT applications. It integrates easily into existing services and reduces development costs for custom IoT platforms.

2. Features

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

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

Provides HTTP REST API (documentation referenced).

Includes MQTT client and server implementations.

Supports MQTT will messages and retained messages.

Enables custom message processing and cluster forwarding.

Offers an Alibaba Cloud MQTT connection demo.

Can be compiled to a native executable with GraalVM.

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

Integrates with Prometheus and Grafana for monitoring.

Implements clustering via Redis pub/sub (see mica-mqtt-broker module).

3. Use Cases

IoT cloud MQTT broker.

Edge‑side message communication for IoT.

Group chat (IM) applications.

Message push services.

Simple, easy‑to‑use MQTT client implementations.

4. Update Log (v2.1.0 – 2023‑03‑05)

Incompatible interface parameter adjustments for easier use.

Core refactoring and compatibility with newer Spring Boot versions (2.1.0.RELEASE+).

SSL support for mutual authentication.

Bug fixes for will‑message handling and typo corrections.

Dependency upgrades.

5. Migration Guide

Split mica-mqtt-core into mica-mqtt-client and mica-mqtt-server to avoid dependency conflicts.

Moved HexUtil from net.dreamlu.iot.mqtt.core.util.HexUtil to org.tio.utils.mica.HexUtils.

5.1 Client

5.1.1 Subscription Callback Interface Changes

When using mica-mqtt-client-spring-boot-starter, annotation‑based subscriptions are supported.

The

IMqttClientMessageListener#onMessage(ChannelContext context, String topic, MqttPublishMessage message, ByteBuffer payload)

method now includes context and message parameters.

// Message subscription example (subQos0)
client.subQos0("/test/#", (context, topic, message, payload) -> {
    logger.info(topic + '\t' + ByteBufferUtil.toString(payload));
});

5.1.2 SSL Mutual Authentication Support

mica:
  ssl:
    enabled: false   # Set true to enable SSL; from 2.1.0 supports mutual auth
    keystore-path:   # Path to keystore for mutual auth (classpath:/ supported)
    keystore-pass:   # Keystore password (required for mutual auth)
    truststore-path: # Path to truststore for mutual auth (optional)
    truststore-pass: # Truststore password (optional)
    client-auth: none # Options: none, optional, require

SSL modes:

ClientAuth NONE – server only requires SSL, no client certificate.

ClientAuth OPTIONAL – server negotiates client authentication; client must provide truststore.

ClientAuth REQUIRE – client must provide both truststore and keystore certificates.

5.1.2.1 IMqttMessageListener Adjustments

The IMqttMessageListener onMessage signature now includes topic and qoS, and the message parameter is the raw MqttPublishMessage to access MQTT 5.x properties.

/**
 * Listener for received messages
 * @param context   ChannelContext
 * @param clientId  client identifier
 * @param topic     topic name
 * @param qoS       MQTT QoS level
 * @param message   MqttPublishMessage instance
 */
void onMessage(ChannelContext context, String clientId, String topic, MqttQoS qoS, MqttPublishMessage message);

6. Documentation and Examples

mica-mqtt-client documentation.

mica-mqtt-server documentation.

mica-mqtt-client-spring-boot-starter documentation.

mica-mqtt-server-spring-boot-starter documentation.

mica-mqtt HTTP API documentation.

mica-mqtt release notes.

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.

IoThigh performanceopen-sourceMQTT
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.