Data Hub On Edge
Data Hub is available on HiveMQ Edge and offers the same functionality as for the HiveMQ Enterprise broker. For detailed information, see our Data Hub Quick Start Guide.
| Data Hub is a commercial feature and requires a license. Please reach out to our sales team to obtain one. |
Data Hub Configuration on HiveMQ Edge
When a valid license is present, Data Hub is fully enabled by default and requires no further configuration.
Individual components of Data Hub can be selectively disabled by explicitly setting the enabled attribute to
false in the following way:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<hivemq>
<modules>
<data-hub>
<data-validation>
<enabled>true</enabled>
</data-validation>
<behavior-validation>
<enabled>false</enabled>
</behavior-validation>
<scripting>
<enabled>true</enabled>
</scripting>
</data-hub>
</modules>
</hivemq>
The example configuration disables behavior validation while it keeps data validation and scripting enabled.
Data Hub stores its scripts, schemas, and policies with the persistence mode of HiveMQ Edge. For more information on persistence, see Offline Buffering.
Data Hub persistence
By default, Data Hub uses in-memory persistence, which means that all stored data is lost when HiveMQ Edge restarts. To preserve data across restarts, you must configure file-native persistence.
| When a Data Hub preset is configured, the preset file is the source of truth. The persistence mode does not apply to the Data Hub model. Scripts, schemas, and policies created through the REST API or the UI are lost when HiveMQ Edge restarts. |
<?xml version="1.0"?>
<hivemq xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<persistence>
<mode>file-native</mode>
</persistence>
</hivemq>
Script Engine Pool
Data Hub executes transformation scripts on a pool of JavaScript engines.
The pool size is set with the internal options data-hub.script-runtime.min-engine-count and data-hub.script-runtime.max-engine-count in the config.xml file.
By default, the minimum is half the number of CPUs available to HiveMQ Edge. The maximum is the number of CPUs. Both values are at least 1.
<hivemq>
...
<internal>
<option>
<key>data-hub.script-runtime.min-engine-count</key>
<value>2</value>
</option>
<option>
<key>data-hub.script-runtime.max-engine-count</key>
<value>4</value>
</option>
</internal>
</hivemq>
HiveMQ Edge accepts every <option> under <internal> without validating the key. A misspelled key has no effect and is not reported. Check the key names in your configuration against the ones above.
When every script engine is busy
A message whose policy runs a script needs a free script engine. If every engine is busy, the message waits. Engines go to waiting messages in the order the messages arrived.
At most 500 messages wait at the same time. A message that arrives while 500 messages already wait is dropped at once. A message that waits for 30 seconds without getting an engine is also dropped. The limit keeps HiveMQ Edge responsive when scripts need more CPU than HiveMQ Edge gets, for example under a CPU limit (docker run --cpus, CPU limits in Kubernetes). Without the limit, the waiting messages can take all of the available CPU, and HiveMQ Edge does not recover.
HiveMQ Edge reports dropped messages at most once a second, with their number and one line per reason, in both hivemq.log and script.log:
Dropped 1520 message(s) because every scripting engine was busy and 500 messages were already waiting for one, the limit set by HIVEMQ_DATAHUB_SCRIPT_ENGINE_QUEUE_LIMIT. The scripts need more CPU than Edge gets. Under a CPU limit (docker run --cpus, CPU limits in Kubernetes), give Edge more CPU or dedicated cores; raise the limit only for dedicated cores.
The metric com.hivemq.edge.data-hub.scripting.script-runtime.engines.unavailable.count counts every message that is dropped because no script engine became available. The policy metrics do not count these messages as failed.
If you see dropped messages, give HiveMQ Edge more CPU or dedicated cores first.
Change the queue limit
To change the limit of 500 waiting messages, set the environment variable HIVEMQ_DATAHUB_SCRIPT_ENGINE_QUEUE_LIMIT to an integer from 1 to 60,000.
Raise the limit only when HiveMQ Edge runs on dedicated cores. Under a CPU limit, a higher limit can bring back the overload that the limit prevents.
| Value | Effect |
|---|---|
Not set or empty |
The limit is 500. |
An integer from 1 to 60,000 |
The limit is that number. |
Any other value |
HiveMQ Edge does not start. The log names the variable and the value. |
docker run -e HIVEMQ_DATAHUB_SCRIPT_ENGINE_QUEUE_LIMIT=2000 hivemq/hivemq-edge
Data Hub in the HiveMQ Edge REST API
The Data Hub portions of the HiveMQ REST API and the HiveMQ Edge REST API are identical. All available API interactions work the same way.
However, access to the HiveMQ Edge REST API requires JWT authorization. For more information on JWTs in HiveMQ Edge, see HiveMQ Edge API . An example to obtain a token is shown using cURL.