Search code examples
wso2wso2-das

Howto create WSO2 DAS event receiver using management API


Once you set HideAdminServiceWSDLs to false on carbon configuration file is posible to discover the EventReceiverAdminService service endpoint. It expose the deployEventReceiverConfiguration method. Could anyone provide an example on howto use this service in a multi-tenant context? I try calling the service but every time I get the following response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <soapenv:Fault>
         <faultcode>soapenv:Server</faultcode>
         <faultstring>unknown</faultstring>
         <detail/>
      </soapenv:Fault>
   </soapenv:Body>
</soapenv:Envelope> 

and no usefull message on the DAS logs.


Solution

  • You need to provide the XML configuration of the event receiver. I tried the following with SOAP UI and it works.

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:adm="http://admin.receiver.event.carbon.wso2.org">
       <soapenv:Header/>
       <soapenv:Body>
          <adm:deployEventReceiverConfiguration>
             <!--Optional:-->
             <adm:eventReceiverConfigXml><![CDATA[<eventReceiver xmlns="http://wso2.org/carbon/eventreceiver" name="httpReceiver" statistics="disable" trace="disable">
       <from eventAdapterType="http">
          <property name="transports">all</property>
       </from>
       <mapping customMapping="disable" type="json" />
       <to streamName="org.wso2.event.sensor.stream" version="1.0.0" />
    </eventReceiver>]]>
    

    In a multi tenant environment, use the respective tenant admin's credentials for basic authentication. Then it will deploy the event receiver in the correct tenant. When deploying DAS will print a log as follows,

    [2016-02-11 17:40:39,670] [email protected] [1] [DAS] INFO {org.wso2.carbon.core.services.util.CarbonAuthenticationUtil} -  '[email protected] [1]' logged in at [2016-02-11 17:40:39,670-0700]
    [2016-02-11 17:40:39,674] [email protected] [1] [DAS] INFO {org.wso2.carbon.event.receiver.core.internal.util.helper.EventReceiverConfigurationFileSystemInvoker} -  Event receiver configuration saved to the filesystem :httpReceiver.xml
    [2016-02-11 17:40:39,675] [email protected] [1] [DAS] INFO {org.wso2.carbon.event.input.adapter.core.internal.InputAdapterRuntime} -  Connecting receiver httpReceiver
    [2016-02-11 17:40:39,676] [email protected] [1] [DAS] INFO {org.wso2.carbon.event.stream.core.internal.EventJunction} -  Producer added to the junction. Stream:BAM_MESSAGE_TRACE:1.0.0
    [2016-02-11 17:40:39,676] [email protected] [1] [DAS] INFO {org.wso2.carbon.event.receiver.core.EventReceiverDeployer} -  Event Receiver configuration successfully deployed and in active state: httpReceiver