【问题标题】:wso2 ESB: Clone and Aggregate timed outwso2 ESB:克隆和聚合超时
【发布时间】:2014-07-08 09:31:05
【问题描述】:

我尝试在 WSO2 ESB 中同时使用代理和 API 来测试将类似 SOAP Web 服务聚合到一个响应中,但我只是遇到了超时。为了进行测试,我使用了 Weather Web 服务 (http://wsf.cdyne.com/WeatherWS/Weather.asmx?wsdl)。我基本上通过使用克隆调解器为每个操作提供不同的邮政编码,然后汇总结果来调用相同的操作 GetCityWeatherByZIP 两次。最终的目的是调用托管在不同服务器上的 Web 服务,但目前我试图使用相同的服务。如果能得到任何帮助,我将不胜感激。

以下是代理配置:

 <?xml version="1.0" encoding="UTF-8"?>
   <proxy xmlns="http://ws.apache.org/ns/synapse"
       name="aggre"
       transports="http"
       statistics="disable"
       trace="enable"
       startOnLoad="true">
      <target>
      <inSequence>
         <clone>
            <target>
               <sequence>
                  <payloadFactory media-type="xml">
                     <format>
                        <m0:GetCityWeatherByZIP xmlns:m0="http://ws.cdyne.com/WeatherWS/">
                           <m0:ZIP>11001</m0:ZIP>
                        </m0:GetCityWeatherByZIP>
                     </format>
                     <args/>
                  </payloadFactory>
                  <header name="Action" scope="default" value="urn:GetCityWeatherByZIP "/>
                  <call>
                     <endpoint key="weather"/>
                  </call>
               </sequence>
            </target>
            <target>
               <sequence>
                  <payloadFactory media-type="xml">
                     <format>
                        <m0:GetCityWeatherByZIP xmlns:m0="http://ws.cdyne.com/WeatherWS/">
                           <m0:ZIP>11010</m0:ZIP>
                        </m0:GetCityWeatherByZIP>
                     </format>
                     <args/>
                  </payloadFactory>
                  <header name="Action" scope="default" value="urn:GetCityWeatherByZIP "/>
                  <call>
                     <endpoint key="weather"/>
                  </call>
               </sequence>
            </target>
         </clone>
         <aggregate>
            <completeCondition>
               <messageCount min="-1" max="-1"/>
            </completeCondition>
            <onComplete xmlns:m0="http://ws.cdyne.com/WeatherWS"
                        expression="/m0:GetCityWeatherByZIPResponse">
               <drop/>
            </onComplete>
         </aggregate>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
      </target>
      <description/>
   </proxy>

以下是天气端点配置:

 <endpoint xmlns="http://ws.apache.org/ns/synapse" name="weather">
   <address uri="http://wsf.cdyne.com/WeatherWS/Weather.asmx" format="soap11">
      <suspendOnFailure>
         <progressionFactor>1.0</progressionFactor>
      </suspendOnFailure>
      <markForSuspension>
         <retriesBeforeSuspension>0</retriesBeforeSuspension>
         <retryDelay>0</retryDelay>
      </markForSuspension>
   </address>
</endpoint>

碳原木:

TID: [0] [ESB] [2014-07-08 11:10:44,377]  INFO {org.apache.axis2.transport.http.HTTPSender} -  Unable to sendViaPost to url[http://servername:8281/services/aggre.aggreHttpSoap11Endpoint] {org.apache.axis2.transport.http.HTTPSender}
java.net.SocketTimeoutException: Read timed out
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:150)
    at java.net.SocketInputStream.read(SocketInputStream.java:121)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:254)
    at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78)
    at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106)
    at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116)
    at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1413)
    at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973)
    at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735)
    at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)
    at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
    at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
    at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:622)
    at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:193)
    at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
    at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:451)
    at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:278)
    at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
    at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:430)
    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225)
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
    at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:554)
    at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:530)
    at org.apache.jsp.admin.jsp.WSRequestXSSproxy_005fajaxprocessor_jsp._jspService(org.apache.jsp.admin.jsp.WSRequestXSSproxy_005fajaxprocessor_jsp:276)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:403)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
    at org.wso2.carbon.ui.JspServlet.service(JspServlet.java:155)
    at org.wso2.carbon.ui.TilesJspServlet.service(TilesJspServlet.java:80)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
    at org.eclipse.equinox.http.helper.ContextPathServletAdaptor.service(ContextPathServletAdaptor.java:37)
    at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
    at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:128)
    at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:68)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
    at org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.service(DelegationServlet.java:68)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.wso2.carbon.tomcat.ext.filter.CharacterSetFilter.doFilter(CharacterSetFilter.java:61)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.wso2.carbon.tomcat.ext.valves.CompositeValve.continueInvocation(CompositeValve.java:178)
    at org.wso2.carbon.tomcat.ext.valves.TomcatValveContainer.invokeValves(TomcatValveContainer.java:49)
    at org.wso2.carbon.tomcat.ext.valves.CompositeValve.invoke(CompositeValve.java:141)
    at org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:156)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
    at org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:52)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1653)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)
TID: [0] [ESB] [2014-07-08 11:10:44,420]  WARN {org.apache.synapse.transport.passthru.SourceHandler} -  Connection time out after request is read: http-incoming-295 {org.apache.synapse.transport.passthru.SourceHandler}   

【问题讨论】:

    标签: soap wso2 clone aggregate esb


    【解决方案1】:

    SOAP Action 不正确,必须是http://ws.cdyne.com/WeatherWS/GetCityWeatherByZIP

    聚合的 onComplete xpath 表达式的命名空间不正确,末尾缺少“/”:http://ws.cdyne.com/WeatherWS/

    聚合后,您不想丢弃消息,而是希望将其作为响应发送:在“onComplete”中介中将&lt;drop/&gt; 替换为&lt;send/&gt;

    响应将是一个肥皂消息,并且 SOAP Body 必须有一个根节点作为第一个子节点,因此您必须应用转换,例如:

    <payloadFactory media-type="xml">
      <format>
        <response>
          $1
         </response>
      </format>
      <args>
        <arg evaluator="xml" xmlns:m0="http://ws.cdyne.com/WeatherWS/" expression="//m0:GetCityWeatherByZIPResponse"/>
      </args>
    </payloadFactory>
    

    默认情况下,克隆中介停止父中介,如果要执行聚合,需要指定continueParent="true"

    使用调用中介,下划线工作线程返回而不等待响应:用于执行代理的请求将到达您的聚合:在执行聚合中介之前,测试消息是否为 GetCityWeatherByZIPResponse

    完整的代理:

    <?xml version="1.0" encoding="UTF-8"?>
       <proxy xmlns="http://ws.apache.org/ns/synapse"
           name="TestSOF"
           transports="http"
           statistics="disable"
           trace="enable"
           startOnLoad="true">
          <target>
          <inSequence>
             <clone continueParent="true">
                <target>
                   <sequence>
                      <payloadFactory media-type="xml">
                         <format>
                            <m0:GetCityWeatherByZIP xmlns:m0="http://ws.cdyne.com/WeatherWS/">
                               <m0:ZIP>11001</m0:ZIP>
                            </m0:GetCityWeatherByZIP>
                         </format>
                         <args/>
                      </payloadFactory>
                      <header name="Action" scope="default" value="http://ws.cdyne.com/WeatherWS/GetCityWeatherByZIP"/>
                      <call>
                         <endpoint key="weather"/>
                      </call>
                   </sequence>
                </target>
                <target>
                   <sequence>
                      <payloadFactory media-type="xml">
                         <format>
                            <m0:GetCityWeatherByZIP xmlns:m0="http://ws.cdyne.com/WeatherWS/">
                               <m0:ZIP>11010</m0:ZIP>
                            </m0:GetCityWeatherByZIP>
                         </format>
                         <args/>
                      </payloadFactory>
                      <header name="Action" scope="default" value="http://ws.cdyne.com/WeatherWS/GetCityWeatherByZIP"/>
                      <call>
                         <endpoint key="weather"/>
                      </call>
                   </sequence>
                </target>
             </clone>
             <filter source="local-name($body/*[1])" regex="GetCityWeatherByZIPResponse">
                <then>
                     <aggregate>
                        <completeCondition>
                           <messageCount min="-1" max="-1"/>
                        </completeCondition>
                        <onComplete xmlns:m0="http://ws.cdyne.com/WeatherWS/"
                                    expression="//m0:GetCityWeatherByZIPResponse">
                            <payloadFactory media-type="xml">
                                <format>
                                   <response>
                                    $1
                                   </response>
                                </format>
                                <args>
                                   <arg evaluator="xml" xmlns:m0="http://ws.cdyne.com/WeatherWS/" expression="//m0:GetCityWeatherByZIPResponse"/>
                                </args>
                             </payloadFactory>
                             <send/>
                        </onComplete>
                     </aggregate>
                </then>
            </filter>
          </inSequence>
          <outSequence>
             <send/>
          </outSequence>
          </target>
          <description/>
       </proxy>
    

    端点:

    <?xml version="1.0" encoding="UTF-8"?>
    <endpoint xmlns="http://ws.apache.org/ns/synapse" name="weather">
       <wsdl service="Weather"
             port="WeatherSoap"
             uri="http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL"/>
    </endpoint>
    

    我得到的回应:

    <response xmlns="http://ws.apache.org/ns/synapse">
    <GetCityWeatherByZIPResponse xmlns="http://ws.cdyne.com/WeatherWS/">
    <GetCityWeatherByZIPResult>
    <Success>true</Success>
    <ResponseText>City Found</ResponseText>
    <State>NY</State>
    <City>Franklin Square</City>
    <WeatherStationCity>Farmingdale</WeatherStationCity>
    <WeatherID>14</WeatherID>
    <Description>Cloudy</Description>
    <Temperature>73</Temperature>
    <RelativeHumidity>78</RelativeHumidity>
    <Wind>S6</Wind>
    <Pressure>29.75R</Pressure>
    <Visibility/>
    <WindChill/>
    <Remarks/>
    </GetCityWeatherByZIPResult>
    </GetCityWeatherByZIPResponse>
    <GetCityWeatherByZIPResponse xmlns="http://ws.cdyne.com/WeatherWS/">
    <GetCityWeatherByZIPResult>
    <Success>true</Success>
    <ResponseText>City Found</ResponseText>
    <State>NY</State>
    <City>Floral Park</City>
    <WeatherStationCity>Farmingdale</WeatherStationCity>
    <WeatherID>14</WeatherID>
    <Description>Cloudy</Description>
    <Temperature>73</Temperature>
    <RelativeHumidity>78</RelativeHumidity>
    <Wind>S6</Wind>
    <Pressure>29.75R</Pressure>
    <Visibility/>
    <WindChill/>
    <Remarks/>
    </GetCityWeatherByZIPResult>
    </GetCityWeatherByZIPResponse>
    </response>
    

    【讨论】:

    • 非常感谢。它有效,您帮助我了解我做错了什么:)
    • 我在做同样的事情,但是我在克隆中使用了两个不同的端点。我使用了呼叫调解员,它甚至没有进入顺序。它正在浪费时间..你能帮我吗??
    • 用 SoapUI 试试看是否得到响应并测量响应时间
    【解决方案2】:

    调用中介依赖于非阻塞传输:编辑 repository/conf/nhttp.properties 并添加 http.socket.timeout.sender=60000 如果您同意等待 60 秒

    【讨论】:

    • 谢谢,但我做了配置更改,它仍然超时。 Tbh,我不一定需要使用呼叫调解器。但是我尝试在有和没有发送或呼叫的情况下使用克隆;我也尝试将聚合放在 outsequence 中。但无论我做什么,我都会一直暂停。这很奇怪,因为当使用 Payload factory 和 Send(没有克隆和聚合)调用一次天气 Web 服务时,我会在几秒钟内得到响应。所以这里有一些非常错误的地方,我找不到。我还能做什么?
    猜你喜欢
    • 2015-05-05
    • 2015-04-29
    • 1970-01-01
    • 2015-02-19
    • 1970-01-01
    • 1970-01-01
    • 2014-04-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多