Test the Custom Java Toolkit Adapter
Prerequisites
- Tutorial: Where to Place the Custom Adapter Files
- Step 1
Open a command prompt(
CMD
) and navigate to the install directory ofMosquitto
. The default location is inC:\Program Files(x86)\Mosquitto
. Run theMosquitto
broker by typingmosquitto.exe
- Step 2
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.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”.Replace
<your-ip-address>
with theip address
of the machine you will be running theMosquitto
MQTT
message broker. - Step 3
Ensure that the server you have placed your custom adapter, including the required configuration files on is set as the
Default Server URL
. TheStreaming 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.-
Select Window > Preferences in your
IDE
. -
With the Preferences window now open, select SAP HANA streaming analytics and, if necessary, change the
Default Server URL
to match theip address
of the machine you are running the Streaming Server. ClickApply
and thenOK
.
-
- Step 4
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.
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.
- Step 5
Switch to the SAP HANA Streaming Run-Test perspective from the Quick Access toolbar in the top right corner of your
IDE
.Open the input window by double clicking
InputWindow1
in the Run-Test perspective of HANA Studio. This is where theMQTT
message will appear. - Step 6
Open another command prompt (
CMD
) window and navigate to the install directory ofMosquitto
. The default location is inC:\Program Files (x86)/Mosquitto
.Run the
mosquitto_pub.exe
program withmosquitto_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"
You should now be able to view the published
MQTT
message inInputWindow1
.In the box below, enter the string you have received in the
MQTT
message on HANA Studio, and click Validate. - Step 7SQLCopy
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' ;