An event builder converts different input event formats such as WSO2Event, XML, Map (Key-value pairs), JSON into a uniform format that is supported by the CEP or any other event consumer. It handles input mappings for the CEP.
To create an event builder via the management console UI, you must have an event stream definition and an input event adaptor added before hand.
For an event builder to be active, the stream to which that builder is publishing must be defined. Also, for WSO2 events, the incoming stream definition also must be defined. If an event builder is in inactive state then there will be a short message specifying the reason why the event builder is inactive ( in inactive event builders section in management console) . Usually a similar message will be printed to console as well.
This section covers different types of event builders that CEP supports and how to configure them:
Default Event Builders
A default event builder is created every time you create a stream definition (or if a stream definition is created by a client sending events). This event builder will be a WSO2Event Event Builder with custom mapping disabled. The name will be automatically generated according to the name of the stream as <stream_name>_<version>. e.g. if the stream is named org.wso2.mediation.stats, with the version 1.0.0, the event builder name will be org.wso2.mediation.stats_1.0.0
Exported Stream Definition
Event builder exports a looks for a stream definition based on the mapping specified (when custom mapping is enabled). When specifying the attribute to which a particular incoming event is matched, the following convention is used to distinguish between meta, correlation and payload attributes.
The name attribute in the <to> tag in a mapping will be used to identify the attribute type.
- meta_<attrib_name> - Denotes a meta attribute
- correlation_<attrib_name> - Denotes a correlation attribute
- <attrib_name> - Denotes a payload attribute
<?xml version="1.0" encoding="UTF-8"?> <eventBuilder name="ATMStatsEventBuilder" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventbuilder"> <from eventAdaptorName="wsEventReceiver" eventAdaptorType="ws-event"> <property name="topic">ATMTransactionStats</property> </from> <mapping customMapping="disable" type="xml"> <xpathDefinition namespace="http://samples.wso2.org/" prefix="atmdata"/> <property> <from xpath="//atmdata:ATMTransactionStat/atmdata:TransactionTime"/> <to name="meta_transactionTime" type="string"/> </property> <property> <from xpath="//atmdata:ATMTransactionStat/atmdata:Location"/> <to name="meta_location" type="string"/> </property> <property> <from xpath="//atmdata:ATMTransactionStat/atmdata:CardNo"/> <to name="cardNo" type="string"/> </property> <property> <from xpath="//atmdata:ATMTransactionStat/atmdata:CardHolderName"/> <to name="cardHolderName" type="string"/> </property> <property> <from xpath="//atmdata:ATMTransactionStat/atmdata:AmountWithdrawed"/> <to name="amountWithdrawed" type="double"/> </property> </mapping> <to streamName="atmStatsStream" version="1.0.0"/> </eventBuilder>