This documentation is for WSO2 CEP 3.1.0. View the home page of the latest release.

||
Skip to end of metadata
Go to start of metadata

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 adapter 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:

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
Sample event builder configuration
<?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>
  • No labels