IT Hub Processor
The IT Hub processor lets an Analytics flow talk to your IT and business systems. It runs a command against a Cloud Connector instance, for example a SQL query on a database connector or a request on a REST connector, and brings the result back into the flow. You set it up once, and it can run on a schedule, whenever an upstream processor sends it a value, or on demand when you run it yourself.
Triggering
You can trigger the processor in three ways:
- On a timer. Turn on Execute On Interval, then choose how often it runs with the interval value and unit. The timer stays active as long as the interval value is above 0. Set it to 0 to turn the timer off and run the processor from an input or by hand instead.
- From an upstream processor. The processor runs each time another processor sends it a value.
- Manually. Run the processor whenever you need to by selecting the invoke button.
Runtime overrides
When an input value triggers the processor and that value is a map, you can change some settings for that one run. Include any of these keys in the message to replace the saved value for that call: connector, body, parameters, headers, response_topic, force_reset_cache, stream_name, and message_id_prefix. Only the keys you include change, and everything else keeps its saved value. The timer settings and the command timeout stay fixed and cannot be overridden.
Here is a message that overrides every available field:
{
"connector": "a3f82b1c-4d90-4e11-b6a3-012f45678abc",
"body": "SELECT * FROM readings WHERE device_id = 'sensor-001'",
"parameters": ["sensor-001", "100"],
"headers": { "X-Foo": "bar" },
"response_topic": "cc.results.readings",
"force_reset_cache": false,
"stream_name": "cc-results",
"message_id_prefix": "readings-run"
}Output
The processor listens on the Response Topic you set and passes along each message it receives there, so the command's results appear in the tabular view. Leave Response Topic empty when you only need to run the command and do not want to collect a response. The command's own success or error is written to the debug log, so it is not part of the output.
Important: The processor always listens on the Response Topic saved in its settings. If you override response_topic for a single call, the connector publishes to the new topic for that run, but the processor keeps listening on the saved one, so those results are not forwarded.
Concurrency
The processor runs one command at a time. If a new trigger arrives while a command is still running, the processor skips it rather than lining it up for later. When you use the timer, give each command room to finish by setting an interval that is longer than a typical run.
Parameters
Note: You only see the advanced parameters when Advanced Parameters is set to Show, and the timer fields when Execute On Interval is set to True.
Parameter | Details |
|---|---|
Connector | The connector instance to run the command against. The dropdown shows only supported connectors. Required. |
Response Topic | The DataHub topic the connector publishes result chunks to. The processor subscribes to this topic and forwards each message to its output. Leave empty to run the command without forwarding results. |
Body | The command payload, such as SQL text for a SQL connector or an HTTP body for a REST connector. |
Advanced Parameters | Shows or hides the advanced configuration options below. |
Parameters | Positional parameters as a JSON array of strings, for example ["a", "b"]. |
Headers | Free-form headers as a JSON object of string to string, for example {"X-Foo":"bar"}. |
Force Reset Cache | Tells the connector to drop any cached state before this call. |
Stream Name | An optional JetStream stream name to verify the response topic maps to. Leave empty to skip the check. |
Message ID Prefix | An optional base prefix for per-chunk message IDs. The processor appends a per-run identifier so each run is distinct. |
Command Timeout | The timeout for a single request, in seconds. Default is 1. |
Execute On Interval | Runs the command automatically on a timer. The timer is active whenever the interval value is greater than 0. |
Timer Interval Type | The timer interval unit: seconds, minutes, hours, or days. |
Timer Interval Value | The timer interval value. Enter 0 for no timer, which leaves manual or input triggering only. |
{
"connector": "a3f82b1c-4d90-4e11-b6a3-012f45678abc",
"body": "SELECT * FROM readings WHERE device_id = 'sensor-001'",
"parameters": ["sensor-001", "100"],
"headers": { "X-Foo": "bar" },
"response_topic": "cc.results.readings",
"force_reset_cache": false,
"stream_name": "cc-results",
"message_id_prefix": "readings-run"
}Example
- Add an Inject processor. It generates the trigger message for the run. Run it by hand with the Invoke button, or set its timing mode to interval to run on a schedule.
- Add a JavaScript Processor and connect Inject to it. In the Code Editor, build a map message whose keys match the IT Hub fields you want to set for the run, such as connector, body, parameters, or response_topic. Any key you include overrides the IT Hub's saved value for that call (see Runtime overrides).
- Add the IT Hub processor and connect the JavaScript Processor to it. Pick the Connector and set a Response Topic (optional) so results are forwarded to the message broker. These act as the defaults for any field the incoming message doesn't override.
- View the results from dynamic REST or SQL.
- Enable watch output on the IT Hub, view the response in Analytics.
- Use DataHub Subscribe processor with the on the Response Topic
Note: For IT Hub with a SQL connector, when watch output is disabled and Response Topic is a not being subscribed too. The SQL query results will display as a tabular view.
SQL connector
result = {
connector: "<sql-connector-id>",
body: "SELECT * FROM readings WHERE device_id = 'press-01'",
response_topic: "cc.results.sql"
}REST connector
result = {
connector: "<sql-connector-id>",
response_topic: "cc.results.sql",
body: JSON.stringify({
method: "POST",
path: "/meters",
body: {
name: "Boiler Temp",
description: "Monitors boiler temperature",
measurementType: "AUTOMATED_SENSOR",
unit: "Celsius"
}
})
}Note: The value of body needs to be a STRING. As shown above:
- For SQL connectors, the entire SQL query is sent a STRING
- For REST connectors, stringified JSON object with method, path and request body