In WSO2 ESB, how to pass parameter to sequence from scheduler task - wso2

I configured a scheduler task to invoke a sequence; and I need to pass a parameter to this sequence per requirement. How to accomplish this in WSO2 ESB? I had attempting to pass in the value through the message property in the scheduler task and read the value off the message in the sequence. But failed to obtain the value in the sequence. My codes and output shown below. Please let me know what I should do to make it work. Thank you for your time in advance.
<task class="org.apache.synapse.startup.tasks.MessageInjector" group="synapse.simple.quartz" name="UploadFile2Vendor1" xmlns="http://ws.apache.org/ns/synapse">
<trigger interval="15"/>
<property name="message" xmlns:task="http://www.wso2.org/products/wso2commons/tasks">
<request>
<vendorId>1</vendorId>
</request>
</property>
<property name="sequenceName" value="SendFile2VendorSeq" xmlns:task="http://www.wso2.org/products/wso2commons/tasks"/>
<property name="injectTo" value="sequence" xmlns:task="http://www.wso2.org/products/wso2commons/tasks"/>
</task>
<sequence name="SendFile2VendorSeq" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<log>
<property xmlns:m0="http://services.samples"
expression="$body/m0:request/m0:vendorId" name="vendorId"/>
</log>
<dblookup description="get vendor">
<connection>
<pool>
<dsName>jdbc/DBDS</dsName>
</pool>
</connection>
<statement>
<sql>SELECT code, name FROM vendor WHERE id = ?</sql>
<parameter expression="get-property('vendorId')" type="INTEGER"/>
<result column="code" name="code"/>
<result column="name" name="name"/>
</statement>
</dblookup>
</sequence>
Output in log file
[2016-07-27 09:25:36,446] DEBUG - StartUpController Synapse server name : localhost
[2016-07-27 09:25:36,446] DEBUG - StartUpController loaded task property : <property xmlns="http://ws.apache.org/ns/synapse" xmlns:task="http://www.wso2.org/products/wso2commons/tasks" name="injectTo" value="sequence"/>
[2016-07-27 09:25:36,446] DEBUG - StartUpController loaded task property : <property xmlns="http://ws.apache.org/ns/synapse" xmlns:task="http://www.wso2.org/products/wso2commons/tasks" name="sequenceName" value="SendFile2VendorSeq"/>
[2016-07-27 09:25:36,446] DEBUG - StartUpController loaded task property : <property xmlns="http://ws.apache.org/ns/synapse" xmlns:task="http://www.wso2.org/products/wso2commons/tasks" name="message">
<request>
<vendorId>1</vendorId>
</request>
</property>
[2016-07-27 09:25:36,446] DEBUG - PropertyHelper Setting property :: invoking method setMessage(<request xmlns="http://ws.apache.org/ns/synapse">
<vendorId>1</vendorId>
</request>)
[2016-07-27 09:25:36,446] DEBUG - MessageInjector set message <request xmlns="http://ws.apache.org/ns/synapse">
<vendorId>1</vendorId>
</request>
[2016-07-27 09:25:36,446] DEBUG - TaskScheduler TaskScheduler already initialized.
[2016-07-27 09:25:36,532] INFO - AbstractQuartzTaskManager Task scheduled: [-1234][ESB_TASK][Upload2Vendor]
[2016-07-27 09:25:36,532] INFO - NTaskTaskManager Scheduled task [NTask::-1234::Upload2Vendor]
[2016-07-27 09:25:36,532] DEBUG - StartUpController Submitted task [Upload2Vendor] to Synapse task scheduler.
[2016-07-27 09:25:36,532] DEBUG - TaskDeployer Initialized the StartupTask : Upload2Vendor
[2016-07-27 09:25:36,532] DEBUG - TaskDeployer StartupTask Deployment from file : C:\MyApps\wso2esb-4.9.0\tmp\carbonapps\-1234\1469629535899ESBCDRCApp_1.0.0.car\UploadCDR2CDG_1.0.0\Upload2Vendor-1.0.0.xml : Completed
[2016-07-27 09:25:36,532] INFO - TaskDeployer StartupTask named 'Upload2Vendor' has been deployed from file : C:\MyApps\wso2esb-4.9.0\tmp\carbonapps\-1234\1469629535899ESBCDRCApp_1.0.0.car\UploadCDR2CDG_1.0.0\Upload2Vendor-1.0.0.xml
[2016-07-27 09:25:36,532] DEBUG - SynapseArtifactDeploymentStore Added deployment artifact with file : C:\MyApps\wso2esb-4.9.0\tmp\carbonapps\-1234\1469629535899ESBCDRCApp_1.0.0.car\UploadCDR2CDG_1.0.0\Upload2Vendor-1.0.0.xml
[2016-07-27 09:25:36,532] DEBUG - AbstractSynapseArtifactDeployer Deployment of the synapse artifact from file : C:\MyApps\wso2esb-4.9.0\tmp\carbonapps\-1234\1469629535899ESBCDRCApp_1.0.0.car\UploadCDR2CDG_1.0.0\Upload2Vendor-1.0.0.xml : COMPLETED
[2016-07-27 09:25:36,532] INFO - ApplicationManager Successfully Deployed Carbon Application : ESBCDRCApp_1.0.0 {super-tenant}
[2016-07-27 09:25:36,532] DEBUG - MessageInjector execute
[2016-07-27 09:25:36,532] DEBUG - Axis2SynapseEnvironment Creating Message Context
[2016-07-27 09:25:36,542] DEBUG - MessageInjector injecting message to sequence : SendFile2VendorSeq
[2016-07-27 09:25:36,542] DEBUG - Axis2SynapseEnvironment Injecting MessageContext for asynchronous mediation using the : SendFile2VendorSeq Sequence
[2016-07-27 09:25:36,552] DEBUG - SequenceMediator Start : Sequence <SendFile2VendorSeq>
[2016-07-27 09:25:36,552] DEBUG - SequenceMediator Sequence <SequenceMediator> :: mediate()
[2016-07-27 09:25:36,552] DEBUG - SequenceMediator Mediation started from mediator position : 0
[2016-07-27 09:25:36,552] DEBUG - SequenceMediator Building message. Sequence <SequenceMediator> is content aware
[2016-07-27 09:25:36,552] DEBUG - LogMediator Start : Log mediator
[2016-07-27 09:25:36,552] INFO - LogMediator To: , MessageID: urn:uuid:c620513a-5b90-452e-8133-d5fd23e2cce0, Direction: request, vendorId =
[2016-07-27 09:25:36,552] DEBUG - LogMediator End : Log mediator
[2016-07-27 09:25:36,552] DEBUG - DBLookupMediator Start : DBLookup mediator
[2016-07-27 09:25:36,582] DEBUG - DBLookupMediator Getting a connection from DataSource jdbc/CallOneCDRDB and preparing statement :
SELECT SELECT code, name FROM vendor WHERE id = ?
[2016-07-27 09:25:36,662] DEBUG - DBLookupMediator Setting as parameter : 1 value : null as JDBC Type : 4(see java.sql.Types for valid types)
[2016-07-27 09:25:36,662] DEBUG - DBLookupMediator Successfully prepared statement :
SELECT code, name FROM vendor WHERE id = ?

One option you can try is use org.apache.synapse.startup.tasks.TemplateMessageExecutor
as the task class. This class exposes two parameters :
1. templateParams
You can set the parameters here in an XML in some root element.
Example :
<root>
<user>John</user>
<age>10</age>
</root>
2. templateKey
You can set the key of sequence template that uses the above parameters here.
Example : gov:/sequenceTemplates/getUserSequenceTemplate
Sample Sequence Template
<template name="getUserSequenceTemplate" xmlns="http://ws.apache.org/ns/synapse">
<parameter name="user"/>
<parameter name="age"/>
<sequence>
<log level = "full">
<property name="User name is" expression={$func:user} />
<property name="User age is" expression={$func:age} />
</log>
</sequence>
</template>

There seems to be issue with namespace. I have updated the task and sequence as follow. This worked for me.
Task
<task class="org.apache.synapse.startup.tasks.MessageInjector" group="synapse.simple.quartz" name="UploadFile2Vendor1" xmlns="http://ws.apache.org/ns/synapse">
<trigger interval="15"/>
<property name="message" xmlns:task="http://www.wso2.org/products/wso2commons/tasks">
<request xmlns="" xmlns:m0="http://services.samples">
<vendorId>1</vendorId>
</request>
</property>
<property name="sequenceName" value="SendFile2VendorSeq" xmlns:task="http://www.wso2.org/products/wso2commons/tasks"/>
<property name="injectTo" value="sequence" xmlns:task="http://www.wso2.org/products/wso2commons/tasks"/>
</task>
Sequence
<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse"
name="SendFile2VendorSeq"
trace="disable">
<log level="full"/>
<log>
<property xmlns:m0="http://services.samples"
name="vendorId"
expression="//vendorId"/>
</log>
</sequence>

Related

Error while building Passthrough stream First Element must contain the local name, Envelope , but found alerts

Scenario
I've created a proxy service which calls an endpoint. The endpoints gives XML response. I'm using Foreach Mediator to iterate through the XML response using the defined XPath expression. Finally, each record will be inserted to the database using the DB Report Mediator.
Proxy Service
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="alertsIoscoProxy" startOnLoad="true" statistics="enable" trace="enable" transports="http https" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<send>
<endpoint>
<address uri="https://www.XXXXXX/investor_protection/investor_alerts/xml-feed">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>1</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</address>
</endpoint>
</send>
</inSequence>
<outSequence>
<foreach expression="//alerts/alert" id="foreach_alert">
<sequence>
<dbreport>
<connection>
<pool>
<driver>org.postgresql.Driver</driver>
<url>jdbc:postgresql://localhost:5432/postgres</url>
<user>postgres</user>
<password>admin</password>
</pool>
</connection>
<statement>
<sql><![CDATA[insert into IOSCO_RESPONSE (ID, DATE_POSTED, COMPANY,REGULATOR, JURISDICTION, LINK, SUBJECT) values (?,?,?,?,?,?,?)]]></sql>
<parameter expression="//id" type="VARCHAR" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"/>
<parameter expression="//datePosted" type="VARCHAR" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"/>
<parameter expression="//company" type="VARCHAR" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"/>
<parameter expression="//regulator" type="VARCHAR" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"/>
<parameter expression="//jurisdiction" type="VARCHAR" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"/>
<parameter expression="//link" type="VARCHAR" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"/>
<parameter expression="//subject" type="VARCHAR" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"/>
</statement>
</dbreport>
</sequence>
</foreach>
<log level="custom">
<property name="add" value="Records added!!!!"/>
</log>
<sequence key="Lookup"/>
<respond/>
</outSequence>
<faultSequence/>
</target>
</proxy>
Sample XML
<alerts>
<message>Results are capped at 500 records.</message>
<alert>
<id>23091</id>
<datePosted>20221209</datePosted>
<company>Trado Banco</company>
<regulator>Financial Conduct Authority</regulator>
<jurisdiction>United Kingdom</jurisdiction>
<link>https://www.fca.org.uk/news/warnings/trado-banco</link>
<subject>Regarding fraudulent or manipulative practices (insider dealing, market manipulation, misrepresentation of material information, etc.)<br /><br />Regarding registration of issuance, offer or sale of securities/derivatives, and reporting requirements<br /><br />Regarding market intermediaries (investment and trading advisers, collective investment schemes, brokers, dealers, and transfer agents)<br /><br />Regarding markets, exchanges, and clearing and settlement entities<br /><br />Miscellaneous</subject>
<comments/>
<attachments/>
</alert>
.
.
.
</alerts>
Error
[2022-12-13 23:42:55,323] INFO {TRACE_LOGGER} - {proxy:alertsIoscoProxy} Proxy Service alertsIoscoProxy received a new message...
[2022-12-13 23:42:55,323] INFO {TRACE_LOGGER} - {proxy:alertsIoscoProxy} Message To: null
[2022-12-13 23:42:55,323] INFO {TRACE_LOGGER} - {proxy:alertsIoscoProxy} SOAPAction: null
[2022-12-13 23:42:55,323] INFO {TRACE_LOGGER} - {proxy:alertsIoscoProxy} WSA-Action: null
[2022-12-13 23:42:55,324] INFO {TRACE_LOGGER} - Setting specified anonymous fault-sequence for proxy
[2022-12-13 23:42:55,324] INFO {TRACE_LOGGER} - {proxy:alertsIoscoProxy} Using the anonymous in-sequence of the proxy service for mediation
[2022-12-13 23:42:55,878] INFO {TRACE_LOGGER} - Setting specified anonymous fault-sequence for proxy
[2022-12-13 23:42:57,175] ERROR {RelayUtils} - Error while building Passthrough stream org.apache.axiom.soap.SOAPProcessingException: First Element must contain the local name, Envelope , but found alerts
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.constructNode(StAXSOAPModelBuilder.java:305)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createOMElement(StAXSOAPModelBuilder.java:252)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createNextOMElement(StAXSOAPModelBuilder.java:234)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:249)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:204)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:154)
at org.apache.axiom.om.impl.AbstractOMMetaFactory.createStAXSOAPModelBuilder(AbstractOMMetaFactory.java:73)
at org.apache.axiom.om.impl.AbstractOMMetaFactory.createSOAPModelBuilder(AbstractOMMetaFactory.java:79)
at org.apache.axiom.om.OMXMLBuilderFactory.createSOAPModelBuilder(OMXMLBuilderFactory.java:196)
at org.apache.axis2.builder.SOAPBuilder.processDocument(SOAPBuilder.java:65)
at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:153)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:169)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:122)
at org.apache.synapse.transport.util.PassThroughMessageHandler.buildMessage(PassThroughMessageHandler.java:103)
at org.apache.synapse.mediators.AbstractListMediator.buildMessage(AbstractListMediator.java:155)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:96)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:72)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:377)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:627)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:208)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:298)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Question
Why proxy Service is considering the response as Soap while its HTTP response with xml based formatting? How could I solve this issue?
One reason for this issue is, your response coming from https://www.XXXXXX/investor_protection/investor_alerts/xml-feed maybe having the Content-Type set to text/xml which is by default considered as a SOAP message and built with the SOAPMessageBuilder. If you can change the backend to send application/xml as the content type this would resolve the issue. Else you will have to change the Message Builder configurations to build text/xml messages with ApplicationXMLBuilder. For that you need to add the following to the deployment.toml.
[[custom_message_builders]]
content_type = "text/xml"
class="org.apache.axis2.builder.ApplicationXMLBuilder"
Note that this will affect all the SOAP 1.1 calls as well, which use text/xml content type. To avoid this you can create a custom message builder as well. More details are on the aforementioned doc.

WSO2 ESB FileConnector MergeFiles does not produce expected results

I am working with the WSO2 ESB 6.5.0 and am using the fileconnector-2.0.21 version for file operations. The proxy service that I'm building is intended to read the files from a certain source path and merge the contents into a file at the destination path.
The content of the proxy service artifact is below
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="FileMergeProxy" startOnLoad="true" transports="http https" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<log description="Combine files" level="custom" separator="| ">
<property name="statusMessage" value="Processing complete"/>
<property name="fileCreation" value="Initiating file merge"/>
<property expression="$ctx:mergeDirPath" name="sourceDir"/>
<property expression="$ctx:finalDirPath" name="destDir"/>
<property expression="$ctx:outputFilePattern" name="pattern"/>
<property expression="fn:concat('file:///', $ctx:mergeDirPath)" name="sourceDir1" scope="default" type="STRING"/>
property expression="fn:concat('file:///', $ctx:finalDirPath)" name="destDir1" scope="default" type="STRING"/>
</log>
<fileconnector.mergeFiles>
<source>{$ctx:mergeDirPath}</source>
<destination>{$ctx:finalDirPath}</destination>
<filePattern>{$ctx:outputFilePattern}</filePattern>
</fileconnector.mergeFiles>
<log description="Processing complete" level="custom" separator="| ">
<property name="doneMessage" value="File merge processing complete"/>
</log>
</inSequence>
<outSequence/>
<faultSequence>
<log level="custom">
<property name="text" value="An unexpected error occured"/>
<property expression="get-property('ERROR_MESSAGE')" name="message"/>
<property expression="get-property('ERROR_DETAIL')" name="errordetail"/>
</log>
<send description="Send Error Information"/>
</faultSequence>
</target>
</proxy>
I'm invoking the service with the following parameters as a JSON file
{
"mergeDirPath": "C://temp//merge//",
"finalDirPath": "C://temp//final//finalcontent.txt",
"outputFilePattern": "\\*txt"
}
When I call the service after deploying the artifacts to the ESB engine, it creates an empty file in the destination path without merging the contents of the files in the source directory. This is the extract from the WSO2 logs.
[2020-03-23 12:48:36,683] [] INFO - LogMediator To: /services/FileMergeProxy,MessageID: urn:uuid:b569ec6a-d4fe-4763-a0ca-fb2eb868a31e correlation_id : a1c542bb-7fac-4e0b-9582-8cb1a605f618,Direction: request,Payload: { "mergeDirPath": "C://temp//merge//", "finalDirPath": "C://temp//final//finalcontent.txt", "outputFilePattern": "\\*txt" }
[2020-03-23 12:49:00,422] [] INFO - LogMediator statusMessage = Combine files| fileCreation = Initiating file merge| sourceDir = C://temp//merge//| destDir = C://temp//final//finalcontent.txt| pattern = \*txt| sourceDir1 = file:///C://temp//merge//| destDir1 = file:///C://temp//final//finalcontent.txt
[2020-03-23 12:49:02,943] [] INFO - LogMediator doneMessage = File merge processing complete
Unless I'm missing something here, shouldn't the mergeFiles be doing exactly that - merge the contents of files in a specified directory ? Any helpful suggestions or pointers are welcome. Thanks in advance.
According to the proxy you have shared, you have defined properties inside the log mediator. Define the properties outside the log mediator.

How to call sequence in Task Scheduler in wso2 esb

I want to run a proxy(pass through) or a sequence(pass through type) repeatatively after every 60 seconds so i started with Task Scheduler but i am not able to figure out how can i achieve my requirement using Task Scheduler. I want to execute my proxy or sequence after every 60 seconds.Like in wso2 BPS we can achieve this thing using loops, Likewise is there anything in esb that can schedule run a proxy or sequence after certain interval of time? Looking forward to your answers.
Thanks in advance.
IS it possible to achieve above requirement in wso2 esb. Please Help.
You can use the task to run a proxy service which is configured in your ESB. You need to configure the task as below.
Here is a sample configuration to access the SimpleStockQuoteService sample service which comes with the ESB. You can replace the value of the "to" property to match your proxy endpoint and set the desired message.
<task class="org.apache.synapse.startup.tasks.MessageInjector" name="CheckPrice">
<property name="to" value="http://localhost:9000/services/SimpleStockQuoteService"/>
<property name="soapAction" value="urn:getQuote"/>
<property name="message">
<m0:getQuote xmlns:m0="http://services.samples">
<m0:request>
<m0:symbol>IBM</m0:symbol>
</m0:request>
</m0:getQuote>
</property>
<trigger interval="5"/>
</task>
Form WSO2 ESB version 4.7.0 new properties are added to task component. Using those we can call a proxy service or sequence from our task scheduler. Below are my sample code for calling a proxy service
<task name="DBPOller"
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="soapAction"
value="urn:getRequestForm"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks" name="message">
<p:getRequestForm xmlns:p="http://ws.wso2.org/dataservice"><!--Exactly 1 occurrence--><p:isRead>n</p:isRead>
</p:getRequestForm>
</property>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks"
name="injectTo"
value="proxy"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks"
name="proxyName"
value="DBPollerService"/>
</task>

Scheduled Message Forwarding Processor does not deactivate after X delivery attempts

I'm running WSO2 ESB 4.5.1 with Sun Java SE 1.6.0_33 on Red Hat 2.6.32 using Apache ActiveMQ 5.5.1 as persistent storage to the ESB.
I’m trying to write a flow that:
1. reads address information from XML file
2. save each address in MQ queue
3. have a Message Processor read from MQ and attempt delivery to a JMS Endpoint
4. if the delivery fails the Message Processor is to attempt one more delivery before deactivating itself
When the JMS Endpoint (another ActiveMQ instance running on another server) is up everything works great, but if I stop the ActiveMQ that is acting as the JMS Endpoint the Message Processor does not deactivate as I expect after one retry but continually attempts to resend the same messages from Message Store. What is going wrong?
Here is the flow I have:
Proxy:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="AddressPxy" transports="vfs" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
<property name="target.endpoint" value="AddressesEP" scope="default" type="STRING"/>
<log level="full"/>
<iterate expression="//addresses/address">
<target>
<sequence>
<store messageStore="AddressesMS"/>
</sequence>
</target>
</iterate>
</inSequence>
</target>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.PollInterval">15</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file:///home/esb/sent</parameter>
<parameter name="transport.vfs.FileURI">file:///home/esb/addresses.xml</parameter>
<parameter name="transport.vfs.MoveAfterFailure">file:///home/esb/fail</parameter>
<parameter name="transport.vfs.ContentType">application/xml</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
<description></description>
</proxy>
Message Store:
<messageStore name="AddressesMS" class="org.wso2.carbon.message.store.persistence.jms.JMSMessageStore" xmlns="http://ws.apache.org/ns/synapse">
<parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
<parameter name="java.naming.provider.url">tcp://localhost:61616</parameter>
<parameter name="store.jms.JMSSpecVersion">1.1</parameter>
<parameter name="store.jms.cache.connection">false</parameter>
</messageStore>
Message Processor:
<messageProcessor name="AddressesMP" class="org.apache.synapse.message.processors.forward.ScheduledMessageForwardingProcessor" messageStore="AddressesMS" xmlns="http://ws.apache.org/ns/synapse">
<parameter name="interval">10000</parameter>
<parameter name="max.delivery.attempts">1</parameter>
</messageProcessor>
Endpoint:
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="AddressesEP">
<address uri="jms:/Addresses?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://rhdev001:61616&transport.jms.DestinationType=queue">
</address>
</endpoint>
I see this error message in wso2carbon.log:
TID: [0] [ESB] [2012-11-07 02:58:07,396] ERROR {org.apache.axis2.transport.jms.JMSSender} - Unable to create a JMSMessageSender for : null {org.apache.axis2.transport.jms.JMSSender}
javax.jms.JMSException: Could not connect to broker URL: tcp://rhdev001:61616. Reason: java.net.ConnectException: Connection refused
TID: [0] [ESB] [2012-11-07 02:58:07,398] ERROR {org.apache.synapse.message.processors.forward.BlockingMessageSender} - Error sending Message to url : jms:/Addresses?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://rhdev001:61616&transport.jms.DestinationType=queue {org.apache.synapse.message.processors.forward.BlockingMessageSender}
org.apache.axis2.AxisFault: Unable to create a JMSMessageSender for : null
TID: [0] [ESB] [2012-11-07 02:58:07,399] ERROR {org.apache.synapse.message.processors.forward.ForwardingJob} - Error Forwarding Message {org.apache.synapse.message.processors.forward.ForwardingJob}
java.lang.Exception: Error while Sending Message
Hope someone can help me!
In this version of ESB There is a slight problem with "max.delivery.attempts" parameter in the message processor. But you can make this work by going to source view and changing "max.delivery.attempts" to "max.deliver.attempts".

Exposing WSO2 ESB as REST for use in JavaScript

I have been digging around in Stackoverflow and WSO2 ESB documentation for days but I have yet to come across any clear answer.
My application is in JavaScript and using the Dojo framework. Ideally all the web services call should be make against REST and returns JSON. I know how to get the SOAP xml to come back as JSON because of this example 440: "http//wso2.org/project/esb/java/4.0.3/docs/samples/advanced_mediation_samples.html#Sample440" I have looked at the sample posted on this blog as well: "http//vvratha.blogspot.ca/2011/11/invoking-restful-service-via-wso2esb.html" I seems to be able to call the proxy service from tools like soapUI and get my result in JSON. So I can only assume that ESB is working properly However when I try to call it using dojo.xhrGet or dojo.io.script.get, the data returns as NULL always!!!
What is the method in REST am I supposed to call for a ESB Proxy Service? If I look at the wsdl of the service, the operation seems to call "mediate" but that did not get me any further. I have looked at example 800: "http//wso2.org/project/esb/java/4.0.3/docs/samples/rest_api_samples.html#Sample800" but I am not clear where to use this.
Note: Please add ":" after http for those http links. I seems to be running out of quotas for hyperlinks.
More information after some help from Ratha:
1. This is how I want to call the proxy service: (There will be more querystring parameters later)
http//loh7:8280/services/TestRestProxy?address=1460%20nicholson%20road
Query string is null from this Mediation Message Tracker dump:
13:10:10,803 [-] [HttpServerWorker-16] INFO Proxy Service TestRestProxy received a new message from : 192.168.7.143
13:10:10,803 [-] [HttpServerWorker-16] INFO Message To: /services/TestRestProxy?address=1460%20nicholson%20road
13:10:10,803 [-] [HttpServerWorker-16] INFO SOAPAction: null
13:10:10,803 [-] [HttpServerWorker-16] INFO WSA-Action: null
13:10:10,803 [-] [HttpServerWorker-16] INFO Using the anonymous in-sequence of the proxy service for mediation
13:10:10,804 [-] [HttpServerWorker-16] INFO Start : Sequence
13:10:10,804 [-] [HttpServerWorker-16] INFO Sequence :: mediate()
13:10:10,804 [-] [HttpServerWorker-16] INFO Start : Log mediator
13:10:10,805 [-] [HttpServerWorker-16] INFO querystring = null
13:10:10,805 [-] [HttpServerWorker-16] INFO End : Log mediator
13:10:10,806 [-] [HttpServerWorker-16] INFO Start : Log mediator
13:10:10,806 [-] [HttpServerWorker-16] INFO End : Log mediator
13:10:10,806 [-] [HttpServerWorker-16] INFO Start : Send mediator
13:10:10,806 [-] [HttpServerWorker-16] INFO Sending message through endpoint : EsriNA10 resolving to address =
This is how the proxy looks like:
Note: I wanted to extract the "address" value and put it in the $1 in the request soap message.
<proxy xmlns="http://ws.apache.org/ns/synapse" name="TestRestProxy" transports="https,http" statistics="disable" trace="enable" startOnLoad="true">
<target>
<inSequence>
<log level="custom">
<property name="querystring" expression="get-property('REST_URL_POSTFIX')" />
</log>
<payloadFactory>
<format>
<GeocodeAddress xmlns="http://www.esri.com/schemas/ArcGIS/10.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Address xmlns="">
<PropertyArray>
<PropertySetProperty>
<Key>Street</Key>
<Value>$1</Value>
</PropertySetProperty>
<PropertySetProperty>
<Key>City</Key>
<Value>Newmarket</Value>
</PropertySetProperty>
<PropertySetProperty>
<Key>State</Key>
<Value>ON</Value>
</PropertySetProperty>
<PropertySetProperty>
<Key>Zip</Key>
<Value>L3Y 9C3</Value>
</PropertySetProperty>
<PropertySetProperty>
<Key>Country</Key>
<Value>CANADA</Value>
</PropertySetProperty>
</PropertyArray>
</Address>
<PropMods xmlns="">
<PropertyArray>
<PropertySetProperty>
<Key>OutputSpatialReference</Key>
<Value xmlns:q2="http://www.esri.com/schemas/ArcGIS/10.0" xsi:type="q2:ProjectedCoordinateSystem">
<WKID>102100</WKID>
</Value>
</PropertySetProperty>
</PropertyArray>
</PropMods>
</GeocodeAddress>
</format>
<args>
<arg expression="$ctx:querystring" />
</args>
</payloadFactory>
<log level="full" category="TRACE" separator="," />
<send>
<endpoint key="EsriNA10" />
</send>
</inSequence>
<outSequence>
<log level="full" separator="," />
<xslt key="out_transform" />
<property name="messageType" value="application/json" scope="axis2" type="STRING" />
<send />
</outSequence>
</target>
</proxy>
In the sample 800 it explains how you can directly invoke RESTAPIs..
For example, if you have your REST service endpoints point that as your service endpoint. Note that the following configuration;
<api name="StockQuoteAPI" context="/stockquote">
<resource uri-template="/view/{symbol}" methods="GET">
Where we define the RESTAPI call stockquoteAPI and defining the context and uritemplate..
So, when you try to execute above API, use curl or other REST client and execute like;
curl -v http://127.0.0.1:8280/stockquote/view/IBM
Here you will see we provide the context and uri template..from that we pick symbol call IBM and sending to stcokquote service..But it is your logic, you can define your own logic in the sequence.
Edit
From browser try like this;
http://localhost:8280/services/yourProxy/<Operation>?param1=21312&param2=wqeqw
Here the "operation" is the operation(which is present at your backend REST service) you try to invoke.
"Mediate" is the default operation..If you want to execute your actual backend service operation provide that operation as i mentioned above.
When you define proxy follow my sample in the blog..
<proxy name="yourProxy" transports="https http" startOnLoad="true" trace="disable">
<target>
<endpoint>
<address uri="Your REST SERVICE ENDPOINT URL"/>
</endpoint>
<inSequenc>
<log level ="custom">
<property name="querystrings" expression=get-property('REST_URL_POSTFIX')/>
</log>
</inSequnece>
<outSequence>
<send/>
</outSequence>
</target>
</proxy>
Try above proxy and see what it logs fro "querystrings"
You can use REST API to invoke allt hese http verbs.Simply define what type of the verb you like to execute..and route the request to the service endpoint
This is a simple introduction part..hope may help you..
http://vvratha.blogspot.com/2012/09/rest-support-in-wso2esb-introduction.html