【发布时间】:2015-02-25 18:45:21
【问题描述】:
我有一个 esb,我从中进行 web 服务调用,大多数情况下都可以正常工作,但有时我会遇到以下异常
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)
奇怪的是在我得到这个异常之后,有时http出站调用仍然成功,有时没有成功
为什么这不一致?
mule http 连接器上的某些配置是否有可能帮助这种异常情况保持一致?
我要问的是...如何在引发读取超时异常后停止处理 http 出站请求?
流程如下所示
<queued-asynchronous-processing-strategy name="allow2Threads" maxThreads="2"/>
<flow name="TestFlow" processingStrategy="allow2Threads">
<vm:inbound-endpoint path="performWebserviceLogic" exchange-pattern="one-way" />
.... some transformation logic
....
<http:outbound-endpoint address="http://localhost:8080/firstwebservicecall" responseTimeout="65000" exchange-pattern="request-response"/>
....
.... some transformation logic on response...
<http:outbound-endpoint address="http://localhost:8080/secondWeberviceCall" responseTimeout="20000" exchange-pattern="request-response"/>
......some transformation logic on response...
<catch-exception-strategy>
<choice>
<when expression="#[groovy:message.getExceptionPayload().getRootException.getMessage().equals('Read timed out') and message.getSessionProperty('typeOfCall').equals('firstWeberviceCall')]">
.... unreliable ...result... as firstWeberviceCall may succeed even after the control comes here
and if we process http://localhost:8080/firstwebservicecall .. the transaction takes place twice... as already it succeeded above even after an exception is thrown
</when>
<when expression="#[groovy:message.getExceptionPayload().getRootException.getMessage().equals('Read timed out') and message.getSessionProperty('typeOfCall').equals('secondWeberviceCall')]">
..... reliable ... if control comes here and if we process http://localhost:8080/secondWeberviceCall .. the transaction takes place only once
</when>
<when expression="#[groovy:message.getExceptionPayload().getRootException.getMessage().equals('Connect timed out') and message.getSessionProperty('typeOfCall').equals('firstWeberviceCall')]">
....reliable
</when>
<when expression="#[groovy:message.getExceptionPayload().getRootException.getMessage().equals('Connect timed out') and message.getSessionProperty('typeOfCall').equals('secondWeberviceCall')]">
....reliable
</when>
</choice>
</catch-exception-strategy>
</flow>
【问题讨论】:
-
你能分享你的流程配置吗?获取上下文会更容易。
-
你检查每个
http:outbound-endpoint之后收到的状态码吗? -
我没有检查它.. 但我猜它应该是 500,因为它落在了 catch 块中.. 但是当我检查数据库时,出站调用证明是成功的.. 所以我没有处理 firstwebservicecall再次在解决业务逻辑的 catch 块中......但从技术上讲,我觉得它是错误的......
-
如果我理解正确,
readTimeOut发生在您的firstwebservicecall和secondWeberviceCall成功。对吗?