iMES Task Graphs and Schedules

Each data set runs as a two-task graph, execute_sql followed by publish_kafka, on a schedule.

Graph structure

The publish_kafka task depends on the execute_sql task, so a result is published only after the query finishes. The supplied graphs cover Machine Time, In Loads, Waste and Order Details for the supplied work centers (machine_time_*, material_load_*, waste and mfg_order_details_*).

Example graph, abbreviated (statement stands for the Machine Time SQL in iMES Data Sets for Shift Handover):

{
  "slug": "machine_time_pm02_24h",
  "resourceSpec": {
    "sqlDb": { "adapterType": "MYSQL", "connectionRef": "manufacturing-mysql",
               "secretRef": "tenants/${context.tenantId}/resources/manufacturing-db",
               "requiredCapabilities": ["executeQuery"] },
    "kafkaBroker": { "adapterType": "KAFKA", "connectionRef": "workflow-messaging-kafka",
                     "secretRef": "tenants/${context.tenantId}/resources/task-results",
                     "requiredCapabilities": ["publish"] }
  },
  "allowedTriggers": ["API", "SCHEDULE", "DOMAIN_EVENT", "MESSAGE"],
  "graphPolicy": { "concurrency": "FORBID_OVERLAP", "timeoutMs": 300000 },
  "tasks": [
    { "slug": "query_machine_time", "taskDefinitionId": "execute_sql",
      "config": {
        "resource": "sqlDb",
        "queryId": "machine-time",
        "tableName": "v_Mfg_Machine_Time_All",
        "statement": "<machine-time SQL>",
        "parameters": { "burdenCenter": "PM02", "lookbackHours": 24 },
        "parameterOrder": ["burdenCenter", "lookbackHours"],
        "timeoutMs": 30000,
        "maxRows": 1000 } },
    { "slug": "publish_machine_time", "taskDefinitionId": "publish_kafka",
      "dependsOn": ["query_machine_time"],
      "config": {
        "resource": "kafkaBroker",
        "topic": "task.sql.results",
        "sourceTask": "query_machine_time",
        "sourceAdapterType": "MYSQL",
        "sourceQueryId": "machine-time",
        "keyTemplate": "${context.tenantId}:${context.aggregateId}" } }
  ]
}
SettingMeaning
resourceSpec.sqlDb, resourceSpec.kafkaBrokerThe database and Kafka resources. Each names its connection (connectionRef), a per-tenant secret (secretRef) and the capability it needs (executeQuery or publish). Tasks refer to them by name in config.resource.
parameterOrderLists the parameter names in the order the ? placeholders appear in the SQL.
timeoutMs (task)Cancels the server-side query after this time.
maxRowsTruncates the result to this many rows; the message then has truncated: true.
graphPolicy.concurrencyWhether runs of the graph may overlap. FORBID_OVERLAP stops a new run while one is in progress.
graphPolicy.timeoutMsTime limit for the whole graph run.
keyTemplateKafka message key: ${context.tenantId}:${context.aggregateId}.

Adding a work center

For Machine Time, In Loads and Waste, the work center is a parameter: copy the graph, change parameters and the slug. Order Details is different. Its work center comes from a fixed allow-list in the SQL builder (B4, C7, PM02, PM04), so copying a graph does not add support for another work center.

Schedules

  • Each graph runs on a cron schedule managed through the schedules API (PUT /schedules/:id, with pause, resume and run actions). Temporal drives the schedule.
  • A cron that is not "every N minutes" is read in the schedule's timezone.
  • The schedule's concurrencyPolicy (ALLOW or FORBID_OVERLAP) controls whether scheduled runs may overlap. It is separate from the graph's graphPolicy.concurrency.
  • Set the cadence to how often shift handover needs fresh data; hourly is typical. This is how often new IMES results are produced. It is separate from Shift Handover's refresh of open reports, about every 30 seconds, which copies results already received.