In this blog I detail the procedure to separate the device messages that contain temperature alert. Once these are separated, they can be channeled to separate cloud storage and also trigger actions to intimate the user about the alert.
The messages with alert are sent to a critical queue and read from that. This is done as described in the Azure document
- First a Service Bus Messaging Namespace is created in Azure Portal as follows:
- Go to +New -> Enterprise Integration -> Service Bus. This shows the Create Namespace panel.
- .Here created a name space named esm-sb-ns.
- Then copied the connection string for this name space to text file.
- In this name space then created a Queue named esm-iot-critical-q.
- Then in the IoT Hub named esmiothub, created a custom endpoint with following attributes:
- Name: esm-critical-q-ep
- Type: Service Bus Queue
- Service Bus Namespace: esm-sb-ns
- Service Bus Queue: esm-iot-critical-q
- Then created a Route in the same IoT Hub with following attributes:
- Name: esm-iot-critical-route.
- Data Source: Device Messages
- Endpoint: esm-critical-q-ep
- Query String: TemperatureAlert="true"
- Then created a .Net Console app named vc_read_alerts. The code for which is shown in the screenshot below.
Then both vc_read_alerts and vc_device_live_data are run simultaneously. The STM unit was also powered up. It is expected that all messages with "No Alert" are to be picked up by vc_device_live_data and the messages with "Alert Occurred" will be picked up by the vc_read_alerts program. Unfortunately alert messages were not picked up by vc_read_alerts. This can be seen in the screenshot below. The upper part is the output of vc_device_live_data and the lower part is that of vc_read_alerts. I have created alert by moving the sensors to near a warm light bulb. This needs to be debugged.