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>
Related
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
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.
When I create proxy with send mediator with Rest service Post HTTP Method in HTTP endpoint url. Selected the endpoint as HTTP endpoint on proxy and post the request xml without soap envelop, this perfectly works and get the response in the response window.
But when I use the call mediator with the same HTTP end point url configuration, this does not works. I would like to know can we use call mediator for Post HTTP method? When I use Call mediator for the GET HTTP method which require only query parameters and does not require any request xml this works absolutely fine.
Here is the further information:
However issue is resloved by using the address endpoint in callmediator. When I Invoke the proxy from external Restt client ot Soap UI, it does works. If I use the Try this Service option in wso2 ESB will fail with the results 1. When Soap12 endpoint is selected and 2 when HTTP end point is selected as shown below.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="postIDMPCall"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<property name="ContentType" value="text/xml" scope="axis2" type="STRING"/>
<property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING"/>
<payloadFactory media-type="xml">
<format>
<organizationList xmlns="">
<xml content>
</organizationList>
</format>
<args/>
</payloadFactory>
<header name="_user" scope="transport" value="username"/>
<header name="_password" scope="transport" value="Password"/>
<call blocking="true">
<endpoint>
<address uri="http://<ip-address>:<port>/<resource-path>/UpdateOrganization"
format="rest"/>
</endpoint>
</call>
</inSequence>
</target>
</proxy>
Output: When soap12 endpoint is selected
Though posted the correct xml service does not recorgonize the correct xml format for soap12 endpoint.
FAILURE
Record is not processed successfully. Please Provide valid Request XML
When Http end point is selected
[2016-04-21 12:07:50,179] INFO - HTTPSender Unable to sendViaPost to url[http://://UpdateOrganization/mediate]
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
I think we can't use call mediator for this purpose because call mediator is context unaware mediator.
Your call should already perform a post out the box.
Did you try to set format="pox" if you expect simple xml as a response
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.
I have the following logic in my Proxy Service:
<proxy>
<inSequence>
<switch source="get-property('Action')">
<case regex="getTaskTicket">
<sequence key="CQProxy_GetTaskTicket"/>
</case>
<case regex="updateTaskTicket">
<sequence key="CQProxy_UpdateTaskTicket"/>
</case>
...
<default/>
</switch>
</inSequence>
<outSequence>
<send/>
</outSequence>
</proxy>
Now my CQProxy_UpdateTaskTicket calls another sequence:
<sequence name="CQProxy_UpdateTaskTicket">
... some logic goes here ...
<sequence key="CQProxy_GetTicketDetails"/>
... here I need to wait for response from CQProxy_GetTicketDetails
before further processing ...
</sequence>
CQProxy_GetTicketDetails is used by various other sequences and in its turn defines OUT sequence to process its response:
<sequence name="CQProxy_GetTicketDetails">
... some logic ...
<send receive="CQProxy_GetTicketDetails2">
<endpoint key="CQ"/>
</send>
</sequence>
The problem is that after CQProxy_UpdateTaskTicket sequence calls CQProxy_GetTicketDetails sub-sequence, it does not wait for response from that sub-seq but instead continues message processing.
How is it possible to make CQProxy_UpdateTaskTicket wait for response before proceeding?
I was able to get around this issue by passing the response sequence name to the sub-sequence.
You can use the Callout mediator for the blocking kind of operations within the WSO2 ESB. Instead of using the Send mediator (which is non-blocking) you can easily use callout mediator as mentioned below.
http://docs.wso2.org/wiki/display/ESB460/Callout+Mediator