Skip to content

About

Node-RED nodes with SQL operations and native Topic subscription for Apache IoTDB and TimechoDB

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

@timecho/node-red-node-iotdb

English | 中文

Node-RED nodes for Apache IoTDB and TimechoDB: one SQL interface for the Tree and Table models, plus native Topic subscription with manual ACK.

CI

What it does

  • iotdb-server is a shared configuration node holding the address, model, database, Node-RED credentials, timeouts and queue limits; Tree and Table each use their own configuration node, and a shared connection cannot change the model or database of other operators.
  • iotdb-operator runs fixed SQL or the SQL carried in msg.topic for queries, writes and management; msg.iotdb reports operation, model, columns, rowCount and timestamp precision, INT64 values stay decimal strings, and a response is bounded at 10,000 rows / 8 MiB instead of being truncated silently.
  • iotdb-consumer pulls from an existing native Topic with a stable groupId and consumerId and emits an opaque ackToken; send the token back to the same node to acknowledge, or use pause / resume. A lost connection makes the consumer report RECOVERY_REQUIRED and stop pulling, and a persisted marker keeps the same Topic/group from resuming on its own - the marker stores neither messages nor offsets.
  • Queries run through a pinned @iotdb/client@2.0.11 adaptation layer inside a restricted worker, so Tree timestamps and logical column order survive; a timeout terminates that connection and writes are never retried automatically.

Compatibility

Server Data model SQL Native subscription Node.js / Node-RED
TimechoDB 2.0.12.1 Tree verified snapshot / incremental, manual ACK on a live session >= 22.9.0 / >= 4.1.0
TimechoDB 2.0.12.1 Table verified snapshot / incremental, manual ACK on a live session >= 22.9.0 / >= 4.1.0
Apache IoTDB 2.0.11 Tree verified compiled out of the release build; the node reports an explicit error >= 22.9.0 / >= 4.1.0
Apache IoTDB 2.0.11 Table verified compiled out of the release build; the node reports an explicit error >= 22.9.0 / >= 4.1.0

engines requires Node.js >= 22.9.0 and node-red.version requires Node-RED >= 4.1.0; validation ran on Node.js 22.22.1 / 24.19.0 with Node-RED 5.0.9. Node-RED 4.1 itself, other server versions and cluster deployments are not certified. Details in docs/compatibility.md.

Build

Prerequisites: Node.js >= 22.9.0 and a Node-RED >= 4.1 installation. SQL-only use needs no compilation step.

git clone https://github.com/iotdb-ecosystem/node-red-node-iotdb.git
cd node-red-node-iotdb
npm ci

Install it into a Node-RED user directory and restart Node-RED:

cd ~/.node-red
npm install @timecho/node-red-node-iotdb@0.0.2

The Java bridge behind the subscription node is built separately and CI does not build it:

export IOTDB_SUBSCRIPTION_CLASSPATH='/path/to/approved-sdk/lib/*'
npm run build:bridge

npm run build:bridge needs JDK 17 plus the server-matched official Java SDK and its dependencies, which are not vendored and not distributed with the npm package; a deployment that already ships the build product only needs a Java 17 runtime, while a missing build product makes the bridge start from Java source and therefore requires a JDK. Pin the tested package version and set Node-RED credentialSecret before production use.

Test

npm ci
npm run check   # syntax-check the node entry point and the lib modules
npm test        # 21 unit and Node-RED tests, no server required

CI runs exactly those three commands on Node.js 22.x and nothing else. Server-dependent suites are separate and never part of CI: npm run test:integration, npm run test:acceptance and npm run test:server-contract need IOTDB_TEST_HOST, IOTDB_TEST_PORT and IOTDB_TEST_PASSWORD, plus IOTDB_SUBSCRIPTION_CLASSPATH for native subscription. Integration runs create and clean up their own nr_test_ namespace and Topic resources; without a password the database tests skip, and a skip is not a pass.

Configuration

Field Notes
Address and model one iotdb-server per model; USE and SET SQL_DIALECT are rejected on a shared connection, so switch the configuration instead
Database default database used by the operator
Credentials username and password through Node-RED credentials, not the flow file
Timeout bounds one SQL call; on expiry the connection is terminated and the write result is unknown to the caller
Queue limit maximum pending-ACK batches before a consumer stops polling
Mode auto, query or execute; statements that classifies ambiguously must be pinned manually

SQL is executed verbatim - there is no placeholder substitution, so never concatenate untrusted input. Errors are delivered to the Catch path and msg.iotdb.error carries a stable classification; Complete fires after the operation has actually finished.

Usage

  1. Add an iotdb-server configuration node and fill in address, model and credentials.
  2. Add an iotdb-operator node, select the server and inject SQL:
msg.topic = "SELECT temperature FROM root.factory.device01 LIMIT 100";
return msg;

Queries return an array of row objects in msg.payload, non-query success returns {success:true}, and the rest of the input message is preserved.

  1. For native subscription add an iotdb-consumer node, select an existing Topic and a stable groupId and consumerId:
// consumer output
{
  topic: "temperature_topic",
  payload: [{source: "root.factory.device01", timestamp: "1794133480573", values: {temperature: 25.5}}],
  iotdb: {model: "tree", consumerGroupId: "alarms", consumerId: "worker1", ackToken: "opaque-token"}
}

Default is manual ACK: keep msg.iotdb.ackToken and send it back to the same consumer after the downstream work succeeds (optionally with msg.iotdb.action = "ack"); an ACK input emits no data message. Multi-branch flows must merge first and acknowledge once. delivery mode commits after node.send(), which proves delivery to the flow, not downstream business success, so unacknowledged messages may be redelivered and the business logic must be idempotent.

Project status

Maintained by Timecho engineers in this organization; published to npm as @timecho/node-red-node-iotdb.

License

Apache-2.0, see LICENSE.

About

Node-RED nodes with SQL operations and native Topic subscription for Apache IoTDB and TimechoDB

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages