/Catfish

This is a HiveMQ extension that supports data save to TDEngine.

Primary LanguageJavaMIT LicenseMIT

catfish logo

TDengine Extension of HiveMQ (Codename: Catfish)

This is a HiveMQ extension that supports data save to TDEngine.

Documentation is HERE.

Deployment

  1. Please download hivemq-tdengine-extension-1.1-distribution.zip from releases.
  2. Unzip the file: hivemq-tdengine-extension-1.1-distribution.zip on local folder.
  3. Put the whole folder into {HIVEMQHOME}/extensions/ as below: extensions folder layout
  4. Create a configuration file named "TDengine.properties" under hivemq-tdengine-extension. The template as below:

TDengine.properties

host: {TDengine Server IP/hostname}
port:6041
user: {TDengine account}
password:{password}

prefix:mqtt_msg
database:testdb

reportingInterval:1
connectTimeout:5000
Properties Meaning
host The TDengine server name / IP address.
port TDengine service listening port, default is 6041.
user The TDengine db user name, usually the user should has write permissions.
password The password of db login user.
prefix The name of super table in TDengine.
database The name of TDengine database.
reportingInterval The performance metric report intervals. It's not in use.
connectTimeout HTTP connect timeout in milliseconds.

At least, you should specify TDengine server host/IP address. Other settings will be set to default value.

  1. start HiveMQ service by {HIVEMQHOME}/bin/run.sh

Notes:


It doesen't need to create any database or tables in TDengine service. Just specify database name and table name by database and prefix properties in TDengine.properties. These database objects will created automatically.


Enable Firewall Rules

The TDengine extension needs to access TDengine REST APIs which is locate on TDengine services with port 6041. Please configure firewall to enable outbound rule to communicate to 6041.

By default, the HiveMQ service exposes 1883 to recevied MQTT traffic, please enable it either.

Tuning I/O Performance

There is one way to extend I/O performance:

  • Extends REST APIs serve threads number.

Extends REST APIs serve threads number

The TDengine extension uses REST APIs to communicate to TDengine service. By default, there are only 2 threads serve HTTP traffic. If you have a heavy MQTT traffic, please increase the number of httMaxThreads.

taos.cfg

For details, please review: TDengine Documentation

Build from source

Build this project is very simple. It only needs OpenJDK 11 and Maven.

For install OpenJDK 11, please check https://openjdk.java.net/install/.

For install Maven, please check https://maven.apache.org/install.html.

Then you can build code directly.

# Get code from Github.
> git clone https://www.github.com/micli/Catfish.git
# change current folder.
> cd Catfish/hivemq-tdengine-extension/
# Build extension
> mvn package