Tuesday, 27 August 2013

WSO2 ESB 4.7.0 JMS MessageStore/MessateProcessor fail to handle JSON correctly

WSO2 ESB 4.7.0 JMS MessageStore/MessateProcessor fail to handle JSON
correctly

I am using WSO2 ESB 4.7.0 with ActiveMQ. I am trying to implement a simple
store and forward configuration as per this wso2 documentation.
Here is the proxy I am using to Store in JMS and Forward :
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="testJMSStorenFwd"
transports="http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence onError="fault">
<property name="messageType" value="application/json"
scope="axis2"/>
<property name="FORCE_ERROR_ON_SOAP_FAULT" value="true"/>
<property name="OUT_ONLY" value="true"/>
<log level="full"/>
<property name="target.endpoint" value="JMSRcvEndPoint"
format="soap11"/>
<store messageStore="FMSReadings"/>
<!--send>
<endpoint key="JMSRcvEndPoint" format="soap11"/>
</send-->
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
</proxy>
Here is the endpoint to which the Message should ultimately be forwarded :
<?xml version="1.0" encoding="UTF-8"?>
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="JMSRcvEndPoint">
<address uri="http://kk1:8282/services/testJMSRcvProxy" format="soap11"/>
</endpoint>
Here is the proxy which receives the forwarded message ( it just logs the
received message for this test):
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="testJMSRcvProxy"
transports="http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence onError="fault">
<property name="messageType" value="application/json" scope="axis2"/>
<property name="FORCE_ERROR_ON_SOAP_FAULT" value="true"/>
<log level="full"/>
<drop/>
</inSequence>
<outSequence>
<drop/>
</outSequence>
</target>
</proxy>
Here is my messagestore :
<?xml version="1.0" encoding="UTF-8"?>
<messageStore xmlns="http://ws.apache.org/ns/synapse"
class="org.wso2.carbon.message.store.persistence.jms.JMSMessageStore"
name="FMSReadings">
<parameter
name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
<parameter name="store.jms.cache.connection">false</parameter>
<parameter
name="java.naming.provider.url">tcp://localhost:61616</parameter>
<parameter name="store.jms.JMSSpecVersion">1.1</parameter>
</messageStore>
Here is my MessageProcessor :
<?xml version="1.0" encoding="UTF-8"?>
<messageProcessor xmlns="http://ws.apache.org/ns/synapse"
class="org.apache.synapse.message.processors.forward.ScheduledMessageForwardingProcessor"
name="fwdTotestJMSRcvProxy"
messageStore="FMSReadings">
<parameter name="interval">1000</parameter>
</messageProcessor>
I am using a simple curl command with very basic JSON to test this setup
like below :
curl -v -H "Accept: application/json" -H "Content-Type:application/json"
-d '{"mail":"faisal.shaik@youtility.in"}'
http://kk1:8282/services/testJMSStorenFwd
When I run this the message gets stored and forwarded by the setup ( I can
verify from ActiveMQ web UI that a message was enqueued and dequeued) but
I get below error in ESB logs :
[2013-08-27 14:24:44,052] INFO - To: /services/testJMSStorenFwd,
MessageID: urn:uuid:bb553e52-ee61-4d15-8c1f-19be1356c8e0, Direction:
request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope
xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><mail>faisal.shaik@youtility.in</mail></soapenv:Body></soapenv:Envelope>
{org.apache.synapse.mediators.builtin.LogMediator}
[2013-08-27 14:24:44,085] ERROR - Error building message
{org.apache.synapse.transport.passthru.util.DeferredMessageBuilder}
org.apache.axis2.AxisFault: Failed to convert JSON to XML payload.
Expected a ',' or '}' at character 50 of { "xmlPayload" :
<mail>faisal.shaik@youtility.in</mail>}
at org.apache.axis2.json.JSONBuilder.processDocument(JSONBuilder.java:86)
at
org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:118)
If you notice in the testJMSStorenFwd proxy above I've a commented out
send section. If I uncomment that and comment out the
<property name="target.endpoint" value="JMSRcvEndPoint" format="soap11"/>
<store messageStore="FMSReadings"/>
section, I get the json properly converted to xml and following output in
the logs :
[2013-08-27 14:53:27,333] INFO - To: /services/testJMSStorenFwd,
MessageID: urn:uuid:e482aba1-98a9-4181-9c8e-c5110dcefd09, Direction:
request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope
xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><mail>faisal.shaik@youtility.in</mail></soapenv:Body></soapenv:Envelope>
{org.apache.synapse.mediators.builtin.LogMediator}
[2013-08-27 14:53:27,346] INFO - To: /services/testJMSRcvProxy,
MessageID: urn:uuid:e6da7131-60ec-4c92-b204-e3843f7e6e91, Direction:
request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Envelope><soapenv:Body><mail>faisal.shaik@youtility.in</mail></soapenv:Body></soapenv:Envelope></soapenv:Body></soapenv:Envelope>
{org.apache.synapse.mediators.builtin.LogMediator}
As you can see from above, the same input given to messagestore &
messageprocessor mechanism using same settings results in JSON to XML
conversion errors.
Is this a bug in the wso2 esb MessageStore &/or MessageProcessor or am I
doing something wrong? Is there a way to get rid of the errors I am
getting while using this JMS store & forward without resorting to the
script mediator?

No comments:

Post a Comment