With Node 2.6 Crosser has introduced the possibility to utilize the Node’s internal MQTT Broker to get events when a flow/module status/state changes. This allows you to create an event driven notification architecture with external monitoring tools.
Similar to the HTTP approach, you can either connect to the Node’s local broker from an external MQTT client, or create a flow which subscribes to the relevant topics and send out notification in case something goes wrong.
The Node will publish messages when things occur that someone might want to know. The root topic for all the messages will be $crosser/. So for example $crosser/flows/{flowDefinitionId}/started will be published when a flow starts.
The $crosser topic will be forbidden by clients to publish to, only subscriptions are allowed. If a client tries to publish with a topic that starts with $crosser/ the client will be disconnected.
Note that MQTT Notifications are disabled for remote sessions. Only deployed flows will trigger MQTT Notifications.
Topic: $crosser/flows/{flowDefinitionId}/state [RETAINED]
When a flow changes state (started, stopped) this topic will be triggered with the information:
{
"flowId": "2220e7a7-9e98-4af3-afd4-a1b309128540",
"flowName": "MQTT Notifications",
"version": 9,
"running": true,
"status": "Ok",
"reason": "Flow started",
"origin": "Cloud",
"timestamp": "2023-07-04T10:40:47.601+00:00",
"nodeId": "27929e60-a586-4f51-a512-0583391b0c86",
"nodeName": "Machine123",
"timestamp": "2023-09-28T13:22:51.743+00:00"
}
{
"flowId": "2220e7a7-9e98-4af3-afd4-a1b309128540",
"flowDefinitionId": "6faf4080-c7ce-e642-37a0-43e965904899",
"flowName": "Example MQTT Notifications",
"version": 9,
"status": "Warning",
"reason": "Flow status changed to Warning",
"reasons": [
{
"moduleId": "9c3727c6-7d64-4cb3-95eb-a597596068b2",
"moduleName": "OPC UA Reader",
"moduleType": "Crosser.EdgeNode.Modules.OPC.UA.Reader",
"version": "2.3.0",
"status": "Warning",
"reason": "Module OPC UA Reader, 2.3.0 changed to status Warning: This is a test",
"timestamp": "2023-09-28T13:22:51.743+00:00"
}
],
"nodeId": "27929e60-a586-4f51-a512-0583391b0c86",
"nodeName": "Machine123",
"timestamp": "2023-09-28T13:22:51.743+00:00"
}
Topic: $crosser/modules/{moduleId}/status [RETAINED]
When a module changes status (Ok, Warning, Error):
{
"moduleId": "9f5f82a2-1dc0-433d-805e-182be417fdef",
"moduleName": "Queue & Persistence",
"version": "2.3.0",
"status": "Warning",
"flowId": "2220e7a7-9e98-4af3-afd4-a1b309128540",
"flowName": "MQTT Notifications",
"reason": "Module Queue & Persistence, 2.3.0 changed to status Warning: Queue is full (100), message was dropped, fullMode=DropWrite, persistent=True",
"queue": {
"mode": "DropWrite",
"size": 100,
"retries": 3,
"retryDelay": 100,
"delay": 0,
"persistence": true
},
"nodeId": "27929e60-a586-4f51-a512-0583391b0c86",
"nodeName": "Machine123",
"timestamp": "2023-09-28T13:22:51.743+00:00"
}
When the module queue is full and the strategy is not wait.
{
"moduleId": "9f5f82a2-1dc0-433d-805e-182be417fdef",
"moduleName": "Queue & Persistence",
"version": "2.3.0",
"status": "Warning",
"flowId": "2220e7a7-9e98-4af3-afd4-a1b309128540",
"flowName": "MQTT Notifications",
"reason": "Queue is full",
"queue": {
"mode": "DropWrite",
"size": 100,
"persistence": {
"enabled": true,
"retries": 3,
"retryDelay": 100
}
},
"nodeId": "27929e60-a586-4f51-a512-0583391b0c86",
"nodeName": "Machine123",
"timestamp": "2023-09-28T13:22:51.743+00:00"
}
When persistence is on and a message has failed maximum number of times it will be moved to the deadletter queue. You will then get a message similar to this:
{
"moduleId": "9f5f82a2-1dc0-433d-805e-182be417fdef",
"moduleName": "Queue & Persistence",
"version": "2.3.0",
"status": "Ok",
"flowId": "2220e7a7-9e98-4af3-afd4-a1b309128540",
"flowName": "MQTT Notifications",
"reason": "Retries maxed out",
"queue": {
"mode": "DropWrite",
"size": 100,
"persistence": {
"enabled": true,
"retries": 3,
"retryDelay": 100
}
},
"link": "http://localhost:9191/api/flows/2220e7a7-9e98-4af3-afd4-a1b309128540/deadletters/043e9604-837d-41b7-8a63-ad85321bfe32",
"nodeId": "27929e60-a586-4f51-a512-0583391b0c86",
"nodeName": "Machine123",
"timestamp": "2023-09-28T13:22:51.743+00:00"
}