WSO2Event Event Builder converts events/streams from an input adaptoradapter that supports WSO2-Events into an event stream that is compatible with the event processor. WSO2-Event has three data types (meta, correlation and payload), which can be mapped to the CEP backend runtime event attributes by specifying the mapping in the event builder.
...
- Start the CEP, log in to its management console, select Event Builders and click Add Event Builder.
- Enter details in the form that appears and click the Add Event Builder button at the end of the form. For example,
The fields in the above configuration are as follows:- Event Builder Name : Property to uniquely identify an event formatter configuration
- Input Event Adaptor Adapter (marked as 1 in the screenshot) : The input event adaptoradapter used to publish events to the CEP. This drop-down list only displays the adaptors adapters that are already created. In this example, we select an Input WSO2Event Event AdaptorAdapter already created.
- Input Event Adaptor Adapter properties (marked as 2 in the screenshot) : Properties required by the input event adaptor adapter depending on the input event adaptor adapter type selected before. For example, if you select WSO2Event, then the required properties are:
- Stream Definition - Stream name of the incoming WSO2Event stream
- Stream Version - Version of the incoming stream
- Input Mapping Type (marked as 3 in the screenshot): Select
WSO2Event
mapping type. This property changes based on the event adaptor adapter selected. It lists only the mapping types supported by a particular event adaptoradapter. - Mapping properties (marked as 4 in the screenshot) : Map the incoming stream to the outgoing stream received by the event processor. In this case, mappings are further divided as meta data, correlation data and payload data. Provide the necessary details in the input fields:
- Enter the attribute name of the incoming stream in Input Attribute Name
- Enter the attribute name for the outgoing stream in Mapped To
- Select the data type of the attribute from the To Stream Data Type drop-down
Click Add to add the individual attribute mapping to the event builder
Info For the correct properties to show, you must selected an input event adaptor adapter that supports WSO2Event mapping type.
- To Stream Name/Version : Stream name/version of the outgoing stream
Info When custom mapping is disabled,
- The To Stream name and version should match the From Stream name and version
- The stream definitions are visible to execution plans or event formatters unless the stream definition is already available in the registry
After a builder is successfully created, you can change its configuration and redeploy it. To do this, click the Edit link associated with it. You can also click the other links associated with it to delete or enable statistics and tracing.
- 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 builder configuration using an XML file and save it inAnchor step5 step5 <PRODUCT_HOME>/repository/deployment/server/eventbuilders
directory, which is the event builder 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 based event builder configurations. Event builder implementation must start with<eventbuilder>
root element and the namespace set tohttp://wso2.org/carbon/eventbuilder
as in the example below.Code Block language html/xml <eventBuilder name="SearchStatBuilder" xmlns="http://wso2.org/carbon/eventbuilder"> <from eventAdaptorName="localEventReceiver" eventAdaptorType="wso2event"> <property name="stream">access_Analytics</property> <property name="version">1.0.0</property> </from> <mapping type="wso2event"> <property> <from dataType="meta" name="ipAdd"/> <to name="ipAddress" type="string"/> </property> <property> <from dataType="payload" name="username"/> <to name="username" type="string"/> </property> <property> <from dataType="payload" name="keywords"/> <to name="searchTerms" type="string"/> </property> </mapping> <to streamName="searchStatistics" version="1.0.0"/> </eventBuilder>
Warning When custom mapping is disabled, the event builder is considered as a pass-through event builder, which sends all events without pre-configured mappings. But, this feature is only implemented for wso2Event builder. Also, you cannot configure an execution plan for a pass-through event builder using the UI. You must create it in the back-end. This is because the CEP doesn't know about the stream definition until the first event comes to it. After the first event, you can configure the execution plan and event formatter in the back-end and deploy it.