Text Event Builder converts the events/streams from an input adaptor that supports Text input streams into an event stream that is compatible with the event processor. The event attributes are extracted using regular expressions and 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.
- Start the CEP, log in to its management console, select Event Streams and click In-Flows of the relevant stream..
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 Adaptor : The input event adaptor used to publish events to the CEP. This drop-down list only displays the adaptors that are already created. In this example, we select a Input Email Event Adaptor already created.
- Topic - The topic to which event publishers send events
- Input Mapping Type : Select
text
as the mapping type. This property changes based on the event adaptor selected. It lists only the mapping types supported by a particular event adaptor. - Advanced : Map the incoming stream to the outgoing stream received by the event processor. Provide the necessary details in the input fields:
- Enter the regular expression under Regular Expression Definitions
- Click Add to add the definition. It must now be available under the Regular Expression drop-down in the Add section
- Enter the Input Attribute Name, Regular Expression 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 select an event adaptor that supports Text mapping type.
- When specifying the subject for the input email, the Email Service Name here must be given in the email subject, in the format shown in the hint. For example, if the Email Service Name is
RegisterParticipant
, the subject of the email sent as the input must beSOAPAction: urn:RegisterParticipant
- The input email must be in plain text. Do not use any rich text formatting.
- 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.
- 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.
Alternatively, y ou 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 Text based event builder configurations. Event builder implementation must start with<eventbuilder>
root element and the namespace set tohttp://wso2.org/carbon/eventbuilder
as in the example below:<?xml version="1.0" encoding="UTF-8"?> <eventBuilder name="searchStatsTextBuilder" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventbuilder"> <from eventAdaptorName="httpInputAdaptor" eventAdaptorType="http"> <property name="topic">searchstats</property> </from> <mapping customMapping="enable" type="text"> <property> <from regex="(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"/> <to name="ip" type="int"/> </property> <property> <from regex="user[1234]"/> <to name="username" type="int"/> </property> <property> <from regex="[a-z]+"/> <to name="searchKey" type="int"/> </property> </mapping> <to streamName="searchStats" version="1.0.0"/> </eventBuilder>