I'm using WSO2 ESB 4.9.0 for backend service invocation using blocking call. I have to use blocking call because of jms transaction. Sometimes the network between ESB and backend service is slow so I want to use timeout on connection, but with blocking call timeout on endpoint doesn't work. With non-blocking call timeout works fine.
Is it possible to use timeout with blocking call?
Thanks for any tips.
As endpoint timeout not working in blocking call you can try out following two methods:
1) Global timeout defined in synapse.properties(ESB_HOME\repository\conf) file.
This will decide the maximum time that a callback is waiting in the ESB for a response for a particular request.
If ESB does not get any response from Back End, it will drop the message and clears out the call back. This is a global level parameter which affects all the endpoints configured in ESB.
synapse.global_timeout_interval=120000
2) Socket timeout defined in the passthru-http.properties (ESB_HOME\repository\conf) file.
This parameter will decide on the timeout which a particular http request is waiting for a response. If ESB does not receive any response from the Back End during this period, HTTP connection get timed out and that will eventually throws timeout error in the ESB side and fault handlers will be hit.
http.socket.timeout=60000
We can define blocking timeout at /repository/conf/axis2/axis2_blocking_client.xml by defining SO_TIMEOUT parameter for relevant TransportSender [1].
[1] - https://medium.com/#dilsimchandrasena/set-timeout-for-endpoints-when-call-mediator-blocking-true-fd2744b2cc19
Related
I am implementing standard request/response scenario with MT and RabbitMQ. Client is Asp.net core API and consumer is a windows service.
As part of testing the exception cases if I stop the consumer and submit a request from API using request client, since there is no consumer processing, API got request timeout exception which is cool. But the message is sitting in the consumer queue and when I start the consumer, it picks the message and process the stuff( sending the message to external endpoint) and moved to a _skipped queue as there is no request client listening for this message.
Do you think it is correct behavior? First place when the api got request timeout exception, he will retry anyway so what’s the point of processing first message still?
How can I ignore those message where request clients were already finished processing with any error?
Thanks
What you are describing is very common, and I'd recommend reading up on idempotence and other distributed system failure scenarios.
Sending commands (the request, in this case) and conveying outcomes via a timeout in a message-based system can be very misleading. For instance, if you look at the ForkJoint, in the event of a request timeout, the response is actually a 202/Accepted instead of communicating an error.
The message is in the queue, it will be processed, so there is no reason to fail the controller and report an error back to the caller. So an intermediate response is used instead.
The sample is part of MassTransit Season 3 where I discuss a new idiom to deal with eventual completion/failure of commands in distributed systems. There might be some useful examples in there to help you understand the failure scenarios.
As doc sayed, to discard skipped messages so they are not moved to the _skipped queue:
cfg.ReceiveEndpoint("input-queue", ec =>
{
ec.DiscardSkippedMessages();
});
I have consumed a wsdl service which is working fine and if you change any request it will give you 500 error now what i need to display a predefined message if the web service that i am consuming is down & also for timeout.
Also one thing some of web service calling is not working from web service consumer no idea why but they are working from CXF any idea?
To catch a timeout from a WS, use a Catch Exception Strategy and make it execute when the following condition is met: exception.causedBy(java.util.concurrent.TimeoutException)
To catch SOAP faults:
exception.causedBy(org.mule.module.SoapFaultException)
and
exception.causedBy(org.apache.cxf.binding.soap.SoapFault)
That should get you started. Not sure about the second part as to why you can't always use the WS Consumer component.
I am new to Mule ESB. Currently i am handling a project, where we are using Mule as message broker. Requirement is client will call a SOAP web service (request-response) published in Mule ESB. In the server request will be accepted and return a correlation id in the ws response to the client, but at the same time service will also put request payload in the JMS queue for async processing. The JMS queue is also maintained in the Same Mule ESB. Could you please help me how HTTP endpoint can push to JMS endpoint in Mule ESB?
This is very simple, if you want to put your soap request in a JMS queue along the call to the SOAP web service exposed in the Mule, then what you can do is after your HTTP listener in the flow, you need to put a Async block (reference :- https://docs.mulesoft.com/mule-user-guide/v/3.6/async-scope-reference) and in that Async block you can use Object to String Transformer followed by you JMS outbound end point.
This Async block block will create a separate thread from the flow and will push your SOAP request to the JMS queue along with your SOAP web service which accept the request and return a correlation id in the ws response to the client as you reuired.
Remember anything you put inside <async/> is considered as an async block and will used as a separate thread. You need to put this after your HTTP listener in the flow as mentioned above.
How can I build a synchronous WCF service that wraps asynchronous MSMQ communications?
Let us have a simple scenario. I have a client which supports only synchronous web service calls. I need to send a synchronous request for "Order", but the back end system exposes this as an asynchronous request and response MSMQs. The WCF does not need to have any logic just wrap the MSMQ asych communication and pass parameters back and forth.
Grateful for your help
Let us have a simple scenario. I have a client which supports only synchronous web service calls
Synchronous call means you are using same link (end point url) or channel for your communication between client and server, so according to your assumption no.
Reason: Every time your client will send a request, it will keep waiting for response from server and will produce error.
Alternatively,You can define two services (different end point url) in your wsdl or webservice, one for request and one for response.
At client side you need to invoke these end point url saperately for sending request and receiving response,so it will appear as synchronous but ultimately it will be asynch. Thats all you can do in this scenario.
As per my understanding.
I have WSO2 ESB and ELB instances installed.
When HTTP request comes to ESB, it opens a socket and waits for response.
But if ELB instantiates new ESB, then response can go to ESB #2 (instead of #1) and find that there is no socket connection. How would I route response to ESB #1?
[EDIT]
I have implemented custom Axis2 transport, which has class CustomTransportListener. There is a List of opened socket connections, which wait for response. This is the reason why only ESB #1 can handle response.
Each ESB in the ESB cluster behind the ELB is the same so it would not matter which ESB node in the cluster serves the request. The purpose of the ELB is to automatically balance the load and make it so that the complexities of the cluster is not seen so it does not provide a way to specify an specific node that should receive the response.
It is not possible to send a request to a specific ESB in the cluster through the ELB because the ELB uses an Round Robin algorithm to dispatch request to the ESB cluster so you can not gurantee that a specific ESB node will get the request. In my opinoin do not think it is a good idea to make the ESB's in the same cluster different from each other :).