title: Hystrix configuration for circuit breaker in Java
body: <p>I am writing an application and I want to implement <a href="https://en.wikipedia.org/wiki/Circuit_breaker_design_pattern" rel="nofollow noreferrer"><em>circuit breaker</em></a> pattern. This is the Hystrix Command class I have written:</p>
  
  <pre><code>public class HystrixCommandNextGen extends HystrixCommand&lt;ScriptContext&gt; {
  
      private ScriptContext scriptctx;
      private ScriptFactory scriptFactory;
      private ScriptContext responseContext = null;
  
      private Logger logger = LoggerFactory.getLogger(HystrixCommandNextGen.class);
  
      public HystrixCommandNextGen(ScriptContext scriptctx, ScriptFactory scriptFactory) {
          super(
              Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("Thread_Pool"))
              .andCommandKey(HystrixCommandKey.Factory.asKey(scriptctx.getExecutionData(ExecutionParam.SCRIPTNAME)))
          );
          this.scriptctx = scriptctx;
          this.scriptFactory = scriptFactory;
  
          HystrixCommandProperties.Setter().withCircuitBreakerEnabled(true);
          HystrixCommandProperties.Setter().withCircuitBreakerRequestVolumeThreshold(150);
      }
  
      @Override
      protected ScriptContext run() throws Exception {
          scriptFactory.execute(scriptctx);
          return scriptctx;
      }
  
      @Override
      protected ScriptContext getFallback() {
          logger.error("FI is not responding: Error occurred in the execution of " + getClass().getSimpleName());
          return scriptctx;
      }
  }
  </code></pre>
  
  <p>I am not able to understand how to configure the number of threads, threshold time for circuit breaker and number of requests to handle.</p>