Editing Adapter Configuration Files
Edit a set of adapter configuration files in order to make the custom adapter available to both the HANA Streaming Analytics server at run time and in HANA Studio at design time.
Overview
You will learn
- Locate which files to edit locally on HANA Studio and on the Streaming Server
- How to edit the
modulesdefineandcustommodulesdefine.xmlfiles - How to edit the
parametersdefine.xmlfile - To transfer the files edited on the Streaming Server to the client where the HANA Studio is running
Prerequisites
Prerequisites
Steps
Next Steps
Time to Complete
15 Min
Intro
IMPORTANT! Since you’re running a
multidbSAP HANA environment,$STREAMING_CUSTOM_ADAPTERS_HOMEwill refer toassuming you have used the default location of/hana/shared/<SID>/streaming/cluster/<tenant db>/adapters/hanaas the root directory for the installation.
For this step, we will be adding our custom modules to the modulesdefine.xml file and custommodulesdefine.xml file, and adding parameter definitions from the .cnxml file to parametersdefine.xsd. The modulesdefine.xml file is located in the $STREAMING_HOME/adapters/framework/config directory, the custommodulesdefine.xml file is located in the $STREAMING_CUSTOM_ADAPTERS_HOME/config directory, and the parametersdefine.xsd is located in the $STREAMING_CUSTOM_ADAPTERS_HOME/config directory. We are not creating these files from scratch. The purpose of the modulesdefine.xml file is to define our custom modules (Transporter and Formatter) so HANA Streaming Analytics knows what they do and where they reside.
The parametersdefine.xsd file simply defines what elements are valid in an adapter_config.xml file (adapter configuration file). Since we have used a custom element – MqttInputTransporterParameters – in our adapter_config.xml file, we must define it in parametersdefine.xsd.
The full source code for the
modulesdefine.xmlandcustommodulesdefine.xmlfiles are provided in theAppendixSection
Open
modulesdefine.xmlin a text editor.We will add our Transporter module to the
TransporterDefnListCreate a
<TransporterDefn>element.XML<TransporterDefn>Create a
<Name>element. Specify the name of our custom Transporter class.XML<Name>MqttTransporter</Name>Create a
<Class>element.XML<Class>com.sap.MqttTransporter</Class>Create an
<OutputData>element.XML<OutputData>String</OutputData>Close off the
<TransporterDefn>element.XML</TransporterDefn>
We will add our formatter module to the
formatterDefnListCreate a
<FormatterDefn>element.XML<FormatterDefn>Create a
<Name>element. Specify the name of our customTransporterclass.XML<Name>MqttFormatter</Name>Create a
<Class>element.XML<Class>com.sap.MqttFormatter</Class>Create an
<InputData>element.XML<InputData>String</InputData>Create an
<OutputData>element.XML<OutputData>Esp</OutputData>Close off the
<FormatterDefn>element.XML</FormatterDefn>
Repeat steps 1 to 3 for
custommodulesdefine.xml.
For the question below, select the correct answer, and click Validate.
The full source code for the
parametersdefine.xsdfile is provided in theAppendixSection
Open
parametersdefine.xsdin a text editor.Add the following line to the
<xs:choice>element
```XML
<xs:element name="MQTTInputTransporterParameters" type="MQTTInputTransporterParametersDefn"/>
```
- Since we have defined the
MQTTInputTransporterParameterstype to beMQTTInputTransporterParametersDefn, we must now set up a rule for it.
- Create a <xs:complex> element and specify the name attribute.
```XML
<xs:complexType name="MQTTInputTransporterParametersDefn">
```
- Create an `<xs:all>` element.
- Create an `<xs:element>` element for each `MQTTInputTransporterParametersDefn` parameter (`Topic` and `MosquittoServerAddress`) and specify name and type attributes for each.
```XML
<xs:element name="MosquittoServerAddress" type="xs:string"></xs:element> <xs:element name="Topic" type="xs:string"></xs:element>
```
- Close off the `<xs:all>` and `<xs:complexType>` elements.
```XML
</xs:all>
</xs:complexType>
```
modulesdefine.xml
This is not the full markup of the file. Open your
modulesdefine.xmlfile in a text editor and add theTransporterDefnandFormatterDefnelements of the markup shown below.
<?xml version="1.0" encoding="utf-8"?>
<ModulesDefinition>
<TransporterDefnList>
…
…
<TransporterDefn>
<Name>MqttTransporter</Name>
<Class>com.sap.MqttTransporter</Class>
<OutputData>String</OutputData>
</TransporterDefn>
</TransporterDefnList>
<FormatterDefnList>
…
…
<FormatterDefn>
<Name>MqttFormatter</Name>
<Class>com.sap.MqttFormatter</Class>
<InputData>String</InputData>
<OutputData>ESP</OutputData>
</FormatterDefn>
</FormatterDefnList>
…
</ModulesDefinition>custommodulesdefine.xml
This is not the full markup of the file. Open your
custommodulesdefine.xmlfile in a text editor and add theTransporterDefnandFormatterDefnelements of the markup shown below.
<?xml version="1.0" encoding="utf-8"?>
<ModulesDefinition>
<TransporterDefnList>
…
…
<TransporterDefn>
<Name>MqttTransporter</Name>
<Class>com.sap.MqttTransporter</Class>
<OutputData>String</OutputData>
</TransporterDefn>
</TransporterDefnList>
<FormatterDefnList>
…
…
<FormatterDefn>
<Name>MqttFormatter</Name>
<Class>com.sap.MqttFormatter</Class>
<InputData>String</InputData>
<OutputData>ESP</OutputData>
</FormatterDefn>
</FormatterDefnList>
…
</ModulesDefinition>paramtersdefine.xsd
This is not the full markup of the file. Open your
custommodulesdefine.xmlfile in a text editor and add thexs:elementandxs:complexTypeelements of the markup shown below.
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:include schemaLocation="standard_module_parametersdefine.xsd"/>
<xs:complexType name="DefinedTypeParameters">
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="1">
…
<xs:element name="MQTTInputTransporterParameters"
type="MQTTInputTransporterParametersDefn"/>
…
</xs:choice>
</xs:sequence>
</xs:complexType>
…
<xs:complexType name="MQTTInputTransporterParametersDefn">
<xs:all>
<xs:element name="MosquittoServerAddress" type="xs:string"></xs:element>
<xs:element name="Topic" type="xs:string"></xs:element>
</xs:all>
</xs:complexType>
…
</xs:schema>Resources
Discussion
Share feedback on this tutorial or join the conversation in SAP Community.