JMS transaction roll back in WSO2 ESB4.9.0 - wso2

I've created a JMS listener as below. Everything is working fine as the listener is able to receive the messages from Q. But when my end point is down due to some reasons the message is not roll backing to Q. Would like to know the jms transaction boundary & will I be able to roll back transactoion if my end point fails. Currently it's not happening, anything I am missing here
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="TestJMSListener"
transports="jmslistener1,jmslistener2"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<call>
<endpoint key="StoreJMSMSg"/>
</call>
</inSequence>
<faultSequence>
<property name="SET_ROLLBACK_ONLY" value="true" scope="axis2"/>
</faultSequence>
</target>
<parameter name="transport.jms.ContentType">application/xml</parameter>
<parameter name="transport.jms.Destination">TestQueue</parameter>
<description/>
</proxy>

Have you also set the following in axis2.xml?
<parameter name="transport.jms.SessionTransacted">true</parameter>

The Guaranteed Delivery EIP ensures safe delivery of a message by storing it locally and transmitting it to the receiver's data store. Even when the receiver is offline, the EIP ensures that the message goes through when the receiver comes online.
Using message stores and message processors you can overcome this. Please refer the link.

Related

Continue sequence mediation after timeout in call mediator

Endpoints can have three timeout configurations. Never timeout, discard, or fault. I desperately need to continue the flow after a timeout. Is there a way to achieve this? Fault handler (onError sequence) is not a desired solution for this issue. Imagine orchestration with eight call mediators, I would have to create eight sequences and set each other as fault. This would very quickly bloat carbon apps, make code unreadable and increase deployment time.
Basically,at any given time, the state of the endpoint can be one of the following.
Active
Timeout
Suspend
OFF
When an endpoint is in the "Timeout" state, it will continue to attempt to receive messages until one message succeeds or the maximum retry setting has been reached. If the maximum is reached at which point the endpoint is marked as "Suspended." If one message succeeds, the endpoint is marked as "Active."
If you need to continue the mediation flow when you get an endpoint timeout as per the endpoint timeout configuration, you can use the fault option in responseAction.
Then, whenever the endpoint is timeout, the fault sequence (custom fault sequence if you have defined it already, otherwise the default fault sequence) will be hit. If you need to continue the mediation flow and as per the existing implementation, you can define the required mediation logic in a custom sequence and call that sequence in the fault sequence as follows.
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="customFaultSequence" xmlns="http://ws.apache.org/ns/synapse">
<!-- Log the message at the full log level with the ERROR_MESSAGE and the ERROR_CODE-->
<log level="full">
<property name="MESSAGE" value="Executing default 'fault' sequence"/>
<property expression="get-property('ERROR_CODE')" name="ERROR_CODE" xmlns:ns="http://org.apache.synapse/xsd"/>
<property expression="get-property('ERROR_MESSAGE')" name="ERROR_MESSAGE" xmlns:ns="http://org.apache.synapse/xsd"/>
</log>
<sequence key="afterTimeoutEndpointSequence"/>
</sequence>
Sample proxy service:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="TestProxy" startOnLoad="true" statistics="disable" trace="disable" transports="http,https">
<target faultSequence="customFaultSequence">
<inSequence>
<endpoint>
<address uri="http://run.mocky.io/v3/51c11e65-55a7-47e5-ba38-1d86e8e5d7ea?mocky-delay=45000ms">
<timeout>
<duration>2</duration>
<responseAction>fault</responseAction>
</timeout>
</address>
</endpoint>
<respond/>
</inSequence>
<description/>
</proxy>

WSO2 guaranteed delivery message In memory store

Trying to make workable solution for guaranteed delivery In memory.
Create InMemoryStore InMemMessageStore, create and point InsertInvoice
create API so code looking like this :
Sequence:
<?xml version="1.0" encoding="UTF-8"?> <sequence name="InMMSsequence" xmlns="http://ws.apache.org/ns/synapse">
<log level="custom">
<property name="STATE" value="message is sent to InMemMessageStore"/>
</log>
<property name="FORCE_SC_ACCEPTED" scope="axis2" type="STRING" value="True"/>
<axis2ns12:store messageStore="InMemMessageStore" xmlns:axis2ns12="http://ws.apache.org/ns/synapse"/> </sequence>
my API looks like :
<resource methods="POST" uri-template="/sendMessage">
<inSequence>
<sequence key="InMMSsequence"/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
Message Processor :
<messageProcessor name="MySMessageProcessor" class="org.apache.synapse.message.processor.impl.forwarder.ScheduledMessageForwardingProcessor" targetEndpoint="InsertInvoice" messageStore="InMemMessageStore" xmlns="http://ws.apache.org/ns/synapse">
<parameter name="interval">1000</parameter>
<parameter name="client.retry.interval">1000</parameter>
<parameter name="max.delivery.attempts">4</parameter>
<parameter name="is.active">true</parameter>
<parameter name="max.delivery.drop">Disabled</parameter>
<parameter name="member.count">1</parameter>
</messageProcessor>
And point :
<endpoint xmlns="http://ws.apache.org/ns/synapse"
name="InsertInvoice">
<http uri-template="http://xxxx.xxx.xxx.xxx/InsertInvoiceVehicleList"
method="post">
<suspendOnFailure>
<progressionFactor>1.0</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
<retryDelay>0</retryDelay>
</markForSuspension> </http> </endpoint>
PROBLEMS:
over PostMan I'm sending the request in JSON format but when I open InMemMessageStore message is in XML ?!? Why?
Endpoint expecting message in JSON format. Probably this is the reason of failure BUT on log I see something like
Failed to send the message through the fault sequence. Sequence name does not Exist.
Is the fault sequence mandatory or it is complaining because I don't have any default error sequence defines at all ?
also
Unable to sendViaPost to url[http://xxx.xxx.xx.xx/InsertInvoiceVehicleList/sendMessage]
Why the 'sendMessage' (This is uritemplate that is defined in API is added on endpoint url ?!?!)
so : Biggest issue here is how to keep message in JSON format and how to keep endpoint url intact ...
I found the problem and I wanted to share it with others ...
1. call end point from API adds postfix on end gives the error
By default, URI template 'sendMessage' will get appended to the target URL when sending messages out. You need to use following property in your sequence to remove URI template from target URL
<property action="remove" name="REST_URL_POSTFIX" scope="axis2"/>.
2. message processor fails to send message to end point
My end point was api .net web service and issue was with HTTP 1.1 chunking,had to disable it since .NET service doesn’t support it.
This setting is in axis2_blocking_client.xml and axis2_client.xml
<parameter name="Transfer-Encoding">chunked</parameter>
3. message processor fails to send message to end point
my seccond End point was servicestack web service and I used end point like
http://xxxx.xxx.xxx.xxx/TMSALSvc/UpdateStatus
but problem was that I needed to specify the reponce format. Once when I put a EndPoint delaration like
http://xxx.xxx.xxx.xx/TMSALSvc/json/reply/UpdateStatus
everything forked
I hope that this can same some times for other facing the same issues

WSO2 ESB and MB Message Store looses Message Body

i m trying to face up to the integration between WSO2 ESB 4.7.0 and WSO2 MB 2.1.0, following the instructions written at this URL:
http://docs.wso2.org/display/MB210/Integrating+WSO2+ESB
In particular i want to use a message store as a queue. So i follow the paragraph: "Integrate Using Message Stores and Processors".
I created the message store and message processor, having previously well configured ESB and MB as showed.
Finally i wrote this proxy:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="MessageStoreQueueProxy"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<send>
<endpoint>
<address uri="http://localhost:8080/RestService/rest/servizio"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
<property name="OUT_ONLY" value="true"/>
<store messageStore="JMSMS"/>
<log level="full"/>
</outSequence>
</target>
<description/>
</proxy>
When my client calls the MessageStoreQueueProxy service, on the Message Broker i can see the "JMSMS message store" counter rightly increased but, when i take a look on the "Content Type" field of each message i see just the "Java MessageObject icon", while, in the "body field", i can read just a "not supported" value.
On the other hand, if i browse the JMSMS "message store" in the ESB i can see that the messages' envelopes look like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<root>
<code>ok</code>
<documentID>2546</documentID>
</root>
</soapenv:Body>
</soapenv:Envelope>
So why the body was lost during the transaction? how can i mantain the body? or how can i recover it from the ObjectMessage in the WSO2 MB?
thanks a lot
"Message Store" does not persist the message as it is in the JMS Queue. it serializes the message and other information into java serialized object and put it into JMS Queue.When "Message Processor" processes the message, it pulls Messages from JMS Queue and deserializes the java serialized object to further process.
Here MB is used as JMS Queue. So Message Store serialize and put in MB queue. So you see serialize java object. If you use message store you won't be able see the content in MB.

Can we store a string in a text file in wso2esb?

I have a text file on my local system I wish to append the data in particular file as synchronously.
I have tried many ways, but it's not working.
ESB has this future in Oracle SOA. We can add in FILE ADAPTER. In ESB it's neither giving errors nor expected result.
My configuration is like this:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="FileWrite" transports="http,vfs" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<log>
<property name="OUT_ONLY" value="true"/>
</log>
</inSequence>
<outSequence>
<log>
<property name="OUT_ONLY" value="true"/>
</log>
<payloadFactory>
<format>
<error>error404</error>
</format>
</payloadFactory>
<send>
<endpoint>
<address uri="vfs:file:///home/youtility2/Desktop/Errorlog"/>
</endpoint>
</send>
</outSequence>
</target>
<parameter name="transport.vfs.ReplyFileURI">file:///home/user/test/out? transport.vfs.Append=true</parameter>
<parameter name="transport.PollInterval">10</parameter>
<parameter name="transport.vfs.FileNamePattern">Errorlog.text</parameter>
<parameter name="transport.vfs.ContentType">text/xml</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
<parameter name="transport.vfs.ReplyFileName">Errorlog.xml</parameter>
<description></description>
</proxy>
Actually I kept a log mediator in outSequence. The inSequence mediator is not sending the data in to the outSequence process not forwarding into outSequence. That's why I think that the above configuration is not working.
Any reference for this?
I tried above configuration in inSequence also. It's giving errors like this:
ERROR - Axis2Sender Unexpected error during sending message out
org.apache.axis2.AxisFault:
The VFS transport doesn't support synchronous responses. Please use
the appropriate (out only) message exchange pattern
Please refer to this link.
The issue is, you are setting a property inside a log mediator which is a predefined property, (ie:OUT_ONLY) which is used to indicate the request is only the "out-only" request. So, system, wont expect the response back. That is why, you are not getting anything in your outsequence.
DO NOT USE the predefined properties in the Log mediator,which will cause issues.
Keep some text in the log meditaor to indictae the flow of the message.
eg:
<inSequence>
<log>
<property name="INSEQUENCEEEEEEE" value="********"/>
</log>
</inSequence>
Like wise keep different descriptive log in the outsequence and see whether you are getting the message there, without any issue.

WSO2 ESB: WARNING: EPRs are NULL. Transport configuration my be incorrect

When activating a proxy (with the Web UI), I always get following error message:
WARNING: EPRs are NULL. Transport configuration may be incorrect
But I just don't understand why and what it means?
The source of the proxy:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="patient_toMPI_pJMS_qPatientToMPI" statistics="disable" trace="disable" transports="jms">
<parameter name="transport.jms.Destination">patient_qPatientToMPI</parameter>
<parameter name="transport.jms.ConnectionFactory">queueNonBlocking</parameter>
<parameter name="transport.jms.DestinationType">queue</parameter>
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>application/xml</default>
</rules>
</parameter>
<target faultSequence="errorSequence">
<inSequence>
<log level="custom">
<property name="Patient/toMPI" value="proxy (patient_toMPI_pJMS_qPatientToMPI) called"/>
</log>
<sequence key="patient_toMPI_sTransform"/>
</inSequence>
</target>
</proxy>
Simple fix :) Simply go to "Edit Data Service" and tick http and https on "Transport Settings"
This has already been reported as a bug here. It will be resolved in future releases.
Are you logged in as the super tenant? If so you should not be getting this issue. Aforementioned bug, we experienced only in tenant-mode.
Please make sure, you have copied required (correct) client libraries into repository/components/lib directory in ESB to allow connection between the ESB and the JMS provider.
For eg: If the provider is active-mq, you need to copy following jar files.
activemq-core-xxx.jar AND geronimo-j2ee-management_xx_spec-xx.jar