In this blog, I’m going to show you how you can use the SAP HANA Cloud Connector and the IoT Message Management Service together.
Therefore I’ll start with a fictional scenario so you can imagine why one would want this. Followed by a step-by-step guide how to achieve it and how to test.
2. The Scenario
You have an amazing IoT Application up and running, but it’s running in your datacenter and not in the cloud. Of course, you want to move to the cloud, because the cloud is awesome, we all know.
Some months fast forward, you developers did an outstanding job and most of your software components are now ready to run in the cloud. But some components, which are only needed to process the data from the first generation of your device, are not and you don’t want to move them to the cloud because the device almost reached EOL.
Of course, you decided to use the SAP Cloud Platform and its IoT Service.
You’re using the IoT MMS as a router for any incoming message and some of those messages (green arrows in the diagram) should be sent to your legacy system while the rest (blue arrows) is consumed directly in the cloud.
I will cover:
- How to configure the SAP HANA Cloud Connector for the described scenario.
- How to configure the IoT MMS for the described scenario.
I won’t cover:
- Installing and securing an SCC instance (see SAP HANA Cloud Connector Documentation).
- Setting up the IoT Service (see Message Management Service Documentation).
- Writing a processing service.
4.1 Processing Service
You’ll need a message processing service inside your corporate network. For the seek of this blog, it is not necessary that your processing service does anything meaningful with the data, this can be added later.
It can be basically anything which is able to understand an HTTP POST request. e.g.:
- A LAMP or XAMP instance
- A Java EE Container
- Some ABAP Code
- If you just want to test out the possibilities, you can use this python code. It starts an HTTP Server and accepts HEAD, GET and POST requests. Except logging the requests to standard output, it does nothing. Because it’s the most generic option to follow I’ll use this one. If you decide to use another option and experience problems, first try this “default” option before commenting, it will help me or other readers to understand your problem and provide solutions.
4.1 IoT Service
You’ll need at least one message type, one device type and one device configured in the IoT MMS (see Message Management Service Documentation).
To test your setup, you will need a way to generate some messages. You can either use a physical device like a Tessel or just generate messages using the web interface of the IoT MMS.
Because using the web interface is the most generic option to follow I’ll use it. If you decide to use another option and experience problems, first try this “default” option before commenting, it will help me or other readers to understand your problem and provide solutions.
5. Let’s do it
5.1 Add a system mapping to SCC
- Make sure your processing service is running. If you’re using the provided python script with the default port you can check it by accessing this URL: http://localhost:8000. Also, check the log.
- Add a system mapping as shown in the screenshot below.
- If you’re using the provided python script use the following settings. Otherwise, adapt them to match your needs.
HTTP localhost 8000 iotprocessingservice 8000 None Something meaningful
- You should now see a new entry listed at Mapping Virtual To Internal System.
- I recommend checking if the cloud connector can reach your processing service. To do so, use the icon highlighted in the screenshot below. If the check succeeds, you should see a HEAD request in your log.
Click the + Icon next to Resources Accessible On iotprocessingservice:8000 and fill the upcoming popup like shown below and click Save.
5.2 Add a Message Consumer to the IoT MMS
- Open your Message Management Service Cockpit.
- Select the Configure Processing Service Mappings Tile
- Select the Mapping for the Device Type and Message Type of which the data should be sent to your OnPremise Processing Service or create a new one, if you haven’t created one before.
- Press the Add Processing Service Button and select http
- On the next screen, configure the following settings (anything not shown up in the table can be left at default values):
mms.processing.http.proxy_enabled true mms.processing.http.proxy_host localhost mms.processing.http.proxy_port 20003 mms.processing.http.send_mode messages mms.processing.http.url http://iotprocessingservice:8000
- Press Add HTTP-Header and use “SAP-Connectivity-ConsumerAccount” as Header Name and the name of your account as Header Value
- Click Back to Mapping Page and then Save.
Update 03/16/2017: I was asked the question where the proxy port and host values come from via Email. They are available in the environment variable HC_OP_HTTP_PROXY_HOST respectively HC_OP_HTTP_PROXY_PORT as documented here https://help.hana.ondemand.com/help/frameset.htm?d872cfb4801c4b54896816df4b75c75d.html. Currently, these values are set to localhost and 20003 on every SAP Cloud Platform landscape (without guarantee), but this might change in the future and break the connection. Do not use this productively yet, it is a proof of concept. I’ll update this post as soon as I found an appropriate solution, feel free to comment and if you plan to use this productively so I can keep you updated.
Now it’s time to generate some test data and keep an eye on the log to see if the messages get delivered as supposed.
- Go back to the initial screen of your Message Management Service Cockpit.
- Select the Messaging through HTTP Tile
- Change the values in the red boxes so that they match your configuration.
- Click Send
- Now check the Reply from Server Section. It should look similar to the following:
- Also, check the log of your Processing Service. It should look similar to this:
- SAP HANA Cloud Connector 18.104.22.168
- Message Management Service 2.35.0
- Python 2.7.11
- Windows 10.0.10586
- Google Chrome 56.0.2924.87