In this tutorial, you will learn how to use the MQTT Adapter for SAP Cloud Platform Integration Services, built in-house by our team of developers.

Introduction.

MQTT is a machine to machine protocol which supports a lightweight version of publish/subscribe messaging transport. It is therefore mostly used in Internet of Things (IoT) scenario. Typically speaking, devices will need to send messages to a MQTT broker.

For customers and partners using SAP, Rojo Consultancy B.V has developed a MQTT adapter for the SAP Hana Cloud Platform, Integration Services (SAP HCI). To read more about this adapter, check out our blog post all about it.

This tutorial will give you a step by step demonstration of how you can use the SAP HCI MQTT adapter.
Note that the MQTT adapter is not available by default in your SAP HCI tenant. You can buy it on the official SAP store by clicking here.

Scenario.

You have a number of devices deployed in the field. For sake of simplicity, assume that these are vending machines for selling different types of cookies. As the company owning the vending machines, you would like to have direct access (online) of the events happing on the vending machines.

For simplicity sake, assumes that these devices are pushing their events at mosquitto.org publicly available MQTT server. Mosquitto provides a free MQTT broker that can be used to ease your exploration of what is possible with our MQTT adapter.

Scenario

Figure 1. Scenario

Because the focus of this article is how to use the MQTT adapter, to show case the feature of both sender and receiver adapter, we will pick the message from one MQTT topic (using the sender MQTT adapter) and push the message to another MQTT topic (using the receiver MQTT adapter). This scenario is depicted in the above Figure. We are assuming that your devices are already sending data to the MQTT broker.

Solution: Create a simple integration flow with the MQTT Adapter

Requirements:

Step 1. Create an integration package in SAP HCI

  1. Launch SAP HCI Web application by accessing the URL provided by SAP.
  2. If you are a new user, choose Signup.
  3. If you have user credentials, choose Login.

Pic2.jpg

Figure 2. SAP HCI – Home

  1. Select Pic3.jpg  and choose the Design tab.
  2. Choose Create and insert the required data to create a new Integration Package.
Data Insert
Name New Integration Package
Version <Version>
Owned By <Owned By>
Description <Description>

Pic4.jpg
Figure 3. SAP HCI – New Integration Package

Step 2. Create and add a new integration flow in SAP HCI

  1. Choose Add, and select Process Integration to add a new integration flow as an artifact.
  2. Select Create and enter the required data.
Data Insert
Create Select this checkbox
Name Test Process Integration
Description <Description>
Sender Sender
Receiver Receiver

Pic5.jpg
Figure 4. SAP HCI – Add Process Integration Artifact

Choose Ok to add the process integration artifact.

  1. Choose Save to keep the integration package.

Step 3. Assign MQTT Adapter to integration flow in SAP HCI

  1. Click on the integration flow artifact name and choose Edit.

Pic6.jpg
Figure 5. SAP HCI –  Configuration Integration Flow

  1. Select Sender and choose drag.jpgto drag the pointer to Start to define the sender channel.
  2. Choose MQTT adapter.

Pic7.jpg
Figure 6. SAP HCI – Choose Adapter Type

  1. Select End and choose  drag-(1).jpg to drag the pointer to Receiver to define the receiver channel.
  2. Choose MQTT adapter.

Pic8.jpg
Figure 7. SAP HCI – Configuration Integration Flow with Sender and Receiver MQTT Adapter

Step 4. Configure Sender MQTT Adapter in SAP HCI

  1. Choose Edit.
  2. Select the Sender MQTT adapter, select General tab and enter the required data into fields Name and Description.
Data Insert
Name CC_Sender
Channel Details
Description <Description>

Pic9.jpg
Figure 8. SAP HCI – General Tab in Sender MQTT Adapter

  1. Select Adapter Specific tab and enter the data into Connection Details. In this scenario mosquito.org is used, with port 1883. Topic name can be anything and “/” indicates a topic level separator.
Data Insert
Connection Details
Host mosquitto.org
Port 1883
Topic amsterdam/buildingA/floor1/temperature (this is just an example)
Client ID SAP_HCI_Sender
Quality of Service QoS 0: At Most Once
Authentication None

Pic10.jpg
Figure 9. SAP HCI – Adapter Specific Tab in Sender MQTT Adapter

  1. Select Advanced tab and insert the data into Advanced Option.
Data Insert
Advanced Options
Timeout (in s) 30
Keep Alive Interval (in s) 60
MQTT Version 3.1.1
Clean Session
Detailed Trace

Pic11.jpg
Figure 10. SAP HCI – Advanced Tab in Sender MQTT Adapter

  1. Choose Save to keep this configuration of the Sender MQTT adapter.

Step 5. Configure Receiver MQTT Adapter in SAP HCI

  1. Select Provider MQTT adapter, select General tab and insert the required data into fields Name and Description.
Data Insert
Name CC_Receiver
Channel Details
Description <Description>

Pic12.jpg
Figure 11. SAP HCI – General Tab in Receiver MQTT Adapter

  1. Select Adapter Specific tab and insert the data in section Connection Details.
Data Insert
Connection Details
Host mosquitto.org
Port 1883
Topic datastore/amsterdam/buildingA/floor1/temperature (this is just an example)
Client ID SAP_HCI_Receiver
Quality of Service QoS 0: At Most Once
Authentication None
Retained Checked

Pic13.jpg
Figure 12. SAP HCI – Adapter Specific Tab in Receiver MQTT Adapter

  1. Select Advanced tab and insert the data into Advanced Option, similar to the Sender MQTT Adapter configuration.
Data Insert
Advanced Options
Timeout (secs) 30
Keep Alive Interval 60
MQTT Version 3.1.1
Clean Session
Detailed Trace

Pic14.jpg
Figure 13. SAP HCI – Advanced Tab in Receiver MQTT Adapter

The Last Will and Testament tab is not configured in this tutorial.

  1. Choose Save to keep this configuration of the Receiver MQTT adapter and choose Deploy.

Pic15.jpg
Figure 14. SAP HCI – Integration Flow Triggered for Deployment

And, voila! You have finished your configuration and can now proceed with testing.
For the purpose of testing, you can use any MQTT client of your choice (like MQTT fx)  to place a file in the topic that the sender adapter is reading. e.g: “amsterdam/buildingA/floor1/temperature”.
Questions? Get in touch.