WSO2 how to solve scheduled task? - wso2

In wso2 esb 4.5.1, i don't have option of direct task scheduling for sequence or proxy service. so, i try to use property name SoapAction and to in task scheduling but iam getting the below error,
ERROR - TaskManagementHelper Invalid XML has been provided for property : message
ERROR - TaskManagementHelper Invalid XML has been provided for property : format

Here is a sample "Scheduled Task" that inject 2 times an XML message
<root>
<node1>value1</node1>
</root>
It works with ESB 4.5.1
<?xml version="1.0" encoding="UTF-8"?>
<task xmlns="http://ws.apache.org/ns/synapse"
name="TestTask"
class="org.apache.synapse.startup.tasks.MessageInjector"
group="synapse.simple.quartz">
<trigger count="2" interval="5"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks"
name="format"
value="application/xml"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks"
name="to"
value="TestTaskProxy"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks" name="message">
<root xmlns="">
<node1>value1</node1>
</root>
</property>
</task>
format and to properties are literal types
message property is an XML type

Related

Scheduling tasks in wso2 Integration Studio

I am trying to schedule a task wherein I want to call a proxy which does not take any input payload. This is the code I've tried:
<?xml version="1.0" encoding="UTF-8"?>
<task class="org.apache.synapse.startup.tasks.MessageInjector" group="synapse.simple.quartz" name="ScheduleOrderCreation" xmlns="http://ws.apache.org/ns/synapse">
<trigger count="2" interval="5"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks" value="" name="message">
</property>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks" name="proxyName" value="CreateOrders"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks" name="injectTo" value="proxy"/>
</task>
Since I don't want to pass any input payload, I've set value ="" in "message" property. But I get the following error:
ERROR {MessageInjector} - message or registry-key not set
How can I handle this in my task? Should I write a separate class implementing the Tasks interface to call this proxy?
Just add an Empty Payload there.
<?xml version="1.0" encoding="UTF-8"?>
<task class="org.apache.synapse.startup.tasks.MessageInjector" group="synapse.simple.quartz" name="ScheduleOrderCreation" xmlns="http://ws.apache.org/ns/synapse">
<trigger cron="0 0/1 * 1/1 * ? *"/>
<property name="injectTo" value="proxy" xmlns:task="http://www.wso2.org/products/wso2commons/tasks"/>
<property name="proxyName" value="CreateOrders" xmlns:task="http://www.wso2.org/products/wso2commons/tasks"/>
<property name="message" xmlns:task="http://www.wso2.org/products/wso2commons/tasks">
<sfdc xmlns=""/>
</property>
</task>

Can CEP http receiver receive multi data nodes one time

I used ESB to transform the XML message to CEP http receiver, the XML:
<result>
<event>
<tag>0101A01B001</tag>
<time>10:00:01</time>
<value>30.45</value>
</event>
<event>
<tag>0101A01B001</tag>
<time>10:00:02</time>
<value>33.7</value>
</event>
<event>
<tag>0101A01B001</tag>
<time>10:00:03</time>
<value>23.4</value>
</event>
<event>
<tag>0101A01B001</tag>
<time>10:00:04</time>
<value>33.15</value>
</event>
</result>
And the http receiver in CEP :
<?xml version="1.0" encoding="UTF-8"?>
<eventReceiver name="recv_dss1" statistics="disable" trace="enable" xmlns="http://wso2.org/carbon/eventreceiver">
<from eventAdapterType="http">
<property name="transports">all</property>
</from>
<mapping customMapping="enable" type="xml">
<property>
<from xpath="/result/data/tag"/>
<to name="tag" type="string"/>
</property>
<property>
<from xpath="/result/data/time"/>
<to name="time" type="long"/>
</property>
<property>
<from xpath="/result/data/value"/>
<to name="value" type="double"/>
</property>
</mapping>
<to streamName="dss_stream3" version="1.0.0"/>
</eventReceiver>
The http receiver only receive the first "event" node every time, so how to config the receiver can receive all the "event" nodes one time ?
In the configuration you need to configure "Parent Selector XPath Expression" to indicate the parent element of the events, in this case its /result.
Then elements of the event should be referred from the parent tag, e.g. /data/time
Refer to WSO2 CEP 4.1 XML input mapping documentation for details : https://docs.wso2.com/display/CEP410/Input+Mapping+Types#InputMappingTypes-XMLinputmappingXMLInputMapping

Exception connecting WSO2 CEP to WSO2 Message Broker

I am trying to connect a WSO2 CEP server to a WSO2 Message Broker server.
I have created a jndi.properties file:
connectionfactory.TopicConnectionFactory = amqp://admin:admin#clientid/carbon?brokerlist='tcp://192.168.11.2:5673'
topic.testTopic = testTopic
an input event adaptor:
<?xml version="1.0" encoding="UTF-8"?>
<inputEventAdaptor name="MBJMSInputAdaptor" statistics="enable"
trace="enable" type="jms" xmlns="http://wso2.org/carbon/eventadaptormanager">
<property name="java.naming.provider.url">repository/conf/jndi.properties</property>
<property name="transport.jms.SubscriptionDurable">false</property>
<property name="java.naming.factory.initial">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</property>
<property name="transport.jms.ConnectionFactoryJNDIName">TopicConnectionFactory</property>
<property name="transport.jms.DestinationType">topic</property>
</inputEventAdaptor>
a stream definition:
<streamDefinitions xmlns="http://wso2.org/carbon/databridge">
<streamDefinition>
{
"name":"testStream",
"version":"1.0.0",
"payloadData":[
{"name":"id","type":"INT"},
{"name":"name","type":"STRING"}
]
}
</streamDefinition>
</streamDefinitions>
and an event builder:
<?xml version="1.0" encoding="UTF-8"?>
<eventBuilder name="testBuilder" statistics="enable" trace="enable" xmlns="http://wso2.org/carbon/eventbuilder">
<from eventAdaptorName="MBJMSInputAdaptor" eventAdaptorType="jms">
<property name="topic">testTopic</property>
</from>
<mapping customMapping="enable" type="json">
<property>
<from jsonPath="id"/>
<to name="id" type="int"/>
</property>
<property>
<from jsonPath="name"/>
<to name="name" type="string"/>
</property>
</mapping>
<to streamName="testStream" version="1.0.0"/>
</eventBuilder>
Unfortunately, the WSO2 CEP server does not receive messages from the WSO2 Message Broker server, and throws the following exception:
[2014-11-28 13:00:00,226] INFO - {JMSEventAdaptorType} JMS input event adaptor loading listeners
Exception in thread "Thread-29" java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.hash(ConcurrentHashMap.java:333)
at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:988)
at org.wso2.carbon.event.input.adaptor.jms.JMSEventAdaptorType.createJMSAdaptorListener(JMSEventAdaptorType.java:291)
at org.wso2.carbon.event.input.adaptor.jms.JMSEventAdaptorType.tryStartAdaptor(JMSEventAdaptorType.java:262)
at org.wso2.carbon.event.input.adaptor.jms.internal.ds.JMSEventAdaptorServiceHolder.loadLateStartEventAdaptors(JMSEventAdaptorServiceHolder.java:66)
at org.wso2.carbon.event.input.adaptor.jms.internal.ds.JMSEventAdaptorServiceHolder$1.run(JMSEventAdaptorServiceHolder.java:43)
at java.lang.Thread.run(Thread.java:745)
Could you help me debugging this exception?
If you like to debug the code then you can checkout the source from below location [1].. But I think below blog [2] will help you to achieve the usecase.
[1]https://svn.wso2.org/repos/wso2/carbon/platform/branches/turing/components/event-stream/event-input-adaptor/org.wso2.carbon.event.input.adaptor.jms/1.0.1
[2] http://sajithr.blogspot.com/2014/04/sample-on-using-wso2-mb-with-wso2-cep.html

WSO2 ESB How to deliver the message of the Custom Mediator in EndPoint

Good day!
I only recently began to study the ESB bus. I need to convert the incoming SOAP message in the HTTP request with Content-Type: application/x-www-form-urlencoded.
I have created a Proxy Service, Custom Mediator 1 in Java, transformed message, how do I pass it to the endpoint and get the answer in Custom Mediator 2?
In the picture I have drawn an example of how to transform the message.
You don't need to write custom mediators, you can transform SOAP to rest calls, sample with a rest service waiting for 2 parameters like
param1=value1&param2=value2
<!-- prepare data for org.apache.axis2.transport.http.XFormURLEncodedFormatter message formatter -->
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<root>
<param1>$1</param1>
<param2>$2</param2>
</root>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args>
<arg evaluator="xml" expression="$body/node1/node11/text()"/>
<arg evaluator="xml" expression="$body/node1/node12/text()"/>
</args>
</payloadFactory>
<!-- set output format -->
<property name="messageType" value="application/x-www-form-urlencoded" scope="axis2" type="STRING"/>
<property name="DISABLE_CHUNKING" value="true" scope="axis2" type="STRING"/>
<!-- call the REST endpoint with synch call : response is received in this sequence -->
<call>
<endpoint key="conf:endpoints/MyServiceEndpoint.xml"/>
</call>
<!-- the response is here, transform it has needed -->
<xslt key="myxsl"/>
<!-- send this response to the client -->
<property name="messageType" value="application/soap+xml" scope="axis2" type="STRING"/>
<!-- or test/xml and in this case, don't forget to specify a SOAP Action, below, a sample to specify a blank soapAction : -->
<header name="Action" value=""""/>
<send/>
Sample endpoint conf (with this sample, you need to define a property uri.var.ServiceURL in your sequence) :
<endpoint>
<http method="POST" uri-template="{uri.var.ServiceURL}/Path/2011-10-01"/>
</endpoint>
But if you really need your custom mediators, just replace payloadFactory and xslt mediators with them
Thanks for the reply, I still have to write custom mediator, just a very complex transformation messages
I will give an example how should I transform the message
SOAP message in my Proxy Service, send in custrom mediator
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<AddPay xmlns="http://MyTestService">
<!--input dynamic data-->
<fields>
<Items>
<Data>
<Name>Field1</Name>
<Value>11</Value>
</Data>
<Data>
<Name>Field2</Name>
<Value>22</Value>
</Data>
</Items>
</fields>
</AddPay>
</soap:Body>
</soap:Envelope>
The result of the transformation of the mediator
0000035401SM000000970000009700000121
api99 00000990
00000000
BEGIN // <!--input dynamic data-->
FIELD1=11 // Soap data
FIELD2=22 // Soap data
END
BEGIN SIGNATURE
iQBRAwkBAAAD3j2r2NwBAeevAf4nvAG4rGAyAePHkyVKTt7wffzURhOckd3ctgmG
yQkKWkXh3CLpsbrExsllVUBlO6ih8qHozk2uttXApzHXQXoO
=+pch
END SIGNATURE
Request to the HTTP Server
POST /cgi-bin/es/es_pay_check.cgi HTTP/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 498
inputmessage=0000035401SM000000970000009700000121%0D%0Aapi99+
+++++++++++00000990%0D%0A++++++++++++++++++++00000000%0ABEGIN%0D%
0FIELD1%11%0FIELD2%220AEND%0D%0ABEGIN+SIGNATURE%0AiQBRAwkBAABCiUs
00dQBATG5AgDHdZ6RYHykL46QBaAvnHYaY4p0pDjgjO4K1Iyj%0D%0AfSBSvCRpS%2
F0EYO9NspuyLeANEQQkkGE%2F37gUxiPqzAgStXjpsAHH%0D%0A%3DvSgb%0AEND+
SIGNATURE
The response from the HTTP Server, pass in custrom mediator to transform into SOAP
0000030301SM000000460000004600000121
0J0005 00064182
00000000
BEGIN
DATE=04.10.2014 12:34:12
ERROR=0
ERRMSG=
FIELD3=33
FIELD4=44
FIELD5=55
END
BEGIN SIGNATURE
iQBRAwkBAAD6tj1BJ10BAYKxAfsHlQsEFnO2k6ry++W8O8AiJuv4gT+ZVCfZHsKk
c0CbZpP/W3vkljG3xNzMLiqjbwkNuIdwR9Dq7gHmH+ZQMhbT
=LOnP
END SIGNATURE
The result in the Proxy service
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<AddPayResponse xmlns="http://MyTestService">
<AddPayResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Data>
<Items>
<!--output dynamic data-->
<Data>
<Name>Field3</Name>
<Value>33</Value>
</Data>
<Data>
<Name>Field4</Name>
<Value>44</Value>
</Data>
<Data>
<Name>Field5</Name>
<Value>55</Value>
</Data>
</Items>
</Data>
<ErrCode>0</ErrCode>
<ErrMsg>Ok</ErrMsg>
</AddPayResult>
</AddPayResponse>
</s:Body>
</s:Envelope>

How to work with wso2CEP3.0.0 and activemq 5.8.0

i am using wso2cep 3.0.0 and activemq5.8.0
As per CEP documents i wish to Publish events using CEP.
For that i started activemq with 2 define QUEUES with the name jmsProxy for incoming message and JmsProxy for out message.I added required jars in CEP lib activemq-broker-5.8.0.jar,activemq-client-5.8.0.jar,axiom.jar,geronimo-j2ee-management_1.1_spec-1.0.1.jar,geronimo-jms_1.1_spec-1.1.1.jar,hawtbuf-1.2.jar,xpp3-1.1.4c.jar,xstream-1.4.4.jar
my configuration is like this
InputEventAdaptor
<?xml version="1.0" encoding="UTF-8"?>
<inputEventAdaptor name="jmsProxy" statistics="disable" trace="enable"
type="jms" xmlns="http://wso2.org/carbon/eventadaptormanager">
<property name="java.naming.provider.url">tcp://localhost:61616</property>
<property name="transport.jms.SubscriptionDurable">true</property>
<property name="transport.jms.DurableSubscriberName">jmsProxy</property>
<property name="transport.jms.UserName">admin</property>
<property name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</property>
<property name="transport.jms.Password">admin</property>
<property name="transport.jms.ConnectionFactoryJNDIName">QueueConnectionFactory</property>
<property name="transport.jms.DestinationType">queue</property>
</inputEventAdaptor>
above for incoming messages which will pick the messages from jmsProxy queue
But its unable to pick the message from jmsProxy Queue.How would i initiate this to get the message into CEP and
outputEventAdaptor
<?xml version="1.0" encoding="UTF-8"?>
<outputEventAdaptor name="JmsProxy" statistics="disable" trace="disable"
type="jms" xmlns="http://wso2.org/carbon/eventadaptormanager">
<property name="java.naming.security.principal">admin</property>
<property name="java.naming.provider.url">tcp://localhost:61616</property>
<property name="java.naming.security.credentials">admin</property>
<property name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</property>
<property name="transport.jms.ConnectionFactoryJNDIName">QueueConnectionFactory</property>
<property name="transport.jms.DestinationType">queue</property>
</outputEventAdaptor>
event builder configuration like this
<?xml version="1.0" encoding="UTF-8"?>
<eventBuilder name="ReadingsDtoBuilder" statistics="disable"
trace="disable" xmlns="http://wso2.org/carbon/eventbuilder">
<from eventAdaptorName="jmsProxy" eventAdaptorType="jmsProxy">
<property name="transport.jms.Destination">JmsProxy</property>
</from>
<mapping customMapping="disable"
parentXpath="//ReadingsLiteTaildtos" type="xml">
<property>
<from xpath="//ReadingsLiteTaildto/ParameterId"/>
<to name="meta_parameterId" type="string"/>
</property>
<property>
<from xpath="//ReadingsLiteTaildto/Slno"/>
<to name="meta_slno" type="string"/>
</property>
<property>
<from xpath="//ReadingsLiteTaildto/FinalValue"/>
<to name="finalValue" type="int"/>
</property>
<property>
<from xpath="//ReadingsLiteTaildto/InputText"/>
<to name="inputText" type="string"/>
</property>
<property>
<from xpath="//ReadingsLiteTaildto/InputValue"/>
<to name="inputValue" type="double"/>
</property>
</mapping>
<to streamName="org.sample.readings.dto.stream" version="1.0.0"/>
</eventBuilder>
The execution plan can be as follows.like this
<?xml version="1.0" encoding="UTF-8"?>
<executionPlan name="ReadingsAnalyzer" statistics="disable"
trace="disable" xmlns="http://wso2.org/carbon/eventprocessor">
<description>This execution plan analyzes readings and triggers notifications based on threshold.</description>
<siddhiConfiguration>
<property name="siddhi.enable.distributed.processing">false</property>
<property name="siddhi.persistence.snapshot.time.interval.minutes">0</property>
</siddhiConfiguration>
<importedStreams>
<stream as="readings" name="org.sample.readings.dto.stream" version="1.0.0"/>
</importedStreams>
<queryExpressions><![CDATA[from readings[finalValue > 100]
select *
insert into notificationStream;]]></queryExpressions>
<exportedStreams>
<stream name="notificationStream" valueOf="notificationStream" version="1.0.0"/>
</exportedStreams>
</executionPlan>
I defined streams inside stream-manager-config.xml similar to the following.
<streamDefinition name="org.sample.readings.dto.stream" version="1.0.0">
<metaData>
<property name="parameterId" type="STRING"/>
<property name="slno" type="STRING"/>
</metaData>
<payloadData>
<property name="finalValue" type="INT"/>
<property name="inputText" type="STRING"/>
<property name="inputValue" type="DOUBLE"/>
</payloadData>
</streamDefinition>
<streamDefinition name="notificationStream" version="1.0.0">
<metaData>
<property name="parameterId" type="STRING"/>
<property name="slno" type="STRING"/>
</metaData>
<payloadData>
<property name="finalValue" type="INT"/>
<property name="inputText" type="STRING"/>
<property name="inputValue" type="DOUBLE"/>
</payloadData>
</streamDefinition>.
its look like all well while i am sending any message to my jmsProxy queue the message is not reflecting to CEP for event and i am getting this message in CEP
[2014-02-18 11:57:53,159] INFO - {EventBuilderDeployer} Event Builder undeployed successfully : ReadingsDtoBuilder.xml
[2014-02-18 11:57:53,160] INFO - {EventBuilderDeployer} Event builder deployment held back and in inactive state :ReadingsDtoBuilder, Waiting for Input Event Adaptor dependency :jmsProxy
[2014-02-18 12:03:58,006] INFO - {InputEventAdaptorConfigurationFilesystemInvoker} Input Event Adaptor configuration deleted from file system : jmsProxy.xml
[2014-02-18 12:03:58,006] INFO - {InputEventAdaptorDeployer} Input Event Adaptor undeployed successfully : jmsProxy.xml
[2014-02-18 12:03:58,008] INFO - {InputEventAdaptorConfigurationFilesystemInvoker} Input Event Adaptor configuration saved in th filesystem : jmsProxy
[2014-02-18 12:03:58,009] INFO - {InputEventAdaptorDeployer} Input Event Adaptor deployed successfully and in active state : jmsProxy
[2014-02-18 12:03:58,009] INFO - {EventBuilderDeployer} Event Builder undeployed successfully : ReadingsDtoBuilder.xml
[2014-02-18 12:03:58,009] INFO - {EventBuilderDeployer} Event builder deployment held back and in inactive state :ReadingsDtoBuilder, Waiting for Input Event Adaptor dependency :jmsProxy
Looking at your configuration, it seems that the event builder configuration is incorrect. Event adaptor type should be 'jms' in the event builder configuration.
<from eventAdaptorName="jmsProxy" eventAdaptorType="jms">
Please correct this as above to get it working. You can enable tracing [1] to see if messages come to a particular component of CEP.
[1] https://docs.wso2.org/display/CEP300/CEP+Event+Tracer