WSO2: Add IBM MQ Correllation ID to message header - wso2

How do you add the IBM MQ Correlation ID header to a message in WSO2 Integrator?
I have a scenario where I receive a message from MQ, transform the message using a few mediators and calls to backend services, and need to reply with the transformed message to another (MQ) queue using WSO2 Integrator (version 6.1.1). The client receiving the message is expecting to find the same Correlation ID in my reply as in his original message.
IBM tells me the property is this one:
The CorrelationId to be included in the MQMD of a message when put on
a queue.
Defined in: MQMessage class
Data Type: String of 24 characters
Syntax: To get: correlid$ = MQMessage.CorrelationId To set: MQMessage.CorrelationId = correlid$
https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_7.5.0/com.ibm.mq.dev.doc/q034650_.htm

It turns out it was an easy solution. The JMS_COORELATION_ID property must be set specifically in the axis2 scope.
So while this works:
<property name="JMS_COORELATION_ID" value="MyCoorelationId" scope="axis2" xmlns:ns="http://org.apache.synapse/xsd"/>
Using any other scope, such as default or transport, does not:
<property name="JMS_COORELATION_ID" value="MyCoorelationId" scope="transport" xmlns:ns="http://org.apache.synapse/xsd"/>
<property name="JMS_COORELATION_ID" value="MyCoorelationId" scope="default" xmlns:ns="http://org.apache.synapse/xsd"/>
Unfortunately the WSO2 documentation is dreadful and does not mention that other scopes do not work. Hope this saves someone time in the future.

Related

WSO2: Remove MQRFH2 header from outgoing IBM MQ message

I am facing an issue where the receiving application (consumer/listener of an IBM MQ) cannot handle MQHRF2 format and is expecting the raw MQSTR format instead.
When put a plain old XML message into the queue using WSO2 Integrator (v. 6.1.1), the receiving application sees:
RFH € zMQSTR z <mcd><Msd>jms_text</Msd></mcd> X<jms>
<Dst>queue://QUEUE_ALIAS</Dst><Tms>1532002363544</Tms><Dlv>2</Dlv></jms>
ahead of my XML message which starts right after the JMS tag.
How can I force WSO2 to put MQSTR instead of MQRFH2 into the Websphere MQ? I have tried the following property just before sending via my endpoint but it has no effect.
<property name="JMS_IBM_FORMAT" value="MQSTR" scope="transport" type="STRING" action="set"/>
<send>
<endpoint key="conf:/endpoints/MY_ENDPOINT.xml"/>
</send>
The endpoint is merely defined as:
<endpoint name="MY_ENDPOINT" xmlns="http://ws.apache.org/ns/synapse">
<address format="pox" uri="jms://QUEUE_ALIAS"/>
</endpoint>
The RFH2 header is added by MQ. If you don't need it, add targetClient=1 to the location URI, like:
queue:///MYQUEUE?targetClient=1
http://www.mqseries.net/phpBB2/viewtopic.php?=&p=171236
Change the queue definition the application gets from as follows:-
ALTER QLOCAL(q-name) PROPCTL(NONE)

where can I set up character encoding in WSO2 EI

I'm new to WSO2,
In the WSO2 ESB profile, I tried to send a message like this:
{"name":"中国"}
but after proxy service and in my back-end service it printed:
{"name":"???"}
it also appeared both in API, when I debug the api, I can see the payload as already unreadable.
So I think I must set up character encoding before the payload coming in. But where can I do this?
Can you help me?
Can you try adding the following (as suggested in this blog):
<property name="CHARACTER_SET_ENCODING" value="UTF-8" scope="axis2" type="STRING"/>

How correctly make sequence for WSO2 API? It's breaking email send

I create simple api with URI-template
/my_context/{param1}?b={param2}
I created simple sequence for sending email message to endpoint with address
mailto:user#gmail.com
I opened link
/api/my_context/123?b=222
And found in log messages:
Send TO: user#gmail.com/my_context/123?b=222
Incorrect Address.
Why WSO2 ESB append uri to email address?
Removing REST_URL_POSTFIX property like this will change that behavior.
<property name="REST_URL_POSTFIX" action="remove" scope="axis2"/>

WSO2 ESB 4.9 - fire and forgot is not working with OUT_ONLY

I am newbie to WSO2 ESB, so far everything is OK.
I started exploring fire and forgot feature, looks like this can be used as below to invoke async calls to end points.
<property name="CHANNEL_COD" value="999"/>
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
<property name="OUT_ONLY" value="true"/>
But when tested the API with above code, still ESB invoking the end point in syncronous. Tried this approach with call and send mediators.
Would anybody please help me is there any link I am missing here.
With ESB 4.8.1 :
If ClientApiNonBlocking property is not set, send mediator should be asynchronous.
Because of FORCE_SC_ACCEPTED, 202 http status code will be sended back at the end of IN mediation (ie : the message has been delivered to your endpoint, without waiting for the response)
If it takes several seconds to send the message to the endpoint, the caller will receive 202 status code AFTER that.
If you want this status code to be sent ASAP, you can use clone mediator and move send mediator inside clone's target

How to check if the reponse from one proxy service to other is FAULT message?

I am using WSO2 ESB 4.0.3 with Java 6 on MAC OSX 10.7.4. I have also installed Data Services Features.
In the typical scenario I have one proxy service which the client calls and I pass one the request to Data Service. Now if I have FAULT message from the Data service back to proxy how do I check in proxy service whether the response from Data Service is Fault or normal valid response?
Currently I am using following filter mediator logic in outsequence of proxy service
<filter xpath="get-property('FAULT')">
<then>
<log category="ERROR" level="custom" separator=",">
<property name="OWCHECK-faultMessage" value="TQS_OWCHECK - Received Fault From OWCHECK Data Service !!!!"/>
<property expression="$body" name="Fault-I-Got-Is"/>
<property name="OWCHECK-Forwading-Error" value="TQS_OWCHECK - Forwarding the Fault to Error Handler !!!!"/>
</log>
<else>
<xslt key="conf:/tqs/owcheck/proxy-output-transform.xslt"/>
<log category="INFO" level="custom" separator=",">
<property name="ValidResponse" value="TQS_OWCHECK - Sending Valid Response Back."/>
</log>
<send/>
</else>
</filter>
But this logic of checking the "FAULT" property works when axis2 has NIO senders & receivers in axis2.xml.
How ever if I switch the receivers & senders in axis2.xml from NIO to standard servlet one's (org.wso2.carbon.core.transports.http.HttpTransportListener / org.wso2.carbon.core.transports.http.HttpTransportListener) I do not get the "FAULT" property set and my error handling does not work.
Is there a standard way of checking if the response from one proxy service to another or response from data service to proxy is FAULT or not? I am looking for something which is independent of transport senders and receivers, at least HTTP ones.
Please help.
thanks
Abhijit
It is not good documentation I believe where none of the samples talk about how to handle the faults from Data service to Proxy service or am I missing something?
I would be thankful if I know the best practices to handle the errors from Data service as well as from one proxy to another proxy service.
Please help. This is big project at very prestigious company.
I think you need to check whether the soap body element has a soap:fault message or not. you can use the filter mediator with some xpath expression to check that.