processing jms message in wso2 esb - jms

I have the JMS message as
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<content>
<entry type="1">
<textMessage JMSDeliveryMode="2" JMSDestination="queue:///QUEUE" JMSExpiration="0" JMSMessageID="ID:c3e2d840d8e3c1f14040404040404040cf1eba01c4eff036" JMSPriority="4" JMSRedelivered="false" JMSTimestamp="1434705226223" fromQueue="true" codec="Base64">
<text>dGVzdA==</text>
</textMessage>
</entry>
</content>
but when i pull it into wso2 esb it gets into soap envelope and i'm not able to retrieve the properties over here, like JMSDestination etc.
I want to read those details in WSO2 ESB. Is there a way?
I get the following SOAP message after getting the message from JMS, and it is logging or the xPath works only on this.
[2015-06-22 11:08:33,632] INFO - LogMediator To: , WSAction: urn:mediate, SOAPA
ction: urn:mediate, MessageID: ID:c3e2d840d8e3c1f14040404040404040cf224f7f3bbf47
25, Direction: request, Envelope: <?xml version="1.0" encoding="utf-8"?><soapenv
:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Bod
y>test1</soapenv:Body></soapenv:Envelope>
Thanks

I'm setting the JMS headers in my sending proxy like this.
In the receiving proxy, you can then access the property with get-property like in the following example.
<log level="custom">
<property name="Autodeploy_TSONL_CreateProxyTarget - Config Params transport intervall "
expression="get-property('transport','TRANSPORT_TRANSFERINTERVALL')"/>
Hope that helps.

You can select any information from the message body (even if there is a soap envelope for internal purposes) with the following code in your inSequence:
<property name="JMSDestination" expression="$body/content/entry/textMessage/#JMSDestination"/>
Verify that your message is being build with an appropriate message builder, otherwise you can't see the message content. See this JMS Proxy example:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="JMSProxyName" transports="jms" startOnLoad="true" trace="disable">
<target>
<inSequence>
<log level="custom">
<property name="Log JMSDestination" expression="$body/content/entry/textMessage/#JMSDestination"/>
</log>
<drop/>
</inSequence>
<outSequence/>
<faultSequence/>
</target>
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>application/xml</default>
</rules>
</parameter>
<parameter name="transport.jms.Destination">YourQueue</parameter>
</proxy>

Related

wso2esb failover configuration throws error

this is my proxy configuration
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="FileProcessorProxy" transports="vfs" startOnLoad="true" trace="disable">
<target>
<inSequence>
<log level="full"/>
<property xmlns:ns2="http://org.apache.synapse/xsd" name="transport.vfs.ReplyFileName" expression="fn:concat(fn:substring-after(get-property('MessageID'), 'urn:uuid:'), '.txt')" scope="transport" type="STRING"/>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
<send>
<endpoint name="FailOverTest">
<failover>
<endpoint name="endpoint_urn_uuid_6179155B57847314A656794419902014617670556">
<address uri="vfs:file:///opt/wso2/wso2data/esboverviewtest/out"/>
</endpoint>
<endpoint name="endpoint_urn_uuid_failureOut">
<address uri="vfs:file:///opt/wso2/wso2data/esboverviewtest/failureOut"/>
</endpoint>
</failover>
</endpoint>
</send>
</inSequence>
<outSequence/>
<faultSequence>
<log level="full">
<property name="faultSequence" value="send endpoint error"/>
</log>
</faultSequence>
</target>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.PollInterval">5</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file:///opt/wso2/wso2data/esboverviewtest/original</parameter>
<parameter name="transport.vfs.FileURI">file:///opt/wso2/wso2data/esboverviewtest/in</parameter>
<parameter name="transport.vfs.MoveAfterFailure">file:///opt/wso2/wso2data/esboverviewtest/failureIn</parameter>
<parameter name="transport.vfs.FileNamePattern">.*.txt</parameter>
<parameter name="transport.vfs.ContentType">text/plain</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
<parameter name="transport.vfs.MoveTimestampFormat">yyyy-MM-dd'T'HH:mm:ss.SSSZ_</parameter>
</proxy>
when I drop a proper file to to the "in" folder I got the following error -
[2015-09-06 18:36:50,092] INFO - LogMediator To: , WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:3D8967DAB6BB7F719D1441546610096, Direction: request, Envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><text xmlns="http://ws.apache.org/commons/ns/payload">test message 1
</text></soapenv:Body></soapenv:Envelope>
[2015-09-06 18:36:50,092] ERROR - ClientUtils Address information does not exist in the Endpoint Reference (EPR).The system cannot infer the transport mechanism.
[2015-09-06 18:36:50,092] ERROR - Axis2Sender Unexpected error during sending message out
org.apache.axis2.AxisFault: Address information does not exist in the Endpoint Reference (EPR).The system cannot infer the transport mechanism.
at org.apache.axis2.description.ClientUtils.inferOutTransport(ClientUtils.java:73)
at org.apache.axis2.client.OperationClient.prepareMessageContext(OperationClient.java:288)
at org.apache.axis2.description.OutOnlyAxisOperationClient.executeImpl(OutOnlyAxisOperation.java:249)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
at org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:482)
at org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:59)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:338)
at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:94)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:131)
at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:166)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.axis2.transport.base.AbstractTransportListener.handleIncomingMessage(AbstractTransportListener.java:328)
at org.apache.synapse.transport.vfs.VFSTransportListener.processFile(VFSTransportListener.java:597)
at org.apache.synapse.transport.vfs.VFSTransportListener.scanFileOrDirectory(VFSTransportListener.java:328)
at org.apache.synapse.transport.vfs.VFSTransportListener.poll(VFSTransportListener.java:158)
at org.apache.synapse.transport.vfs.VFSTransportListener.poll(VFSTransportListener.java:107)
at org.apache.axis2.transport.base.AbstractPollingTransportListener$1$1.run(AbstractPollingTransportListener.java:67)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
[2015-09-06 18:36:50,093] INFO - LogMediator To: , WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:3D8967DAB6BB7F719D1441546610096, Direction: request, faultSequence = send endpoint error, Envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><text xmlns="http://ws.apache.org/commons/ns/payload">test message 1
</text></soapenv:Body></soapenv:Envelope>
to be short:
[2015-09-06 18:36:50,092] ERROR - Axis2Sender Unexpected error during sending message out
org.apache.axis2.AxisFault: Address information does not exist in the Endpoint Reference (EPR).The system cannot infer the transport mechanism.
However, if I remove failover configuration and leave just simple endpoint with "out" directory the file is process succesfully.
I cannot understand why failover throws such exception and how to fix it.
Somehow, by checking various options, i figured out that if you change endpoint name you MUST call "publish" command against the wso2esb server again (in WSO2 development studio). In other case, wso2esb does not see endpoint's new name
I am still not sure why it is so (bug?). At least, now I have a workaround...
In my case I get URL from the database, accidentally I set it as an empty, that's why I got the issue like above.

WSO2 Message Broker not receiving message

i followed the official documentation dealing with the integration between WSO2 ESB and WSO2 MB.
https://docs.wso2.com/display/MB210/Integrating+WSO2+ESB
On my WSO2 ESB 8.1.0 i wrote a simple proxy like this:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="jobReplicaFeed"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<log level="full"/>
<send>
<endpoint key="ReplicaFeedEndpoint"/>
</send>
</inSequence>
<outSequence>
<log level="full"/>
</outSequence>
</target>
<description/>
</proxy>
where ReplicaFeedEndpoint is like the following linsting:
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="ReplicaFeedEndpoint">
<address uri="jms:/REPLICA_FEED?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.wso2.andes.jndi.PropertiesFileInitialContextFactory&java.naming.provider.url=repository/conf/jndi.properties&transport.jms.DestinationType=topic">
<suspendOnFailure>
<progressionFactor>1.0</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
<retryDelay>0</retryDelay>
</markForSuspension>
</address>
</endpoint>
and this is my jndi.properties:
connectionfactory.QueueConnectionFactory = amqp://admin:admin#clientID/carbon?brokerlist='tcp://myHost:5672'
connectionfactory.TopicConnectionFactory = amqp://admin:admin#clientID/carbon?brokerlist='tcp://myHost:5672'
topic.MioEvento = REPLICA_FEED
using a simple REST client i'm trying to send a message to the proxy, expecting the same to be intercepted by the message broker.
Nothing happens. Furthermore, trying different times i get randomly this exception:
TID: [0] [ESB] [2015-05-06 19:55:16,503] ERROR {org.apache.axis2.transport.jms.JMSOutTransportInfo} - Couldn't locate the JMS destination REPLICA_FEED of type topic/ extracted from the URL jms:/REPLICA_FEED?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.wso2.andes.jndi.PropertiesFileInitialContextFactory&java.naming.provider.url=repository/conf/jndi.properties&transport.jms.DestinationType=topic/ {org.apache.axis2.transport.jms.JMSOutTransportInfo}
javax.naming.NameNotFoundException: dynamicQueues/REPLICA_FEED
at org.wso2.andes.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:271)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at org.apache.axis2.transport.jms.JMSUtils.lookup(JMSUtils.java:583)
at org.apache.axis2.transport.jms.JMSUtils.lookupDestination(JMSUtils.java:814)
at org.apache.axis2.transport.jms.JMSOutTransportInfo.getDestination(JMSOutTransportInfo.java:184)
at org.apache.axis2.transport.jms.JMSOutTransportInfo.loadConnectionFactoryFromProperties(JMSOutTransportInfo.java:132)
at org.apache.axis2.transport.jms.JMSOutTransportInfo.createJMSSender(JMSOutTransportInfo.java:330)
at org.apache.axis2.transport.jms.JMSSender.sendMessage(JMSSender.java:127)
at org.apache.axis2.transport.base.AbstractTransportSender.invoke(AbstractTransportSender.java:112)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
at org.apache.synapse.core.axis2.DynamicAxisOperation$DynamicOperationClient.send(DynamicAxisOperation.java:185)
at org.apache.synapse.core.axis2.DynamicAxisOperation$DynamicOperationClient.executeImpl(DynamicAxisOperation.java:167)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
at org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:482)
at org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:59)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:338)
at org.apache.synapse.endpoints.AbstractEndpoint.send(AbstractEndpoint.java:333)
at org.apache.synapse.endpoints.AddressEndpoint.send(AddressEndpoint.java:59)
at org.apache.synapse.endpoints.IndirectEndpoint.send(IndirectEndpoint.java:54)
at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:97)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:131)
at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:166)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:344)
at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:385)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:183)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Threa
What could be the problem?
thanks
In the endpoint definition, the uri contains the JNDI entry to the queue, where as the transport is defined as a topic.
transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory
Should be
transport.jms.ConnectionFactoryJNDIName=TopicConnectionFactory
You can find further information in the following article on WSO2 ESB and MB Integration.
http://wso2.com/library/articles/2013/03/configuring-wso2-esb-wso2-message-broker/

Proxy Service: AdminProxy Admin Exception in wso2 esb 4.8.1

I have defined a simple proxy service in WSO2 ESB(4.8.1) which is listening over a QUEUE via JMS. This service after reading the message send it to another queue.
Problem:
When i define inline endpoint then it works fine, but if i refer to a registry endpoint then WSO2 ESB gives me error and does not allow me to modify the service.
Proxy Service:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="FailOverTest"
transports="jms"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
<log level="full"/>
<property name="ClientApiNonBlocking" action="remove" scope="axis2"/>
<send>
<endpoint key="gov:/repository/Endpoints/EndpointFailover.xml"/>
</send>
<log level="full"/>
</inSequence>
<faultSequence>
<property name="SET_ROLLBACK_ONLY"
value="true"
scope="axis2"
type="STRING"/>
<log level="custom">
<property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
<property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
<property name="ERROR_DETAIL" expression="get-property('ERROR_DETAIL')"/>
<property name="ERROR_EXCEPTION" expression="get-property('ERROR_EXCEPTION')"/>
<property name="Transaction Action" value="Rollbacked"/>
</log>
</faultSequence>
</target>
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>application/xml</default>
</rules>
</parameter>
<parameter name="transport.jms.ConnectionFactory">myQueueConnectionFactory</parameter>
<parameter name="transport.jms.DestinationType">queue</parameter>
<parameter name="transport.jms.Destination">FailOverRequest</parameter>
<parameter name="originator">ServiceAdmin</parameter>
<description/>
</proxy>
Registry Endpoint XML:
<?xml version="1.0" encoding="UTF-8"?>
<endpoint>
<address uri="jms:/FailOverResponse?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616&transport.jms.DestinationType=queue" format="pox">
</address>
</endpoint>
Error WSO2 ESB Displaying:
This error may occur if you are attempting to modify the endpoint through Source View. The Design-View endpoint modification has a nice feature that allows browsing of the registry, and it will format the link to registry endpoints successfully every time. Please try that Design-view to modify your endpoint.

WSO2ESB Simple Passthrough Proxy doesnt forward the url extensions

I implemented a simple pass through proxy i.e. when i call
"http://wso2esb:9443/services/proxy"
it should forward the request to
"http://destinationserver:80/" .
The question is the url extensions are not carried while forwarding.. i.e.
when i do a HTTP POST in
http://wso2esb:9443/services/proxy/path1/path2
the request is forwarded to
http://destinationserver:80
rather than to
http://destinationserver:80/path1/path2.
but HTTP GET behaves as expected. Could anyone help in where i am going wrong?
My Proxy.xml
<proxy xmlns="http://ws.apache.org/ns/synapse" name="proxy" transports="https,http"
statistics="disable" trace="disable" startOnLoad="true">
<target>
<outSequence>
<send/>
</outSequence>
<endpoint>
<address uri="http://destinationserver:80/"/>
</endpoint>
</target>
<description/>
</proxy>
Thanks in advance!
P.S: my WSO2ESB version : 4.8.1
If you really need that, one way (not sure this is the best) to achieve your goal would be :
<proxy xmlns="http://ws.apache.org/ns/synapse" name="proxy" transports="https,http"
statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<header name="To"
expression="concat('http://destinationserver:80',substring-after(syn:get-property('To'),'/services/proxy'))"/>
<send/>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<description/>
</proxy>
Send a post request to http://wso2esb:8280/services/proxy/path1/path2 and it should be forwarded to http://destinationserver:80/path1/path2
Things worked as per Jeans answer but Htttp HEAD request is not forwarded except it is returning 400 Bad Request. Testing with direct link on the destination server returns expected response.

How to retrive the value in Wso2esb using Xpath

I am using wso2esb4.7.0 i have written jms proxy so i wish send my data to endpoint but i am unable process this
my proxy is
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="MediaMoveQueue"
transports="jms"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<property name="readingspayload" expression="$body"/>
<payloadFactory media-type="xml">
<format>
<p:hello xmlns:p="http://jaxws.youtility.in/">
<arg0 xmlns="">$1</arg0>
</p:hello>
</format>
<args>
<arg evaluator="xml" expression="get-property('readingspayload')"/>
</args>
</payloadFactory>
<!--header name="Action" value="hello"/-->
<log level="full"/>
<send>
<endpoint>
<address uri="http://192.168.1.2:8282/services/media_move_service_i_f"
format="soap11"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<log level="full"/>
<send/>
</outSequence>
</target>
</proxy>
in this proxy i am getting the data like this if i log this esb
my log is look like this
{"timestamp":1383715637698,"tmpfilename":"313d79a7-c29b-4e1a-9609-818610a6a66b.pdf","objecttype":"Punch","filename":"enterprisedb_order.pdf","totalfilesize":994086,"uuid":"313d79a7-c29b-4e1a-9609-818610a6a66b","objectid":"313d79a7-c29b-4e1a-9609-818610a6a66b","fullpath":"/tmp/tmpmedia//313d79a7-c29b-4e1a-9609-818610a6a66b.pdf","deviceId":"911202500210109","filemimetype":"PNG"}
but i need to just send that json format of data to my endpoint for that i have tried this xpath but its showing errors of name space how would i get this
$axis2ns58:text
but its throwing errors i wish to send that data to my endpoint
i have tried this but i need above format of data only
//soapenv:Body
its giving like this result
<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<axis2ns58:text xmlns:axis2ns58="http://ws.apache.org/commons/ns/payload">{"timestamp":1383715637698,"tmpfilename":"313d79a7-c29b-4e1a-9609-818610a6a66b.pdf","objecttype":"Punch","filename":"enterprisedb_order.pdf","totalfilesize":994086,"uuid":"313d79a7-c29b-4e1a-9609-818610a6a66b","objectid":"313d79a7-c29b-4e1a-9609-818610a6a66b","fullpath":"/tmp/tmpmedia//313d79a7-c29b-4e1a-9609-818610a6a66b.pdf","deviceId":"911202500210109","filemimetype":"PNG"}</axis2ns58:text>
</soapenv:Body>
but i wish to send below data to my endpoint even payload also not supporting for this
{"timestamp":1383715637698,"tmpfilename":"313d79a7-c29b-4e1a-9609-818610a6a66b.pdf","objecttype":"Punch","filename":"enterprisedb_order.pdf","totalfilesize":994086,"uuid":"313d79a7-c29b-4e1a-9609-818610a6a66b","objectid":"313d79a7-c29b-4e1a-9609-818610a6a66b","fullpath":"/tmp/tmpmedia//313d79a7-c29b-4e1a-9609-818610a6a66b.pdf","deviceId":"911202500210109","filemimetype":"PNG"}
You could try doing
//soapenv:Body/ns:text
and set the namespace
ns="http://ws.apache.org/commons/ns/payload"
Try this:
Modify your Proxy service as below :
Instead of <property name="readingspayload" expression="$body"/> , modify it to below,
<property xmlns:ns="http://ws.apache.org/commons/ns/payload" name="readingspayload" expression="$body/ns:text/text()"/>
****
Hope this should work!!!

Resources