hystrix动态修改参数

Hystrix 从入门到深入——运行时修改动态配置

/**
 * 
 * @author zhangshuo
 *
 */
@Component
public class DynamicConfigSource implements PolledConfigurationSource {
  private static final Logger logger = LoggerFactory.getLogger(DynamicConfigSource.class);

  @Override
  public PollResult poll(boolean initial, Object checkPoint) throws Exception {
    Map<String, Object> complete = new HashMap<String, Object>();

    /**
     * 配置中心配置了对应的key/value。其中commandKey是我指定的具体接口。
     */
    complete.put("hystrix.command.commandKey.circuitBreaker.forceOpen",
        “具体配置,比如来自配置中心”);

    logger.debug("poll:{}", complete);

    return PollResult.createFull(complete);
  }
}

  

posted @ 2019-11-08 17:27  heroinss  阅读(1123)  评论(0编辑  收藏  举报