2017-03-03 170 views
0

我有2个mule应用程序在单个机器上运行,其中应用程序A向应用程序B发送获取请求,应用程序B连接到外部http应用程序以获取信息。基本上,应用程序B是一个重定向应用程序,它会在一天内多次抛出连接超时异常(java.net.SocketTimeoutException)。根据我的观察,每当应用程序(B)空闲一段时间,然后如果它接收到一个请求,就会在第一个请求连接超时时连接到出站http端点的外部服务器,并且后续请求正常工作。只发生在我没有调试访问权的环境中,并且我没有在任何其他env中遇到过这个问题,虽然有两个其他环境具有相同的确切设置。连接到外部服务器时Mule http出站端点的连接超时错误

任何帮助/建议/ guidence在调试问题时赞赏。 代码

<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&param2=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

添加了直到成功的循环到出站HTTP端点在我的应用程序B中,并正在工作,如果我单独访问它。但是,当应用程序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完成其重试并尝试发送回应用程式其获得错误的响应: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

您需要将HTTP/HTTPS连接器

<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> 
+0

Satheesh喜上使用untilSuccess,我implememted乌尔建议,但是我在运行中一些其他问题。我已经添加了细节。请看一看。 – KBSri

+0

嗨KBsri当您发送响应时连接超时增加应用程序A请求程序中的超时。 –

+0

感谢您的意见。但问题是,即使在应用程序B中处理完成之前,应用程序A已经将请求者的调度异常(它表示不能将事件路由到应用程序B)发送给请求者。我不明白为什么应用程序A在消息实际到达应用程序B时正在获取路由展开,并且正在处理该应用程序。 – KBSri