title: Fallback methods at Zuul server in Spring cloud
body: <p>I am new in Spring Cloud Netflix and have some questions concerning it.<br>
  I am using the API Gateway together with Hystrix running at Zuul edge server and I would like to make sure if I understand the following behavior correctly:</p>
  
  <p>I kill a microservice running "behind" API Gateway then I force hystrix to open the circuit. After that (ca 10 seconds) I send a request to the non-running microservice and receive TIMEOUT error. However when I send many (tens) of requests in a very short time (up to 1 sec), I receive SHORTCIRCUIT OPEN error.<br>
  I was surprised why I receive TIMEOUT error although the circuit is open and therefore hystrix should come to play to avoid such kind of failures. But I guess the reason is that if time since last request > circuitBreaker.sleepWindowInMilliseconds, then the API Gateway tries to connect to the microservice  again to check if it's alive, but it wasn't, thus -> TIMEOUT. That would also explain, why I got SHORTCIRCUIT OPEN error on many requests in short time.  </p>
  
  <p>The next thing is that as I receive "TIMEOUT" or "SHORTCIRCUIT" error I got:</p>
  
  <pre><code>HystrixRuntimeException: Microservice (timed-out | short-circuited) and no fallback available
  </code></pre>
  
  <p>How can I specify a fallback at zuul server (this can be the same for all routes) to avoid this exception ?<br>
  What I have tried until now:  </p>
  
  <ul>
  <li><p>According <a href="https://github.com/spring-cloud/spring-cloud-netflix/issues/595" rel="nofollow">this</a> to I set execution isolation strategy to THREAD
  to avoid time-out:</p>
  
  <p>hystrix:
    command.default.execution.isolation.strategy: THREAD</p></li>
  </ul>
  
  <p>but after looking at the hystrix.stream I got <code>propertyValue_executionIsolationStrategy":"SEMAPHORE"</code></p>
  
  <ul>
  <li>There seems to be a hint for solution on <a href="https://github.com/spring-cloud/spring-cloud-netflix/issues/250" rel="nofollow">github</a> by writing a custom RibbonCommand and overriding getFallback(), but after looking at <a href="https://github.com/spring-cloud/spring-cloud-netflix/blob/master/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/route/RibbonCommand.java" rel="nofollow">RibbonCommand</a> interface. I found out, that neither RibbonCommand nor its super interfaces doesn't define such a method.</li>
  </ul>
  
  <p>My API Gateway service:</p>
  
  <pre><code>@SpringBootApplication
  @EnableSidecar // This annotation includes @EnableCircuitBreaker, @EnableDiscoveryClient, and @EnableZuulProxy
  @EnableHystrixDashboard
  public class ApiGatewayApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(ApiGatewayApplication.class, args);
      }
  
  }
  </code></pre>
  
  <p>application.yml</p>
  
  <pre><code>server:
    port: 10000
  sidecar:
    port: 8000
  endpoints:
    restart:
      enabled: true
    shutdown:
      enabled: true
    health:
      sensitive: false
  eureka:
    client:
      registerWithEureka: true
      fetchRegistry: true
      serviceUrl:
        defaultZone: http://localhost:8761/eureka/
  zuul:
    routes:
      microservice:
        path: /microservice/**
  
  hystrix:
    command.default.execution.isolation.strategy: THREAD
  
  debug: true
  </code></pre>