You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by na...@apache.org on 2010/10/26 14:41:13 UTC

svn commit: r1027517 - /tuscany/sca-java-1.x/trunk/demos/xml-bigbank/src/main/java/bigbank/AccountServiceImpl.java

Author: nash
Date: Tue Oct 26 12:41:12 2010
New Revision: 1027517

URL: http://svn.apache.org/viewvc?rev=1027517&view=rev
Log:
Merge r1003145 Add timeout for stock quote service invocation and improve handling of connectivity errors

Modified:
    tuscany/sca-java-1.x/trunk/demos/xml-bigbank/src/main/java/bigbank/AccountServiceImpl.java

Modified: tuscany/sca-java-1.x/trunk/demos/xml-bigbank/src/main/java/bigbank/AccountServiceImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/demos/xml-bigbank/src/main/java/bigbank/AccountServiceImpl.java?rev=1027517&r1=1027516&r2=1027517&view=diff
==============================================================================
--- tuscany/sca-java-1.x/trunk/demos/xml-bigbank/src/main/java/bigbank/AccountServiceImpl.java (original)
+++ tuscany/sca-java-1.x/trunk/demos/xml-bigbank/src/main/java/bigbank/AccountServiceImpl.java Tue Oct 26 12:41:12 2010
@@ -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 implemen
             // 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 {