Skip to content

About

HiveMQ extension persisting inbound MQTT publishes to Apache IoTDB via REST v2

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

HiveMQ IoTDB Storage Extension

English | 中文

A HiveMQ 4 extension that stores inbound MQTT publishes in IoTDB through the REST v2 API (/rest/v2/nonQuery, /rest/v2/insertRecords).

CI

What it does

  • Intercepts every onPublish, stores the topic and the Base64-encoded original payload as two TEXT measurements and queues the record in a bounded queue.
  • Batches up to batchSize records or batchFlushIntervalMillis worth of records and posts them to /rest/v2/insertRecords.
  • Creates the configured database and both measurements through /rest/v2/nonQuery at startup; a failed schema initialization stops the extension from starting.
  • Drains the queue during extension shutdown; a publish that cannot be enqueued within queueOfferTimeoutMillis is dropped and never stored.

Compatibility

IoTDB version Data model Protocol JDK
2.x Tree HTTP REST v2 (/rest/v2/nonQuery, /rest/v2/insertRecords) Java 11 or newer
  • HiveMQ extension SDK 4.4.0 (provided), Apache HttpClient 4.5, fastjson and dom4j for iotdb.xml.
  • The device path must be below the database path; the extension refuses to start otherwise.

Build

Prerequisites: a JDK 11 or newer and Maven 3.8 or newer. CI builds with Temurin 11.

git clone https://github.com/iotdb-ecosystem/hivemq-iotdb-extension.git
cd hivemq-iotdb-extension
mvn -B -ntp verify

The build produces the extension bundle target/hivemq-iotdb-extension-0.1.0-bundle.zip containing hivemq-extension.xml, iotdb.xml and the shaded jar under lib/.

Test

mvn -B -ntp verify

Three unit tests run the writer against a local HTTP test server: schema initialization, authenticated batched writes with binary payload preservation, monotonic timestamps and rejection of invalid paths. No broker and no IoTDB instance are needed, and this is exactly the command CI runs.

Configuration

Key in iotdb.xml Default Meaning
url http://127.0.0.1:18080 IoTDB REST base URL
username, password root, root Basic-auth credentials
database root.hivemq Tree-model database path
device root.hivemq.mqtt_client Device path, must stay below database
timestampPrecision ms Must match the server setting: ms, us or ns
topicMeasurement mqtt_topic Measurement holding the topic
payloadMeasurement payload_base64 Measurement holding the Base64 payload
batchSize 100 Records per insertRecords request
batchFlushIntervalMillis 10 Maximum batching delay
queueCapacity 10000 Bounded queue capacity
queueOfferTimeoutMillis 100 Enqueue timeout before a publish is dropped
requestTimeoutMillis 5000 HTTP request timeout
<iotdb>
    <url>http://127.0.0.1:18080</url>
    <username>root</username>
    <password>change-me</password>
    <database>root.hivemq</database>
    <device>root.hivemq.mqtt_client</device>
    <timestampPrecision>ms</timestampPrecision>
    <batchSize>100</batchSize>
    <batchFlushIntervalMillis>10</batchFlushIntervalMillis>
</iotdb>

Usage

unzip target/hivemq-iotdb-extension-0.1.0-bundle.zip -d /opt/hivemq/extensions
# edit /opt/hivemq/extensions/hivemq-iotdb-extension-0.1.0/iotdb.xml
# then restart or reload the broker

Publishes are acknowledged asynchronously once the queue has accepted them.

Project status

Upstream candidate. Intended for the HiveMQ community extensions; maintainers of that catalog are welcome to adopt this code — open an issue and we will transfer or co-maintain it.

License

Apache-2.0. See LICENSE.

About

HiveMQ extension persisting inbound MQTT publishes to Apache IoTDB via REST v2

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages