We have a flow where we have implemented a soap client to send soap messages to Service provider.
We need to retry the service call for 3 times if it fails. So we have used HTTP Outbound Endpoint inside until successful scope.
It is doing retry as expected, but in case of success scenario, even if we get the response from the service, we are observing a time out error as below.
[DispatchThread: 1] org.apache.cxf.endpoint.ClientImpl: Timed out waiting for response to operation {http://support.cxf.module.mule.org/}invoke.
Observation:
I have removed the until successfully and had the HTTP Outbound endpoint directly, in this case there is no timeout error.
I later tried having until successfully and had an acknowledge expression to accept the response, still the same time out response.
failureExpression="#[message.inboundProperties['http.status'] != 200]" ackExpression="#[message.correlationId]"
Could any one please suggest, how to configure the until successful for accepting the response and not throwing time out error.
The ackExpression has nothing to do with "accept the response", it's for generating a value that will be used as the new message payload after the flow has passed the current event to the until-successful message processor.
Try setting a response-timeout on your outbound HTTP endpoint to see if it helps: maybe the default timeout used in the context of the until-successful scope is too big and creates this issue.
I found a solution for this.
Earlier I had only HttpOutbound endpoint inside Until-Successful and I am facing Timeout issue.
Now I included Soap component also inside Until-successful scope it is working fine.
Since until successful allow us to have only one component inside, I have wrapped soap component and HttpOutbound endpoint iside a processor chain.
<until-successful objectStore-ref="objectStore"
maxRetries="3" secondsBetweenRetries="2" deadLetterQueue-ref="xxxx"
doc:name="UntilSuccessfulService" >
<processor-chain doc:name="Processor Chain">
<cxf:jaxws-client operation="Request1" serviceClass="xxxxxxx" enableMuleSoapHeaders="true" doc:name="SOAP"/>
<http:outbound-endpoint exchange-pattern="request-response" method="POST" doc:name="HTTP" host="localhost" path="cService" port="xxxx" connector-ref="HTTP_HTTPS"/>
</processor-chain>
</until-successful>
Thanks David and all for your responses.
Related
How to handle or log the client side error in best way. Say for Client enters the URL and he received 501 error. We need to log that error as well we need to log from which api call that error was occurred.
Can someone suggest. sorry, I cant give a example because its generic doubt in my mind
If any one suggests how to do. I will create the flow will share here for public use
You can't capture the HTTP status that the HTTP Listener sends automatically. For example a 404 (page not found), if there is no listener for that URL.
You can capture your own HTTP status that you set in your application, and do something before the flow ends.
Example:
<flow name="statusFlow" >
<http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/page">
<http:response statusCode="#[vars.okStatus]" />
<http:error-response statusCode="#[vars.errorStatus]" />
</http:listener>
... set the variables ...
... log the variables ...
Note that the application can not know about status returned by something in front of your application, like a load balancer. That's the case for applications deployed to CloudHub and accessed through the load balancer.
I am using Anypoint Studio 6.1 and Mule 3.8.1 and have a flow that calls MongoDB. I want to see how to get the HTTP status so I can configure my exception handling. When I disconnect MongoDB and run the Mule workflow it fails as expected, but the HTTP status is returned as null when I try this expression message.inboundProperties['http.status'] and the exception message code is -1, but when I play the error through to the end of the workflow the status shows as 500 in Postman.
How can I get the HTTP status?
Thanks
message.inboundProperties['http.status'] will give the http.status code when a HTTP Request invocation is made within the flow. If the flow is trying to invoke DB, then you may need to have a catch exception strategy inside the error handling of the flow to catch the desired exception. If the exception is matched, you can set the http.status and exception payload to be sent to the client end.
If you are using APIKit Router then you can use the following code:
<apikit:mapping-exception-strategy name="apiKitGlobalExceptionMapping">
<apikit:mapping statusCode="500">
<apikit:exception value="java.lang.Exception"/>
<set-property propertyName="Content-Type" value="application/json" doc:name="Property" />
<set-payload value="{ "message": "Internal server error" }" doc:name="Set Payload" />
</apikit:mapping>
For more details you can check here
I currently have a flow that is triggered using a specific HTTP request path, which should then make a request to a RabbitMQ server hosted locally. However, I cannot seem to see the output of the Mule Requester module; I see the HTTP request instead. Here is the gist of my current flow:
<flow name="get-queue-messages-manually" doc:name="get-queue-messages-manually" initialState="started">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="getqueue" contentType="text/plain" doc:name="HTTP"/>
<mulerequester:request returnClass="java.io.String" config-ref="Mule_Requester" resource="amqp://myexchange" doc:name="Mule Requester"/>
<logger level="INFO" doc:name="Logger"/>
<echo-component doc:name="Echo"/>
</flow>
I am able to send messages to the exchange and have them be enqueued without a problem, but I cannot seem to extract any. As I understand it, the Mule Requester module allows one to make a request for resources at any point in a flow; I believe I also read that it causes an asynchronous operation, which may be the problem here. In that case, how would I be able to retrieve the queued message, and not the HTTP request?
I have also looked into the Mulesoft AMQP documentation, and though the URI specs mention the format amdq://{exchange}/amqp-queue.{queue}, it doesn't seem that the Mule Requester accepts this, as it only seems to take exchange names only. The console logs do contain a line which states that a private queue has been created, and from a little bit of searching, is an indication that a queue name is not specified? Not quite sure how that can be done in this component, however.
Note that the reason I have the HTTP request element first is that I do not want the flow firing off the moment a message is received, and therefore the HTTP component is used to ensure that the messages are read only when requested. Without the HTTP component, everything is swell.
Thanks in advance for any pointers on this issue - been struggling with this for some time now.
Well, now I feel silly. This can indeed be done using the Mule Requester. The format for the resource field should be: amqp://amqp-queue.{queueName}. Once I used the queue name instead of the exchange, I finally see the message in the payload. Hope this helps others! (There seems to be a restriction with accepting own answers; I'll accept this answer once that is lifted)
I am very new to mule. I am trying to read a http link, which outputs txt file.
I want to call this link in mule, read text and insert data in to database.
Can any one suggest me how to read txt file in mule when file is coming from http.
Thanks in advance.
Let us consider there is a HTTP url localhost:8081/service which will provide a text output while calling it.
So, to call it from Mule flow, you need to configure HTTP outbound or HTTP request component which is used to call external url.
So, you need to configure it in following way :-
If you are using Mule 3.5 or earlier, you need outbound endpoint :-
<http:outbound-endpoint exchange-pattern="request-response" address="localhost:8081/service" method="GET" doc:name="HTTP"/>
If you are using Mule 3.6 or later version, you need Http request component :-
<http:request-config name="HTTP_Request_Configuration" host="localhost" port="8081" doc:name="HTTP Request Configuration"/>
And in Mule flow :-
<http:request config-ref="HTTP_Request_Configuration" path="/service" method="GET" doc:name="Call external service" />
Reference :- https://developer.mulesoft.com/docs/display/current/HTTP+Request+Connector
After calling the external url from Mule flow, you will be getting the text as payload, which you can insert into database using your SQL query
Take a look at the Mule HTTP Endpoint.
I'm starting using Mule and have some trivial questions. Here one of them.
Suppose you store the address of a url to invoke later on a process on a property file.
Then you want to use an http endpoint specifying this url.
It works fine, you simply put in the address: ${URL_ADDRESS} and that's it.
Now if your url is calculated and set on a flowVar, why the following code does not work?
<http:outbound-endpoint exchange-pattern="request-response" method="GET" address="#[flowVars['URL_ADDRESS']]" doc:name="HTTP"/>
It throws this exception:
java.lang.IllegalArgumentException: Address '#[flowVars['URL_ADDRESS']]' for protocol 'http' should start with http://
Why is it checked at compilation time? How can I do to set it at runtime?
The protocol cannot be dynamic. You should change your outbound endpoint to <http:outbound-endpoint exchange-pattern="request-response" method="GET" address="http://#[flowVars['URL_ADDRESS']]" doc:name="HTTP"/>
you should use the flow variables in below format. Either #[FileName] or #[flowVars.FileName]