Wednesday, July 15, 2015

Deploying an Execution Plan in WSO2 CEP using Admin Service

Discovering Available Admin Services


In order to invoke an admin service in CEP, initial step is to discover available admin services. I have tested this using CEP  4.0.0. To view the admin services wsdl, navigate to '<CEP_home>/repository/conf' directory. And then open carbon.xml file. Edit HideAdminServises property to 'false'. 


And then when starting the server, have to start with OSGIConsole.
For example, in Linux

./wso2server.sh –DosgiConsole

After starting the server, to view all the admin services press enter and type 'listAdminServices' and then press enter again. A list of admin services will appear.


To check the wsdl of admin service in the browser add ' ?wsdl ' in the end of URL. In order to deploy an execution plan you have to use EventProcessorAdminService. 

https://192.168.1.101:9443/services/EventProcessorAdminService?wsdl



Test Admin services using SoapUI

After installing SoapUI go to File > New SOAP Project to create a new SOAP project. Give a project name and click 'ok'. 

Then go to Project > Add WSDL. Then paste the wsdl URL (https://192.168.1.101:9443/services/EventProcessorAdminService?wsdl) in the WSDL Location and click 'ok' .  

Then click on the Admin service method you want to call from SoapUI and go to ‘Request 1’. Before sending a request you have to make sure you set Authentication and Security related settings correctly. To do that click on the 'Auth' and click 'Add new Authorization'. And then select 'Basic' as Authorization and set username and password. To call a Admin Service in CEP, set both username and password as 'admin'.


Create the input and output streams in the CEP as required. Then paste the execution plan you want to add in <adm:executionPlan> section of SOAP UI request as in the picture shown below. 


A sample SOAP UI request is as follows.

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:adm="http://admin.processor.event.carbon.wso2.org">
   <soap:Header />
   <soap:Body>
      <adm:deployExecutionPlan>
         <!--Optional:-->
         <adm:executionPlan><![CDATA[@Plan:name('Insert1')


-- @Plan:description('ExecutionPlan')



@Import('input:1.0.0')
define stream input (name string);

@Export('output1:1.0.0')
define stream output1 (name string);

from input
select *
insert into output1]]></adm:executionPlan>
      </adm:deployExecutionPlan>
   </soap:Body>
</soap:Envelope>

Then click the ‘Submit’ button. If it is succeeded you will get a window like this.




Execution plan will be added to CEP.




No comments:

Post a Comment