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

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

JSON Event Builder converts the events/streams from an input adapter that supports JSON input streams into an event stream that is compatible with the event processor. The event attributes are extracted using JSONPath expressions and are converted to the type specified in the mapping, before sent to the event processor.

You can configure through the management console as explained below or by manually adding an XML file as explained in step 5.

  1. Start the CEP, log in to its management console, select Event Builders and click Add Event Builder.
  2. 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 Adapter (marked as 1 in the screenshot) : The input event adapter used to publish events to the CEP. This drop-down list only displays the adapters that are already created. In this example, we select an Input JMS Event Adapter already created.
    • Input Event Adapter properties (marked as 2 in the screenshot) : Properties required by the input event adapter depending on the input event adapter type selected before. For example, if you select  an event adapter that supports JSON, then the required properties are:
      • Destination - The topic to which event publishers send events
    • Input Mapping Type (marked as 3 in the screenshot): Select json as the mapping type. This property changes based on the event adapter selected. It lists only the mapping types supported by a particular event adapter.
    • Mapping properties (marked as 4 in the screenshot) : Map the incoming stream to the outgoing stream received by the event processor. Provide the necessary details in the input fields:
      • Enter the  Input Attribute Name , JSONPath  and  To Stream Data Type  under Properties
      • Click Add to add the individual attribute mapping to the event builder

        For the correct properties to show, you must selected an event adapter that supports JSON mapping type.

    • To Stream Name/Version : Stream name/version of the outgoing stream
  3. 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.
  4. 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.
  5. Alternatively, you can specify an event builder configuration using an XML file and save it in <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 JSON based event builder configurations. Event builder implementation must start with <eventbuilder> root element and the namespace set to http://wso2.org/carbon/eventbuilder as in the example below:

    <eventBuilder name="jsonbuilder" xmlns="http://wso2.org/carbon/eventbuilder">
        <from eventAdaptorType="jms" eventAdaptorName="jmsActiveMqAdaptor">
            <property name="transport.jms.Destination">AllStockQuotes</property>
        </from>
        <mapping type="json" >
            <property>
                <from jsonPath="$.StockQuoteEvent.LastTradeAmount"/>
                <to name="price" type="double"/>
            </property>
            <property>
                <from jsonPath="$.StockQuoteEvent.StockSymbol"/>
                <to name="symbol" type="string"/>
            </property>
        </mapping>
        <to streamName="stockQuotes" version="1.2.0"/>
    </eventBuilder>
  • No labels