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
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.
<?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>
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
- CEP will send this event as a WSO2Event with anull
value for the particular attribute
- String Attributes
null
- It will be sent out as anull
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. A sample mapping configuration is shown below.
The configuration XML file of the above sample mapping is as follows.
<?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>
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
- CEP will convert this to an empty value and send out- Empty attribute - CEP 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. A sample mapping configuration is shown below.
The configuration XML file of the above sample mapping is as follows.
<?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>
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
- CEP will send this as anull
value- Empty attribute - CEP will send this as it is as an empty value
- String Attributes
null
- It will be sent out as anull
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. A sample mapping configuration is shown below.
The configuration XML file of the above sample mapping is as follows.
<?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>
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
- CEP will convert this to an empty value and send out- Empty attribute - CEP 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.
The configuration XML file of the above sample mapping is as follows.
<?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>
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
- CEP will send this as anull
value- Empty attribute - CEP will send this as it is as an empty value
- String Attributes
null
- It will be sent out as anull
value- Empty Attribute - It will be published as an empty string attribute