Output Mapping Types
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 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. A sample mapping configuration is shown below. The configuration XML file of the above sample mapping is as follows. 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. XML output mapping converts canonical events of the server in the WSO2Event format to any XML message format that an endpoint can support. A sample mapping configuration is shown below. The configuration XML file of the above sample mapping is as follows. 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. JSON output mapping converts canonical event s of the server in the WSO2Event format to any JSON message format that an endpoint can support. A sample mapping configuration is shown below. The configuration XML file of the above sample mapping is as follows. 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. Text output mapping converts canonical events of the server in the WSO2Event format to any text message format. A sample mapping configuration is shown below. The configuration XML file of the above sample mapping is as follows. 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. Map output mapping converts canonical events of the server in the WSO2Event format to Map message format. A sample mapping configuration is shown below. The configuration XML file of the above sample mapping is as follows. 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.WSO2Event output mapping
<?xml version="1.0" encoding="UTF-8"?>
<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>
null
- CEP will send this event as a WSO2Event with a null
value for the particular attributenull
- It will be sent out as a null
valueXML output mapping
<?xml version="1.0" encoding="UTF-8"?>
<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>
null
- CEP will convert this to an empty value and send outnull
- It will be converted to an empty string and sent outJSON output mapping
<?xml version="1.0" encoding="UTF-8"?>
<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>
null
- CEP will send this as a null
valuenull
- It will be sent out as a null
valueText output mapping
<?xml version="1.0" encoding="UTF-8"?>
<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>
null
- CEP will convert this to an empty value and send outnull
- It will be converted to an empty string and sent outMap output mapping
<?xml version="1.0" encoding="UTF-8"?>
<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>
null
- CEP will send this as a null
valuenull
- It will be sent out as a null
value