Skip to Content
Previous

Test the Custom Java Toolkit Adapter

By Gunesh Pinar

Test the MQTT Input Adapter we have created using Mosquitto and HANA Studio.


Step 1: Run the `Mosquitto` broker

Open a command prompt(CMD) and navigate to the install directory of Mosquitto. The default location is in C:\Program Files(x86)\Mosquitto. Run the Mosquitto broker by typing mosquitto.exe

Run Mosquitto Exe
Please log in to access this content.
Step 2: Configure your Streaming Project

Set up a streaming project like the one shown below if you haven’t already set up one in the previous tutorial (Where to Place the Custom Adapter Files). The ccl code is provided in the Appendix section.

Custom Adapter Streaming Project

Right click on the “Properties” to enable editing.

Choose the topic for the new MQTT_Input_Adapter1 to subscribe to. In this tutorial, we will use “test”.

Edit Topic Test

Replace <your-ip-address> with the ip address of the machine you will be running the Mosquitto MQTT message broker.

Edit Your IP Address
Please log in to access this content.
Step 3: Set Default Server URL

Ensure that the server you have placed your custom adapter, including the required configuration files on is set as the Default Server URL. The Streaming Server being used to compile the project that is using the custom adapter needs to have access to the adapter configuration files during the compile process.

  1. Select Window > Preferences in your IDE.

    Setting Default URL Preferences
  2. With the Preferences window now open, select SAP HANA streaming analytics and, if necessary, change the Default Server URL to match the ip address of the machine you are running the Streaming Server. Click Apply and then OK.

    Setting Default URL Preferences
Please log in to access this content.
Step 4: Run your Streaming Project

In the SAP HANA Streaming Development perspective right click on the project in the Project Explorer, go to SAP HANA streaming analytics, and click on Compile Streaming Project to compile your project.

Compile your Streaming Project

To run your project, right click on the project in the Project Explorer, go to SAP HANA streaming analytics, then run, and click on Run Streaming Project in Workspace to run your project.

Run your Streaming Project
Please log in to access this content.
Step 5: Open the Input Window

Switch to the SAP HANA Streaming Run-Test perspective from the Quick Access toolbar in the top right corner of your IDE.

Switch to Run-Test Perspective

Open the input window by double clicking InputWindow1 in the Run-Test perspective of HANA Studio. This is where the MQTT message will appear.

Select Input Window 1
Please log in to access this content.
Step 6: Send an MQTT Message using Mosquitto

Open another command prompt (CMD) window and navigate to the install directory of Mosquitto. The default location is in C:\Program Files (x86)/Mosquitto.

Run the mosquitto_pub.exe program with

mosquitto_pub.exe -t<topic>–m<message>–h<your-ip-address>”.

E.g. mosquitto_pub.exe –t "test" –m "Hello World!" –h "1.0.100.200"

Send an MQTT Message with Mosquitto

You should now be able to view the published MQTT message in InputWindow1.

View your MQTT Message

In the box below, enter the string you have received in the MQTT message on HANA Studio, and click Validate.

×
Appendix  

CREATE INPUT WINDOW InputWindow1 SCHEMA ( Message string ) PRIMARY KEY ( Message ) KEEP ALL ROWS ; ATTACH INPUT ADAPTER MQTT_Input_Adapter1 TYPE mqtt_input TO InputWindow1 PROPERTIES mosquittoServerAddress = 'tcp://<your-ip-address>:1883' , topic = 'test' ;
Please log in to access this content.

Next Steps

Updated 04/17/2018

Time to Complete

15 Min

Intermediate

Prerequisites

Next
Back to top