diff options
author | nash <nash@13f79535-47bb-0310-9956-ffa450edef68> | 2010-09-30 16:34:08 +0000 |
---|---|---|
committer | nash <nash@13f79535-47bb-0310-9956-ffa450edef68> | 2010-09-30 16:34:08 +0000 |
commit | fd91059b4edb58814dc1848e51f43b1a78979497 (patch) | |
tree | 76a9ff06683d3b969238966d8d284117d09338ee /sca-java-1.x/branches/sca-java-1.6.1/demos/xml-bigbank/src/main | |
parent | c88df04dcba6249959cbd5fcc5920539f14517ac (diff) |
Add timeout for stock quote service invocation and improve handling of connectivity errors
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1003145 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-1.x/branches/sca-java-1.6.1/demos/xml-bigbank/src/main')
-rw-r--r-- | sca-java-1.x/branches/sca-java-1.6.1/demos/xml-bigbank/src/main/java/bigbank/AccountServiceImpl.java | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/sca-java-1.x/branches/sca-java-1.6.1/demos/xml-bigbank/src/main/java/bigbank/AccountServiceImpl.java b/sca-java-1.x/branches/sca-java-1.6.1/demos/xml-bigbank/src/main/java/bigbank/AccountServiceImpl.java index c2d0e8ab01..2420c4eba0 100644 --- a/sca-java-1.x/branches/sca-java-1.6.1/demos/xml-bigbank/src/main/java/bigbank/AccountServiceImpl.java +++ b/sca-java-1.x/branches/sca-java-1.6.1/demos/xml-bigbank/src/main/java/bigbank/AccountServiceImpl.java @@ -28,6 +28,7 @@ import org.apache.axiom.om.OMElement; import org.apache.log4j.Level; import org.apache.log4j.LogManager; import org.apache.log4j.spi.LoggerRepository; +import org.apache.tuscany.sca.binding.ws.axis2.Axis2BindingInvoker; import org.osoa.sca.ServiceRuntimeException; import org.osoa.sca.annotations.Property; import org.osoa.sca.annotations.Reference; @@ -76,19 +77,17 @@ public class AccountServiceImpl implements AccountService { // first try to get a live stock quote from the web service String xml = null; try { + // set a small timeout value in case the server doesn't respond + Axis2BindingInvoker.GLOBAL_AXIS_TIMEOUT = 8000L; + OMElement quotes = stockQuote.GetQuote(request); xml = quotes.getText(); if (!xml.startsWith("<")) { System.out.println("Server responded: " + xml); throw new IllegalStateException("Unexpected response from server"); } - } catch (Exception e) { - if (e.getMessage().contains("Transport error: 503")) { - // server is down, use local historical data - } else { - // report any other errors - throw e; - } + } catch (ServiceRuntimeException e) { + // server isn't available, use local historical data // restore the previous logging setting } finally { |