美文网首页
RocketMQ---控制Broker心跳时间在10到60秒

RocketMQ---控制Broker心跳时间在10到60秒

作者: 奔跑的Robi | 来源:发表于2019-10-22 22:53 被阅读0次

From:
BrokerController start()

 this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {

            @Override
            public void run() {
                try {
                    BrokerController.this.registerBrokerAll(true, false, brokerConfig.isForceRegister());
                } catch (Throwable e) {
                    log.error("registerBrokerAll Exception", e);
                }
            }
        }, 1000 * 10, Math.max(10000, Math.min(brokerConfig.getRegisterNameServerPeriod(), 60000)), TimeUnit.MILLISECONDS);

Math.max(10000, Math.min(brokerConfig.getRegisterNameServerPeriod(), 60000))

上面这一句直接控制了中间的自定义值的范围,避免了大量的if判断

相关文章

网友评论

      本文标题:RocketMQ---控制Broker心跳时间在10到60秒

      本文链接:https://www.haomeiwen.com/subject/tsocvctx.html