Thursday, February 28, 2013

Sample to demonstrate WSO2 CEP (Complex Event Processor) Registry Based Output topics and Text Mapping


In my previous blog post, I have given an introduction to WSO2 CEP. If you still do not have an idea, you can refer,
For More information, read on : http://wso2.com/products/complex-event-processor )

Processing and triggering new events based on received events is the basic idea of CEP. For processing events there should be some criteria specified to the CEP Engine, and this is provided as query to the CEP Bucket. To perform the expected task user may need one or more queries and some of this queries may be configured to trigger output events.
Query consists of the following elements.
  • Query Name - Name to identify the query
  • Expression - Actual query text specifying how the events should be processed
  • Output (optional) -Output should only be defined if you want to emit the output events triggered by the query,

Output consists following elements

  • Topic - Topic to which CEP will publish the output events.
  • Broker Name - Name of the broker which the output events are sent through
  • Output Mapping - Define the format of the output events.
Following are the available Output Mappings.
Reference : http://docs.wso2.org/wiki/pages/viewpage.action?pageId=21692679



Sample I am going to demonstrates is a way to realize Output Topics and text mapping using the registry. This sample can be helpful to the WSO2 Quality Assurance team to test the Registry Based Output and text mapping as well. I will not be doing something new in here. But to reuse the existing sa.mples provided in the documentation and organize them as you can execute them and view this feature in WSO2 CEP


To read more : http://docs.wso2.org/wiki/display/CEP210/Output+Topics


To demonstrates I will be using an existing sample from the documentation, which is Build Analyzer. http://docs.wso2.org/wiki/display/CEP210/Build+Analyzer



The best thing to do first is, run the sample given as it is to understand the behavior.


Steps to change for Registry Based Mapping
     1. Follow the steps given in the prerequisites. If you have already run the sample as it is you will not have to do those steps back again. Then you can move to the next step, Configuring Topics for E-Mail Broker.

  1.  When it comes to registry based mapping, the only step that will be differentiate from the existing sample will be the step which you have to configure Topics for E-Mail Broker.
    Follow the steps given in the following : http://docs.wso2.org/wiki/display/CEP210/Output+Topics

  2. Create a plain text content in the registry with the name "emailTopic" in the "config" directory of registry. (Go to the Registry → Browse → _system/config)



  3. Click on Add Resource which is under Entries and select Create Text Content from the Method drop down and provide the mapping details with your email address to see the incoming mail.



  4. Before Providing the file path for the output topic field to the bucket, since the bucket for the given example is already in our CEP-sample scenarios, we can first deploy and then edit the output mapping of it.

  5. Therefore deploy the configurations.
    In a command prompt, switch to the sample directory: <CEP_HOME>/samples/cep-samples
    For example, in Linux: cd <CEP_HOME>/samples/cep-samples

  6. From there, type ant deploy-build.

  7. Then when you list down the buckets, you will be able to see the, BuildFailAnalysisBucket .

  8. If you view it, you will be able to see the output is just mapped inline. Therefore we should map it as it supports our registry mapping. Therefore click on the Edit link to edit the bucket's output mapping.

  9. Then click on the BuildFailFilterQuery to edit the Output mapping.

  10. There you get the Query page. Edit the Output section as follows by providing config-registry:/emailTopic as the topic.


  11. Now we are almost done which is related to this sample. Now start the WSO2 Complex Event Processor. Refer to the Running the Product for instructions.

  12. Then follow the steps provided in the following location (Build Analyzer Sample) from the Defining Stream in CEP engine section onwards.
    http://docs.wso2.org/wiki/display/CEP210/Build+Analyzer

  13. If you have successfully followed the steps, you will be able to view the same observation which you have received in inline mapping.

  14. This sample can be used to demonstrates Registry-Based Output Text mapping as well. Only step you have to follow is define the text content of the email using the registry. Except above 4th and 11th steps you have to follow the steps given in the following location.
    http://docs.wso2.org/wiki/display/CEP210/Text+Output+Mapping

No comments:

Post a Comment