WSO2Event Event Formatter
WSO2Event event formatter converts events coming from Siddhi in to wso2Event, according to the mapping configurations. Therefore, WSO2Event has three data types such as meta, correlation and payload. You can map the CEP back-end runtime event attributes to any one of the three data types by adding the mapping configuration under their type names.
You can configure through the management console as explained below or by manually adding an XML file as explained in step 5.
- Start the CEP, log in to its management console, select Event Formatters and click Add Event Formatter.
- Enter details in the form that appears and click the Add Event Formatter button at the end of the form. For example,
The fields in the above configuration are as follows:- Event Formatter Name : Property to uniquely identify an event formatter configuration
- Stream Attributes : Based on the event stream selected earlier, this shows what the attributes available in the stream are. This field is only for reference.
- Output Event Adapter Name (marked as 2 in the screenshot) : Select the event adapter used to publish events from the CEP. This drop-down list shows the output event adapters already created.
- Stream Name/Version : Since, you have selected a WSO2Event type event adapter here, you need a stream to send events from CEP. Enter the stream name/version here.
- Output Mapping Type (marked as 3 the screenshot) : Select
WSO2Event
mapping type. This drop-down list is populated based on the event adapter selected earlier. It lists only the mapping types supported by a particular event adapter. Some event adapters support multiple types of mappings.WSO2Event Mapping
WSO2Event mapping, which is available under the Advanced section, contains three types of data properties as meta data, correlation data and payload data. Each data property needs to have the following:
- Name : The attribute name to which the event data is mapped when creating the output WSO2Event
Value Of : The attribute/property name from which the data element is mapped
Here, If you are not willing to add advanced mapping properties, then CEP will create an event with all the attributes based on the stream definition. If user need to filter some attributes and change the naming for some attributes then they need to do output mapping manually.
- After an event formatter is successfully created, you can change its configuration and redeploy it. To do this, click the Edit link associated with it.
- An XML based editor opens allowing you to edit the event builder configuration from the UI itself, without having to edit the file in the file system. Do your modifications and click Update.
Alternatively, you can specify an event formatter configuration using an XML file and save it in
<PRODUCT_HOME>/repository/deployment/server/eventformatters
directory, which is the event formatter deployment directory. Since hot deployment is enabled, you can simply add/remove files to deploy/undeploy from the server.
Create the XML file with the following WSO2Event mapping event formatter configurations. Event formatter implementation must start with<eventformatter>
root element as in the example below.<?xml version="1.0" encoding="UTF-8"?> <eventFormatter name="searchStreamWSO2EventFormatter" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventformatter"> <from streamName="searchStats" version="1.0.0"/> <mapping customMapping="disable" type="wso2event"/> <to eventAdaptorName="DefaultWSO2EventOutputAdaptor" eventAdaptorType="wso2event"> <property name="stream">searchAnalyticsWSO2Event</property> <property name="version">1.0.0</property> </to> </eventFormatter>