java怎么断路_用于Java中断路器的Hystrix配置

我正在编写一个应用程序,我想实现

circuit breaker模式.这是我写的Hystrix Command类:

public class HystrixCommandNextGen extends HystrixCommand {

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;

}

}

我无法理解如何配置线程数,断路器的阈值时间和要处理的请求数.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值