Few months back, Message Processing functionality was introduced in HANA Cloud Platform IoT services. This provides more flexibility to process incoming messages. You no longer need to persist the messages in HCP, you could either forward the incoming message to a web service, message broker or Smart Data Streaming depending on your requirements.
In this blog, I am going to focus on the SQL message processing option. This is the default processing service which stores all the incoming messages in a database table. If none of these options are maintained, we have seen how MMS automatically creates a message table with a name which matches the Message type ID. It follows the naming scheme T_IOT_[Message Type ID]. You also would recollect that there would be two columns named G_DEVICE and G_CREATED which represent the device ID and timestamp when the message was stored in the table. All the remaining message fields would be mapped to a column prefixed with C_.
With SQL Message processing service, you longer need to stick to a I_IOT_MessageID table with such column definitions. You can create your own table, in your own schema and have columns with the name you provide.
Navigate to the HCP IoT services cockpit to create Message Type/Device Type and Devices
In the below screen, I have created a message type with two fields
I have assigned the message type to a device type.
Finally I have created a Device for the above device type.
In the payload, I provide the new table name along with the mappings of the message fields with table columns. Notice that I have set “add_default_columns” to true. This will automatically add G_DEVICE and G_CREATED columns in the table.
When I click on SEND, it would provide a below response stating that the service mapping has been registered.
Navigate to the MSS cockpit and click on the “Configure Processing Service Mappings”
You will notice there is a Processing service entry of type SQL. If you want to add more service mappings, you could do it straight from this UI too.
In the detail screen, you will be able to verify the table name along with the message field mappings to table columns
Now, we can test the message by using the test client provided in MMS cockpit.
I am going to use HTTP APIs to test the IoT messages from thecockpit
You will notice a success message as shown below
You can use the Service mappings to create a flexible chain of message processing by forwarding the IoT messages to other web services and event stream processors. I have also posted on how to configure Service mappings for Smart Data Streaming in Capture event streams from IoT devices and perform predictive analytics using HCP – Part 4