SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
โคข Open full site

Creating Custom Adapter Configuration Files

Create a .cnxml file and an Adapter Configuration File(.xml) for your Custom Adapter.

Overview

🎓 intermediate 15 min. SAP HANA Streaming AnalyticsIntermediateInternet Of ThingsSAP HANAExpress Edition

You will learn

  • โœ”How to create a .cnxml configuration file
  • โœ”How to create an Adapter Configuration File(.xml)
Robert Waywell R Robert Waywell January 15, 2025
Created by March 13, 2018
Contributors

Prerequisites

Prerequisites

Steps

Next Steps

Time to Complete

20 Min


Step 1 Create a `.cnxml` configuration file
โ€”

We will now be writing a configuration file that we will name mqtt_input.cnxml. This follows the loose naming convention of <adapter>_<{input,output}>.cnxml.

The purpose of this .cnxml file is to define which parameters will be offered to the user and how Studio will start and stop the adapter.

The full source code for the .cnxml configuration file is provided in the Appendix Section

First, we will create an <Adapter> element and specify attributes for it.

AttributeDescription
type(Required) Specify whether this is an input or output adapter
external(Required) Set to true, as this is an external adapter
id(Required) Specify a unique identifier for your adapter. This value is listed in the type parameter within the ATTACH ADAPTER statement
label(Required) The name of your adapter. This name appears in the SAP Streaming Analytics Authoring perspective if you hover over the adapter icon in the visual editor
description(Required) Specify the purpose of the adapter. This is also visible in the SAP Streaming Analytics Authoring perspective.

Our adapter is an external input adapter and we will not be supporting schema discover.

HTML
<Adapter type="input" external="true"
  id="mqtt_input"
  label="MQTT Input Adapter"
  descr="Listens for MQTT messages published in a specified topic."
  supportsDiscovery="false"
>

Then, create a &lt;Library&gt; element and specify attributes for it.

AttributeDescription
file(Required) Always specify simple_ext as the value for external adapters
type(Required) Specify binary as the value.
HTML
<Library file="simpleext" type="binary"/>

Create a special &lt;Special&gt; element and specify internal parameters for it. See the $STREAMING_HOME/lib/adapters/simple_ext.cnxml.template sample .cnxml file for a complete list of internal parameters and usage details.

HTML
<Special>

Any commands specified in the .cnxml file for an adapter cannot contain the following strings: mv, rm, or del.

Create an x_allocateLocalSessionId &lt;Internal&gt; element and specify attributes for it. This element will allow the adapter to connect to the project using a session id of its choosing.

HTML
<Internal id="x_allocateLocalSessionId"
 label="Request a new local session id"
 descr="Request the project to allocate a new local session
id."
 type="boolean"
 default="true"
/>

Create an x_unixCmdExec &lt;Internal&gt; element and specify attributes for it. This is the command that the adapter framework will use to start the adapter in a Unix environment.

HTML
<Internal id="x_unixCmdExec"
 label="Execute Command"
 type="string"
 default="&quot;$STREAMING_HOME/adapters/framework/bin/start.sh&quot;&quot;$STREAMING_HOME/adapters/framework/instances/mqtt_input/adapter_config.xml&quot; &quot;DMQTTInputTransporterParameters.MosquittoServerAddress=$mosquittoServerAddress&quot; &quot;DMQTTInputTransporterParameters.Topic=$topic&quot;"
/>

Create an x_winCmdExec &lt;Internal&gt; element and specify attributes for it. This is the command that the adapter framework will use to start the adapter in a Windows environment. The Streaming Analytics server is not supported on Windows, but our custom adapter can work with Streaming Analytics systems.

HTML
<Internal id="x_winCmdExec"
 label="Execute Command"
 type="string"

default="&quot;%STREAMING_HOME%/adapters/framework/bin/start.bat&quot; &quot;%STREAMING_HOME%/adapters/framework/instances/mqtt_input/adapter_config.xml&quot; &quot;DMQTTInputTransporterParameters.MosquittoServerAddress=$MosquittoServerAddress&quot; &quot;DMQTTInputTransporterParameters.Topic=$Topic&quot;"
/>

Create an x_unixCmdStop &lt;Internal&gt; element and specify attributes for it. This is the command that the adapter framework will use to stop the adapter in a Unix environment.

HTML
<Internal id="x_unixCmdStop"
 label="Stop Command"
 type="string"

default="&quot;$STREAMING_HOME/adapters/framework/bin/stop.sh&quot; &quot;$STREAMING_HOME/adapters/framework/instances/mqtt_input/adapter_config.xml&quot;"
/>

Create an x_winCmdStop &lt;Internal&gt; element and specify attributes for it. This is the command that the adapter framework will use to stop the adapter in a Windows environment.

HTML
<Internal id="x_winCmdStop"
 label="Stop Command"
 type="string"
 default="&quot;%STREAMING_HOME%/adapters/framework/bin/stop.bat&quot; &quot;%STREAMING_HOME%/adapters/framework/instances/mqtt_input/adapter_config.xml&quot;"
/>

Close off the &lt;Special&gt; tag.

HTML
</Special>

Now, we will specify adapter parameters for the Section element.

These parameters are visible and configurable in studio and the elements contained in this element will be the parameters streaming developers can set for the adapter.

For each parameter, specify:

ParameterDescription
id(Required) The property ID that you can reference in &lt;Internal&gt;command calls with $&lt;varname&gt;ID name&lt;/varname&gt;. This is what you reference when specifying adapter properties for an adapter in CCL.
label(Required) The property name that appears in Studio.
descr(Required) A description of the adapter property.
type(Required) The property datatype.
use(Required) Whether the property is required, optional, or advanced. In Studio, required properties appear in red and advanced ones appear on a separate tab.
default(Optional) The default value to use, if you do not set a value for the property.

Create a mosquittoServerAddress &lt;Parameter&gt; element and specify attributes for it.

Don’t forget to replace &lt;your-ip-address&gt; with your client’s ip address.

HTML
<Parameter id="mosquittoServerAddress"
 label="Mosquitto Server Address"
 descr="The address of the mosquitto server used as a broker"
 type="string"
 use="required"
 default="tcp://<your-ip-address>:1883"
/>

Create a topic &lt;Parameter&gt; element and specify attributes for it.

HTML
<Parameter id="topic"
 label="MQTT Subscription Topic"
 descr="Topic to listen to for MQTT messages."
 type="string"
 use="required"
default="test"
/>

Close the &lt;Section&gt; and &lt;Adapter&gt; tags.

HTML
</Section>
</Adapter>

For the question below, select the correct answer, and click Validate.

Step 2 Create an Adapter Configuration File(.xml)
+
Step 3 Appendix
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 3
1. Create a `.cnxml` configuration file 2. Create an Adapter Configuration File(.xml) 3. Appendix

Learn more →