Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This will convert XML event formatter converts the events which coming from Siddhi in to XML events according to the mapping configurations. CEP back You can inject the CEP's back-end runtime event data can be injected to the output as XML just , by adding the appropriate back-end runtime event attribute names in double curly braces ( Ee.g., {{price}}) into the output XML template.

Configuring through the Management Console UI

1. Log in to the CEP management console and select the Main menu in the left hand side of the screen. Then select the Add menu item under Event Formatter menu.

Image Removed

2. The Create a New Event Formatter window opens, using which you can configure new event formatters. Enter the following details in the form to create a xml mapping based event formatter as shown in the screenshot below.

Image Removed

Here, there are several properties that need to be filled when creating a event formatter. User interface is divided in to 3 main components (From, Mapping and To) except the event formatter name to give more understanding to the user.

...

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 Formatters and click Add Event Formatter.
  2. Enter details in the form that appears and click the Add Event Formatter button at the end of the form. For example,Image Added
    The fields in the above configuration are as follows:

    • Event Formatter Name : Property to uniquely identify an event formatter configuration
    • Event Stream (marked as 1 in the screenshot) : Select an event stream (stream name with version) to listen for events.
    • Stream Attributes : Based on the event stream selected earlier,

...

    • this shows what

...

    • the attributes available in the stream are. This field is only for reference

...

    • .
    • Output

...

    • Event Adapter Name (marked as 2 in the screenshot) : Select the event adapter used to publish events from the CEP. This drop-down list shows the output event adapters already created.
    • Output Mapping Type (marked as 3 the screenshot) : Select xml mapping type. This drop-down list is populated based on the event adapter selected earlier. It lists only the mapping types supported by a particular event adapter. Some event adapters support multiple types of mappings. Also, see XML Mapping section below.
    • Topic : Since you selected ws-event-local type

...

    • event adapter, you need a Topic

...

    • to be used when subscribing the events by the receiver.

...



    • XML Mapping

...

    • When you select the 

...

    • xml mapping, you

...

    • see a

...

    • text area to define an in-line or a registry-based template of the output XML event

...

    • .

      In-

...

    • line : XML mapping is enabled for

...

    • in-line templates by default. You must add the template of the output XML event

...

    • as shown in

...

    • the example above. Note that any attribute name

...

    • must be

...

    • in double curly braces

...

    • . E.g., {{symbol}}.

      Registry

...

    • -based : Follow the steps below to create a registry-based template.

      Step 1: Create a plain text content file (resource)

...

    • in either the

...

    • config

...

    • or the governance directory of the registry

...

    • . For more information, see For example,

      Image Modified

      Step 2

...

    • : Select the resource that you created in registry. First, click on the Pick from registry

...

    • option, then you can see options (Configuration Registry and Governance Registry) to select the registry

...

    • resource.

      Image Modified

      3. Then click on Configuration Registry link, since we have create the resource in config directory, select the specific resource as shown below and click on OK button. 

      Image Modified

3. After adding details click the Add Event Formatter button. The Available Event Formatter page will open. To view event formatter configurations, click on the event formatter name. To delete event formatter, click the Delete button.

Image Removed

 

Editing Event Formatter Configuration through the Management Console

...

  1. After an event formatter is successfully created, you can change its configuration and redeploy it.

...

  1. To do this, click the Edit

...

  1. link associated with it.
  2. An XML based editor opens allowing you to edit the event

...

  1. builder configuration from the UI itself, without

...

  1. having to edit the

...

  1. file in the file system. Do your modifications and click Update.

Image Removed

Configuring through a xml File

...

  1. Alternatively,

    Anchor
    step5
    step5
    you can specify an event formatter configuration using an XML file and save it in <PRODUCT_HOME>/repository/deployment/server/eventformatters

...

  1. directory, which is the event formatter 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 XML mapping event formatter configurations. Event formatter implementation must start with <eventformatter> root element as in the example below.

    Code Block
    languagehtml/xml
    <eventFormatter name="xmlEventFormatter" xmlns="http://wso2.org/carbon/eventformatter">
      <from streamName="stockStream" version="1.0.0"/>
      <mapping type="xml">
        <inline>
          <quotedata:StockQuoteDataEvent
            xmlns:quotedata="http://ws.cdyne.com/"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <quotedata:StockSymbol>{{symbol}}</quotedata:StockSymbol>
            <quotedata:LastTradeAmount>{{price}}</quotedata:LastTradeAmount>
          </quotedata:StockQuoteDataEvent>
        </inline>
      </mapping>
      <to 

...

  1. eventAdaptorName="localWsEventSender" 

...

  1. eventAdaptorType="ws-event-local">
        <property name="topic">FastMovingStockQuotes</property>
      </to>
    </eventFormatter>

...