iMES Results Message on Kafka

Each graph run publishes one TASK_RESULT message to task.sql.results, which the mRounds Shift Handover service consumes.

Topic, key and headers

ItemValue
Topictask.sql.results
Key<tenantId>:<aggregateId>
HeaderstenantId, aggregateType, aggregateId, eventId, causationId, correlationId, plus trace headers
DeliveryAt least once. The same message can arrive more than once; deduplicate on messageId.

Message body

Abbreviated example. It shows one of the two rows that rowCount reports and one of the columns.

{
  "messageId": "<taskGraphRunId>:publish_machine_time:task-result",
  "messageType": "TASK_RESULT",
  "context": { "tenantId": "<tenant>", "aggregateType": "...", "aggregateId": "...",
               "correlationId": "...", "causationId": "..." },
  "source": { "taskSlug": "query_machine_time", "adapterType": "MYSQL" },
  "query": { "queryId": "machine-time", "tableName": "v_Mfg_Machine_Time_All",
             "executedAt": "2026-07-23T11:30:00.000Z" },
  "result": {
    "rowCount": 2,
    "columns": [ { "name": "Order Number", "type": "STRING", "nullable": true } ],
    "rows": [
      { "Order Number": "MM08635", "MMM Number": "41640007765", "Order Status": "ACTIVE",
        "Start Time": "2026-07-23T11:00:00.000Z", "End Time": null,
        "Description": "RUNTIME", "Actual Hours": 4.6 }
    ],
    "truncated": false,
    "executedAt": "2026-07-23T11:30:00.000Z"
  }
}
FieldMeaning
messageTypeAlways TASK_RESULT
query.queryId, query.tableNameIdentify the data set. See iMES Data Sets for Shift Handover.
result.columnsName, type and nullability of each column
result.rowsOne object per row, keyed by the column aliases
result.truncatedtrue when maxRows cut the result

How Shift Handover uses the message

Shift Handover adds or updates the IMES source from each result's table name and columns, then marks the reports for that shift; see Connect Shift Handover Reports to Platform Alerts and IMES. Plant admins then pick the table and up to five columns in an IMES widget; see Add Alerts and IMES Widgets to Shift Handover Reports.

Alternative publisher: SqlQueryExecutorService

A second, simpler publisher exists for generic customer databases. It is not the path used for the iMES shift-handover data sets above, and its messages are not interchangeable with TASK_RESULT messages.

  • Endpoint: POST /api/v1/sql-query-jobs/:id/execute. It reads a SqlQueryJob document from MongoDB, runs the SQL (MySQL, PostgreSQL or SQL Server), and publishes to the job's meta.kafkaTopic, keyed by meta.taxonomyNode.
  • Configuration: DB_MONGODB_URI, INTERNAL_API_TOKEN (required outside development), KAFKA_BROKERS with SASL/TLS variables, SQL_QUERY_TIMEOUT_MS, SQL_MAX_ROWS, SQL_MAX_MESSAGE_BYTES.
  • BIGINT and DECIMAL values are published as strings; datetimes as ISO-8601 UTC.

Message example:

{ "tenantId": "<tenant>", "taxonomyNode": "<objectId>",
  "data": [ { "equipment_id": "CMP001", "temperature": 82.4 } ],
  "metadata": { "executedAt": "2026-09-03T11:30:00.000Z", "queryJobId": "<id>" } }