<cepConfig xmlns="http://wso2.org/carbon/event/cep">
    <!-- details of the Back end runtime provider can be esper or fusion -->
    <cepEngineProvider class="org.wso2.carbon.event.cep.esper.EsperBackendRuntimeFactory">
        <config>
            <esper-configuration
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xmlns="http://www.espertech.com/schema/esper"
                    xsi:noNamespaceSchemaLocation="esper-configuration-3-0.xsd">
                <plugin-event-representation
                        uri="types://xml/apacheaxiom/OMNode"
                        class-name="com.espertech.esperio.representation.axiom.AxiomEventRepresentation"/>
                <plugin-event-type name="ServiceStatisticsDataEvent">
                    <resolution-uri
                            value="types://xml/apacheaxiom/OMNode/ServiceStatisticsDataEvent"/>
                    <initializer>
                        <xml-axiom root-element-name="ServiceStatisticsDataEvent"
                                   default-namespace="http://wso2.org/ns/2009/09/bam/service/statistics/data">
                            <namespace-prefix prefix="statdata"
                                              namespace="http://wso2.org/ns/2009/09/bam/service/statistics/data"/>
                            <xpath-property property-name="requestCount"
                                            xpath="/statdata:ServiceStatisticsDataEvent/statdata:ServiceStatisticsData/statdata:RequestCount"
                                            type="number"/>
                        </xml-axiom>
                    </initializer>
                </plugin-event-type>
            </esper-configuration>
        </config>
    </cepEngineProvider>

    <!-- set of buckets to process the cep events -->
    <buckets>
        <bucket name="addStatistics">
            <description>BAMServiceStatisticsDataCEPServiceBucket</description>
            <queries>
                <query>
                    <source type="inline" listenerName="getQuote">select * from ServiceStatisticsDataEvent.win:length(5) having avg(requestCount) > 5</source>
                    <eventDescription type="omelement"
                           rootElement="Event"
                           namespace="http://wso2.org/ns/2009/09/bam/service/statistics/data"/>
                    <outputStream topic="statisticsPublishTopic" type="ws"/>
                </query>
            </queries>
            <inputStreams>
                <inputStream name="bamevent" topic="carbon/bam/data/publishers/service_stats"
                             type="ws">
                </inputStream>
            </inputStreams>

            <!-- types of the event messages receive from above input streams -->
            <eventDescriptions>
                <eventDescription type="omelement"
                       rootElement="Event"
                       namespace="http://wso2.org/ns/2009/09/bam/service/statistics/data"/>
            </eventDescriptions>
        </bucket>
    </buckets>
</cepConfig>
