--- android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureServlet.java 2009/09/27 19:14:39 348 +++ android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureServlet.java 2009/10/20 10:32:19 451 @@ -24,6 +24,7 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; +import dk.thoerup.curcuitbreaker.CircuitBreakerException; import dk.thoerup.traininfoservice.DBConnection; /** @@ -39,6 +40,7 @@ DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); + @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { int station = Integer.parseInt( req.getParameter("station") ); String format = req.getParameter("format"); @@ -48,12 +50,16 @@ String stationName = getStationName(station); try { - beans = fetcher.lookupDepartures(station); + beans = fetcher.cachedLookupDepartures(station); } catch (java.net.SocketTimeoutException ste) { logger.warning("Read timed out, station="+station); resp.sendError(500); return; - } catch (Exception e) { + } catch (CircuitBreakerException cbe) { + logger.warning("Circuitbreaker - failing fast"); + resp.sendError(500); + return; + } catch (Exception e) { logger.log(Level.WARNING, "Unknown exception, station=" +station, e); resp.sendError(500); return;