zoukankan      html  css  js  c++  java
  • springcloud集成 xxl-job

    这两天做了公司项目集成xxl-job,记录一下

    xxl-job-admin调度中心直接移植,在pom里引入一下core的依赖,我用了最新的版本

    <dependency>
      <groupId>com.xuxueli</groupId>
      <artifactId>xxl-job-core</artifactId>
      <version>2.1.2</version>
    </dependency>

    执行器参考了 springboot的示例,引入一下core依赖.

    项目使用eureka作为注册中心,从eureka获取调度中心的地址,所以修改了一下yml 和 XxlJobConfig

    xxl:
      job:
        executor:
          logpath: /home/jar/public/job-service/log/jobhandler
          appname: yurun-job
          port: -1
          logretentiondays: 10
          ip:
        # 调度中心 eureka服务
        admin:
          addresses: job-admin-service
        accessToken:
    XxlJobConfig
       @Bean
        public XxlJobSpringExecutor xxlJobExecutor() {
            logger.info(">>>>>>>>>>> xxl-job config init.");
            XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
    
            //服务发现 从eureka拉取服务  dll
            List<String> urls = Lists.newArrayList();
            List<ServiceInstance> instances = discoveryClient.getInstances(adminAddresses);
            if(StringUtils.isNotEmpty(instances)) {
                instances.forEach(serviceInstance->{
                    urls.add("http://"+ serviceInstance.getHost() + ":" + serviceInstance.getPort());
                });
            }
            xxlJobSpringExecutor.setAdminAddresses(String.join(",",urls));
            xxlJobSpringExecutor.setAppName(appName);
            xxlJobSpringExecutor.setIp(ip);
            xxlJobSpringExecutor.setPort(port);
            xxlJobSpringExecutor.setAccessToken(accessToken);
            xxlJobSpringExecutor.setLogPath(logPath);
            xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
    
            return xxlJobSpringExecutor;
        }
  • 相关阅读:
    杨辉三角实现
    三种方式都能生成同样的列表
    Python 直接赋值、浅拷贝和深度拷贝解析
    Python 拷贝对象(深拷贝deepcopy与浅拷贝copy)
    教你玩转CSS 分组选择器和嵌套选择器
    教你玩转CSS padding(填充)
    教你玩转CSS 轮廓(outline)属性
    教你玩转CSS margin(外边距)
    教你玩转CSS border(边框)
    教你玩转CSS表格(table)
  • 原文地址:https://www.cnblogs.com/donglulu/p/12581431.html
Copyright © 2011-2022 走看看