The latest version for DAS is WSO2 Data Analytics Server 3.1.0. View documentation for the latest release.
WSO2 Data Analytics Server is succeeded by WSO2 Stream Processor. To view the latest documentation for WSO2 SP, see WSO2 Stream Processor Documentation.

All docs This doc
||
Skip to end of metadata
Go to start of metadata

By default, event publishers publish events in XML, JSON, Text, Map (Key-value pairs), and WSO2Event formats.Thereby, if the remote endpoint can process a default format, select the supported default format for Message Format property under Mapping Configuration when creating event publishers.

However, if the remote endpoint cannot process default formats, when creating event publishers select the supported format for Message Format , click the Advanced section and provide output mappings to convert the event to a supported format which the remote endpoint could process. 

This section covers the following types of output event publisher mappings that WSO2 CEP/DAS supports and how to configure them.

WSO2Event output mapping

WSO2Event output mapping converts events from one WSO2Event format to another. You need to define both the event stream to retrieve events for publishing and the mapped outgoing event stream for it. If the input event has any arbitrary data, they are mapped to the arbitrary data of the output event.

A sample mapping configuration is shown below.

WSO2Event sample output mapping configuration

The configuration XML file of the above sample mapping is as follows.

<eventPublisher ... xmlns="http://wso2.org/carbon/eventpublisher">
  <from ... />
  <mapping customMapping="enable" type="wso2event">
    <to streamName="sensor.stream" version="1.0.7"/>
    <metaData>
      <property>
        <from name="meta_sensorId"/>
        <to name="id" type="int"/>
      </property>
      <property>
        <from name="meta_sensorName"/>
        <to name="name" type="string"/>
      </property>
    </metaData>
    <payloadData>
      <property>
        <from name="humidity"/>
        <to name="humidity" type="float"/>
      </property>
      <property>
        <from name="sensorValue"/>
        <to name="value" type="double"/>
      </property>
    </payloadData>
  </mapping>
  <to ... />
</eventPublisher>                 

Events with null or empty attributes

In case of an event is being published with null or empty attributes the behaviour for WSO2Event Output mapping is as follows.

  • Non-String Attributes (e.g. int, double, long etc.)
    • null - DAS will send this event as a WSO2Event with a null value for the particular attribute

  • String Attributes
    • null - It will be sent out as a null value
    • Empty Attribute - It will be published as an empty string attribute

XML output mapping

XML output mapping converts canonical events of the server in the WSO2Event format to any XML message format that an endpoint can support. Attributes without a meta_ or a correlation_ prefix are matched with payload attributes. If they do not match with existing payload attributes, are considered arbitrary data attributes. If you want to use a registry resource for output mapping, see Using Registry Resources for Output Mapping.

A sample mapping configuration is shown below.

sample XML output mapping configuration

The configuration XML file of the above sample mapping is as follows.

<eventPublisher ... xmlns="http://wso2.org/carbon/eventpublisher">
  <from ... />
  <mapping customMapping="enable" type="xml">
    <inline>
      <sensorData xmlns="">
        <id>{{meta_sensorId}}</id>
        <sensorValue>{{sensorValue}}</sensorValue>
        <humidity>{{humidity}}</humidity>
      </sensorData>
    </inline>
  </mapping>
  <to ... />
</eventPublisher>

Events with null or empty attributes

In case of an event is being published with null or empty attributes the behaviour for XML Output mapping is as follows.

  • Non-String Attributes (e.g. int, double, long etc.)
    • null - DAS will convert this to an empty value and send out

    • Empty attribute - DAS will send this as it is as an empty value
  • String Attributes
    • null - It will be converted to an empty string and sent out
    • Empty Attribute - It will be published as an empty string attribute

JSON output mapping

JSON output mapping converts canonical event s of the server in the WSO2Event format to any JSON message format that an endpoint can support. Attributes without a meta_ or a correlation_ prefix are matched with payload attributes. If they do not match with existing payload attributes, are considered arbitrary data attributes. If you want to use a registry resource for output mapping, see Using Registry Resources for Output Mapping .

A sample mapping configuration is shown below.

The configuration XML file of the above sample mapping is as follows.

<eventPublisher ... xmlns="http://wso2.org/carbon/eventpublisher">
  <from ... />
  <mapping customMapping="enable" type="json">
    <inline>{"sensorData": {
  "id": {{meta_sensorId}},
  "value": {{sensorValue}},
  "humidity": {{humidity}},
  "correlation": {"long": {{correlation_longitude}}, "lat": {{correlation_latitude}}}
}}</inline>
  </mapping>
  <to ... />
</eventPublisher>                 

Events with null or empty attributes

In case of an event is being published with null or empty attributes the behaviour for JSON Output mapping is as follows.

  • Non-String Attributes (e.g. int, double, long etc.)
    • null - DAS will send this as a null value

    • Empty attribute - DAS will send this as it is as an empty value
  • String Attributes
    • null - It will be sent out as a null value
    • Empty Attribute - It will be published as an empty string attribute

Text output mapping

Text output mapping converts canonical events of the server in the WSO2Event format to any text message format. Attributes without a meta_ or a correlation_ prefix are matched with payload attributes. If they do not match with existing payload attributes, are considered arbitrary data attributes. If you want to use a registry resource for output mapping, see Using Registry Resources for Output Mapping .

A sample mapping configuration is shown below.

sample text output mapping configuration

The configuration XML file of the above sample mapping is as follows.

<eventPublisher ... xmlns="http://wso2.org/carbon/eventpublisher">
  <from ... />
  <mapping customMapping="enable" type="text">
    <inline>Sensor Data
Sensor ID : {{meta_sensorId}}
Sensor Name : {{meta_sensorName}}
Sensor located at ({{correlation_longitude}}, {{correlation_latitude}})
Value : {{sensorValue}}
Humidity : {{humidity}}
</inline>
  </mapping>
  <to ... />
</eventPublisher>

Events with null or empty attributes

In case of an event is being published with null or empty attributes the behaviour for Text Output mapping is as follows.

  • Non-String Attributes (e.g. int, double, long etc.)
    • null - DAS will convert this to an empty value and send out

    • Empty attribute - DAS will send this as it is as an empty value
  • String Attributes
    • null - It will be converted to an empty string and sent out
    • Empty Attribute - It will be published as an empty string attribute

Map output mapping

Map output mapping converts canonical events of the server in the WSO2Event format to Map message format. A sample mapping configuration is shown below.

sample map output mapping configuration

The configuration XML file of the above sample mapping is as follows.

<eventPublisher ... xmlns="http://wso2.org/carbon/eventpublisher">
  <from ... />
  <mapping customMapping="enable" type="map">
    <property>
      <from name="meta_sensorId"/>
      <to name="id"/>
    </property>
    <property>
      <from name="meta_sensorName"/>
      <to name="name"/>
    </property>
    <property>
      <from name="sensorValue"/>
      <to name="value"/>
    </property>
  </mapping>
  <to ... />
</eventPublisher>

Events with null or empty attributes

In case of an event is being published with null or empty attributes the behaviour for XML Output mapping is as follows.

  • Non-String Attributes (e.g. int, double, long etc.)
    • null - DAS will send this as a null value

    • Empty attribute - DAS will send this as it is as an empty value
  • String Attributes
    • null - It will be sent out as a null value
    • Empty Attribute - It will be published as an empty string attribute
  • No labels