• 定时任务集群部署


    <dubbo:monitor protocol="registry"/>
    <dubbo:application name="oolp">
    <!--设置dubbo优雅停机,超时30秒,缺省为10秒-->
    <dubbo:parameter key="shutdown.timeout" value="30000"/>
    </dubbo:application>
    <!-- 注册中心的ip地址 -->
    <dubbo:registry protocol="zookeeper" address="${zkservers}"/>
    <!--&lt;!&ndash; 扫描注解包路径,多个包用逗号分隔,不填pacakge表示扫描当前ApplicationContext中所有的类 &ndash;&gt;-->
    <dubbo:annotation package="com.hispeed.teamcontract.service.impl" />
    <dubbo:consumer check="false" retries="0" timeout="12000"/>
    <dubbo:protocol name="dubbo" port="20789"/>
    <!--<dubbo:provider delay="-1" timeout="6000" retries="0"/>-->
    <dubbo:provider timeout="12000" retries="0"/>
    @Configuration
    @ImportResource({ "classpath:config/*.xml" })
    public class DubboConfig {
    }


    private ZKLeaderLatch zkLeaderLatch;

    @Autowired
    public ScheduledTaskServiceImpl(ZKLeaderLatch zkLeaderLatch) {
    this.zkLeaderLatch = zkLeaderLatch;
    }

    @Scheduled(fixedRate = 1 * 60 * 1000)
    @Override
    public void teamContractScheduledTask() {
    if(this.zkLeaderLatch.isLeader()){
        //定时执行任务
      }
    }
    com.boot.zookeeper.ZKLeaderLatch-|-[leaderLatch start....]
  • 相关阅读:
    ....
    CodeForces 375A(同余)
    POJ 2377 Bad Cowtractors (最小生成树)
    POJ 1258 AgriNet (最小生成树)
    HDU 1016 Prime Ring Problem(全排列)
    HDU 4460 Friend Chains(bfs)
    POJ 2236 Wireless Network(并查集)
    POJ 2100 Graveyard Design(尺取)
    POJ 2110 Mountain Walking(二分/bfs)
    CodeForces 1059B Forgery(模拟)
  • 原文地址:https://www.cnblogs.com/liangmm/p/11652031.html
Copyright © 2020-2023  润新知