mule async flow ws call导致读取超时

时间:2014-06-13 07:35:56

标签: java web-services mule mule-studio

我有一个问题要问。 我的情况是这样的:我有一个quartz:inbound-endpoint,触发我的自定义变换器ContractStarter。这个变换器内部有一个web服务调用webService.doStuf()。虽然它是在异步范围内声明的,但是当ws响应时间过长时,我会获得SocketTimeoutException:Read timed out。 我想要的是 - 使这个调用作为异步范围,而不等待响应并且不会导致超时异常,因为响应并不重要。

我的xml看起来像

http:endpoint  name="httpIn"  address="${service.proxy.soap}" responseTimeout="30000" exchange-pattern="one-way" />
http:endpoint  name="httpOut"  address="${service.soap}" responseTimeout="30000" exchange-pattern="one-way" />

<pattern:web-service-proxy 
    name="muleServiceProxy" 
    inboundEndpoint-ref="httpIn" 
    outboundEndpoint-ref="httpOut" />

<spring:bean name="contractStarter" class="com.mule.scheduler.ContractStarter">
    <spring:property name="webService" ref="realWebService"></spring:property>
</spring:bean>

<queued-asynchronous-processing-strategy name="allowFiveThread" maxThreads="30" />

<flow name="contractQuartzScheduler">
    <quartz:inbound-endpoint startDelay="3000" jobName="contractBecome" cronExpression="0 0/2 7-23 * * ?">
        <quartz:event-generator-job/>
    </quartz:inbound-endpoint>
    <async processingStrategy="allowFiveThread">
    <component>
        <spring-object bean="contractStarter"/>
    </component>
    </async>
</flow>

服务&#34; webservice&#34;定义为:

 jaxws:client id="realWebService" serviceClass="com.wsdl._2011.WebService" address="${httpIn}"

我的自定义变压器合同启动器是:

public class ContractStarter implements Callable {

private static Logger log = Logger.getLogger(ContractStarter.class);

private WebService webService;


@Override
public Object onCall(MuleEventContext arg0) throws Exception {
    try {
        log.info("Starting ContractStarter");

        Header requestHeader = JAXBStubsUtil.createHeader(new Date().toString(), "starContract", "MULE");
        Holder<Header> responseHeader = new Holder<Header>();
        MyRequestMessage request = new MyRequestMessage();
        Holder<MyResponseMessage> response = new Holder<MyResponseMessage>();
        webService.doStuff(requestHeader, request, responseHeader, response);
        return response;
    } catch (Exception e) {
        log.error(e,e);
        throw e;
    }
}

异常堆栈是:

异常堆栈是:

1. Read timed out (java.net.SocketTimeoutException)
  java.net.SocketInputStream:-2 (null)
2. Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=http://localhost:8080/WebService, connector=HttpConnector
{
  name=HttpConnector1
  lifecycle=start
  this=5025536c
  numberOfConcurrentTransactedReceivers=4
  createMultipleTransactedReceivers=true
  connected=true
  supportedProtocols=[http]
  serviceOverrides=<none>
}
--------------------------------------------------------------------------------
Root Exception stack trace:
java.net.SocketTimeoutException: Read timed out
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:129)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

ERROR 2014-06-13 09:36:28,514 [[mule-axioma-services].ContractStarterScheduler.async1.01] com.mule.scheduler.ContractStarter: javax.xml.ws.soap.SOAPFaultException: Error reading XMLStreamReader.
javax.xml.ws.soap.SOAPFaultException: Error reading XMLStreamReader.
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:146)
    at $Proxy85.doBatch(Unknown Source)
    at com.mule.scheduler.ContractStarter.onCall(ContractStarter.java:52)
    at org.mule.model.resolvers.CallableEntryPointResolver.invoke(CallableEntryPointResolver.java:50)
    at org.mule.model.resolvers.DefaultEntryPointResolverSet.invoke(DefaultEntryPointResolverSet.java:39)
    at org.mule.component.DefaultComponentLifecycleAdapter.invoke(DefaultComponentLifecycleAdapter.java:350)
    at org.mule.component.AbstractJavaComponent.invokeComponentInstance(AbstractJavaComponent.java:86)
    at org.mule.component.AbstractJavaComponent.doInvoke(AbstractJavaComponent.java:77)
    at org.mule.component.AbstractComponent.invokeInternal(AbstractComponent.java:126)
    at org.mule.component.AbstractComponent.access$000(AbstractComponent.java:61)
    at org.mule.component.AbstractComponent$1$1.process(AbstractComponent.java:242)
    at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:99)
    at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:64)
    at org.mule.processor.chain.InterceptingChainLifecycleWrapper.doProcess(InterceptingChainLifecycleWrapper.java:56)
    at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:64)
    at org.mule.processor.chain.InterceptingChainLifecycleWrapper.process(InterceptingChainLifecycleWrapper.java:87)
    at org.mule.component.AbstractComponent.process(AbstractComponent.java:160)
    at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:99)
    at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:64)
    at org.mule.processor.chain.InterceptingChainLifecycleWrapper.doProcess(InterceptingChainLifecycleWrapper.java:56)
    at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:64)
    at org.mule.processor.chain.InterceptingChainLifecycleWrapper.process(InterceptingChainLifecycleWrapper.java:87)
    at org.mule.processor.AbstractInterceptingMessageProcessorBase.processNext(AbstractInterceptingMessageProcessorBase.java:105)
    at org.mule.interceptor.AbstractEnvelopeInterceptor.process(AbstractEnvelopeInterceptor.java:55)
    at org.mule.processor.AsyncInterceptingMessageProcessor.processNextTimed(AsyncInterceptingMessageProcessor.java:111)
    at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker.doRun(AsyncInterceptingMessageProcessor.java:158)
    at org.mule.work.AbstractMuleEventWork.run(AbstractMuleEventWork.java:43)
    at org.mule.work.WorkerContext.run(WorkerContext.java:310)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'F' (code 70) in prolog; expected '<'
 at [row,col {unknown-source}]: [1,1]
    at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:644)
    at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2003)
    at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1100)
    at com.ctc.wstx.sr.BasicStreamReader.nextTag(BasicStreamReader.java:1123)
    at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:122)
    at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:60)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:255)
    at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:755)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:2330)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:2192)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:2036)
    at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
    at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:696)
    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:255)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:516)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:313)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:265)
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124)
    ... 30 more

1 个答案:

答案 0 :(得分:0)

好吧,经过一段时间的尝试使其在骡子和失败中作为异步流程工作之后,我用标准的异步Web服务方法解决了这个问题。感谢大卫的帮助,感谢您的时间。