Text event mapping converts the events coming from Siddhi to text events according to mapping configurations. you can inject the CEP's back-end runtime event data to the output as text, by adding the appropriate back-end runtime event attribute names in double curly braces (e.g., {{price}}) to the output text template.
You can configure through the management console as explained below or by manually adding an XML file as explained in step 5.
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 Text mapping section below.Here when you select the text mapping, you will see a textarea which let you to define the template of the output Text event. Here you can define the template in two manner, they are In-Line and registry based.
By-default text mapping is enabled for In-Line, Users just need to add the template of the output Text event as shown in number "5".
Please note any attribute name need to be mentioned in double curly braces. eg : {{symbol}}
1. Create a plain text content file(resource) with the name "quotationTemplate" in the "governance" directory of registry, (You can create the resource in "config" directory also)
2. Then 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.
3. Then click on Governance Registry link, since we have create the resource in governance directory, select the specific resource as shown below and click on OK button.
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 Text mapping event formatter configurations. Event formatter implementation must start with <eventformatter>
root element as in the example below.
<eventFormatter name="emailEventFormatter" xmlns="http://wso2.org/carbon/eventformatter"> <from streamName="stockStream" version="1.0.0"/> <mapping type="text"> <inline>Hi,You have received a quotation for Brand {{symbol}}at the price at {{price}}Thanks</inline> </mapping> <to eventAdaptorName="emailAdaptor" eventAdaptorType="email"> <property name="email.address">[email protected]</property> <property name="email.subject">Quotation Details</property> </to> </eventFormatter>