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

Map event formatter converts the events coming from Siddhi to Map events according to the output mapping configurations. Here, each output event is considered as a map object. 

Y ou 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,



    The fields in the above configuration are as follows:

    • Event Formatter Name : Property to uniquely identify an event formatter configuration
    • Stream Attributes : Based on the event stream selected , this shows what the attributes available in the stream are. This field is only for reference.
    • Output Event Adapter Name  : 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 : Select map 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.
    • Header : Optional property, here user can add necessary jms header properties with comma ( , ) separated
    • Destination : Since you selected jms type event adapter, you need a Destination that tells when output events needs to send.

      Map Mapping - Advanced Option

      Map event is simply a map object, a <key,value> pair. Name is used as a key in the event and the actual value is used as value attribute.


      • Name : The attribute name to which the event data is mapped when creating the output Map Event
      • Value Of : The attribute/property name from which the data element is mapped
      • Stream Name/Version : Since you selected a JMS type event adapter here, you need a destination to send events to, from the CEP.

      Here, If you not willing to add advanced mapping properties then CEP will send map events with all the attributes which defined in the stream definition. Here, output map event will be in a predefined event format as shown below.

      StreamDefinition{
              streamId='loanRequestStream:1.0.0',
              name='loanRequestStream',
              version='1.0.0',
              nickName='loanRequest',
              description='Stream which contains events related to loan request',
              tags=null,
              metaData=[Attribute{name='tenant_id', type=INT}],
              correlationData=[Attribute{name='activity_id', type=STRING}],
              payloadData=[Attribute{name='clientPhoneNo', type=STRING}, Attribute{name='clientName', type=STRING}, Attribute{name='clientResidenceAddress', type=STRING}, Attribute{name='clientAccountNo', type=STRING}],
      }

      Here when sending map event, meta attributes need to prefixd with meta_ , correlation attribute needs to prefixed with correlation_ and payload attribute does not need any prefixes. For example,

      key : meta_tenant_id , value : 25

  3. After an event formatter is successfully created, you can change its configuration and redeploy it. To do this, click the Edit link associated with it.
  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 formatter configuration using an XML file and save it in <PRODUCT_HOME>/repository/deployment/server/eventformatters 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 Map mapping event formatter configurations. Event formatter implementation must start with <eventformatter> root element as in the example below.

    <eventFormatter name="StatisticsFormatter" xmlns="http://wso2.org/carbon/eventformatter">
      <from streamName="statisticsStream" version="1.0.0"/>
      <mapping type="map">
        <property>
          <from name="ipAddress"/>
          <to name="ipAddress"/>
        </property>
        <property>
          <from name="user"/>
          <to name="username"/>
        </property>
      </mapping>
      <to eventAdaptorName="jmsOutputEventAdaptor" eventAdaptorType="jms">
        <property name="transport.jms.Destination">statisticInfo</property>
        <property name="transport.jms.Header">JMSPriority:4,JMSExpiration:5000</property>
      </to>
    </eventFormatter> 
  • No labels