我在一台机器上运行了2个骡子应用程序,其中应用程序A向应用程序B发送获取请求,应用程序B连接到外部http应用程序以获取信息。基本上,应用程序B是一个重定向应用程序,它在一天内多次抛出连接超时异常(java.net.SocketTimeoutException)。根据我的观察,只要应用程序(B)空闲一段时间就会发生这种情况,然后如果它收到请求,它会在连接到出站http端点上的外部服务器时抛出第一个请求的连接超时,后续请求工作正常。仅在我无法调试的一个环境中发生,并且我没有在任何其他环境中遇到此问题,尽管还有其他两个环境具有相同的设置。
在调试问题时,我们非常感谢您提供帮助/建议/指导。 代码
<flow name="Main" >
<https:inbound-endpoint exchange-pattern="request-response"
host="${http.listenHost}" port="${support-1.0.https.port}"
path="${service.root}" encoding="UTF-8"
doc:name="HTTP" connector-ref="HTTPSConnector">
<!-- NB: SECURITY TURNED OFF BY DEFAULT AS YOU WILL NEED TO ADD RECORDS
TO THE DATABASE IN ORDER TO USE THIS -->
<!-- <mule-ss:http-security-filter realm="mule-realm"/> -->
</https:inbound-endpoint>
<custom-interceptor class="xyz.BasicLogger">
<spring:property name="outermost" value="true" />
</custom-interceptor>
<set-session-variable variableName="operation" value="#[message.inboundProperties['http.method']]" doc:name="Operation"/>
<set-variable variableName="_logging.text" value="Incoming Payload" doc:name="Logging" />
<component doc:name="Payload Logger">
<spring-object bean="idPayloadLogger" />
</component>
<set-session-variable variableName="http.status"
value="200" doc:name="HTTP Status" />
<flow-ref name="Cache" doc:name="Cache"/>
<http:response-builder status="#[sessionVars['http.status']]" contentType="application/json" doc:name="HTTP Response Builder">
<http:header name="consumerTransId" value="#[sessionVars['tx.id']]"/>
<http:header name="http.status" value="#[sessionVars['http.status']]"/>
<http:header name="Content-Type" value="application/json;charset=utf-8"/>
</http:response-builder>
</flow>
<flow name="Cache">
<expression-transformer expression="#[payload]" doc:name="Create key for cache"/>
<custom-interceptor doc:name="PayloadCache" class="xyz.ehcache.PayloadCache"/>
<flow-ref name="GetResult" doc:name="GetResult"/>
</flow>
<sub-flow name="GetResult">
<choice doc:name="Choice">
<when expression="sessionVars.operation =='GET'">
<processor-chain doc:name="GET">
<set-variable variableName="_logging.calloutName " value="Registry GET" doc:name="_logging.calloutName "/>
<component doc:name="Java"><spring-object bean="idTimerLogger"/></component>
<http:outbound-endpoint exchange-pattern="request-response" host="${registry.host}" port="${registry.port}"
path="${registry.path}/#[message.inboundProperties.'http.relative.path']?#[message.inboundProperties.'http.query.string']" method="GET" doc:name="HTTP" responseTimeout="10000"/>
<component doc:name="Java"><spring-object bean="idTimerLogger"/></component>
</processor-chain>
</when>
<when expression="sessionVars.operation =='DELETE'">
<processor-chain doc:name="DELETE">
<set-variable variableName="_logging.calloutName " value="Registry DELETE" doc:name="_logging.calloutName "/>
<component doc:name="Java"><spring-object bean="idTimerLogger"/></component>
<http:outbound-endpoint exchange-pattern="request-response" host="${registry.host}" port="${registry.port}" path="${registry.path}/#[message.inboundProperties.'http.relative.path']?#[message.inboundProperties.'http.query.string']"
method="DELETE" doc:name="HTTP"/>
<component doc:name="Java"><spring-object bean="idTimerLogger"/></component>
</processor-chain>
</when>
<otherwise>
<processor-chain doc:name="Unsupported Verb">
<set-variable variableName="_error.code" value="2" doc:name="Error code"/>
<custom-transformer class="xyz.eai.utility.transformation.ErrorMessageTransformer" doc:name="Java"/>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</processor-chain>
</otherwise>
</choice>
<object-to-string-transformer doc:name="Object to String"/>
</sub-flow>
</mule>
,错误是“
Exception stack is:
1. connect timed out (java.net.SocketTimeoutException)
java.net.PlainSocketImpl:-2 (null)
2. The host did not accept the connection within timeout of 2000 ms (org.apache.commons.httpclient.ConnectTimeoutException)
org.apache.commons.httpclient.protocol.ReflectionSocketFactory:155 (null)
3. Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=http://xyz.ca.com:8080/search?param1=xyz¶m2=true, connector=HttpConnector
{
name=connector.http.mule.default
lifecycle=start
this=59c02565
numberOfConcurrentTransactedReceivers=4
createMultipleTransactedReceivers=true
connected=true
supportedProtocols=[http]
serviceOverrides=<none>
}
, name='endpoint.http.xyz.com.8080.search.param1.xyz.param2.true', mep=REQUEST_RESPONSE, properties={isActive=true, http.method=GET, exceptionOnMessageError=true, param1=xyz}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: GetMethod (org.mule.api.transport.DispatchException)
org.mule.transport.http.HttpClientMessageDispatcher:151 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)`
################ 3
在我的应用B中向出站http端点添加了一个直到成功的循环,如果我单独访问它,它正在工作。但是当应用程序A尝试与应用程序B通信时,甚至在应用程序B尝试连接到外部服务器并返回响应之前,应用程序A上的http出站端点正在抛出org.mule.api.transport.DispatchException with message : Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=https://application-b/xyz, connector=HttpsConnector
,当应用程序B完成其重试并尝试将响应发送回应用A以获取错误:org.mule.transport.http.HttpsMessageProcessTemplate: Exception sending http response after error: Connection has been shutdown: javax.net.ssl.SSLException: java.net.SocketException: Software caused connection abort: socket write error
答案 0 :(得分:0)
您需要在HTTP / HTTPS连接器上使用 untilSuccess
<until-successful maxRetries="5" synchronous="true" doc:name="Until Successful">
<http:request config-ref="HTTP_Request_Configuration" path="/test" method="POST" doc:name="HTTP"/>
</until-successful>