1. zookeeper注册中心配置
    1 package com.zwh.pay.account.worker;
  2.  
  3. import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration;
  4. import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter;
  5. import org.springframework.beans.factory.annotation.Value;
  6. import org.springframework.context.annotation.Bean;
  7. import org.springframework.context.annotation.Configuration;
  8.  
  9. /**
  10. * Created by Administrator on 2017/7/10.
  11. */
  12. @Configuration
  13. public class RegistryCenterConfig {
  14.  
  15. @Bean(initMethod = "init")
  16. public ZookeeperRegistryCenter createZookeeperRegistryCenter(@Value("${regCenter.serverList}") final String serverLists, @Value("${regCenter.namespace}") final String namespace){
  17. ZookeeperConfiguration zookeeperConfiguration = new ZookeeperConfiguration
  18. (serverLists,namespace);
  19. return new ZookeeperRegistryCenter(zookeeperConfiguration);
  20. }
  21. }
  1. 开启事件追踪器
    1 package com.zwh.pay.account.worker;
  2.  
  3. import com.dangdang.ddframe.job.event.JobEventConfiguration;
  4. import com.dangdang.ddframe.job.event.rdb.JobEventRdbConfiguration;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.context.annotation.Bean;
  7. import org.springframework.context.annotation.Configuration;
  8.  
  9. import javax.sql.DataSource;
  10.  
  11. /**
  12. * Created by Administrator on 2017/7/10.
  13. */
  14. @Configuration
  15. public class JobEventConfig {
  16.  
  17. @Autowired
  18. private DataSource dataSource;
  19.  
  20. @Bean("jobEventConfiguration")
  21. public JobEventConfiguration createJobEventConfiguration(){
  22. return new JobEventRdbConfiguration(dataSource);
  23. }
  24. }
  1. 配置任务启动类
    1 package com.zwh.pay.account.worker;
  2.  
  3. import com.dangdang.ddframe.job.config.JobCoreConfiguration;
  4. import com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration;
  5. import com.dangdang.ddframe.job.event.JobEventConfiguration;
  6. import com.dangdang.ddframe.job.lite.api.JobScheduler;
  7. import com.dangdang.ddframe.job.lite.config.LiteJobConfiguration;
  8. import com.dangdang.ddframe.job.lite.spring.api.SpringJobScheduler;
  9. import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.beans.factory.annotation.Value;
  12. import org.springframework.context.annotation.Bean;
  13. import org.springframework.context.annotation.Configuration;
  14.  
  15. /**
  16. *
  17. * ClassName: JobStart <br/>
  18. * Function: TODO 定时任务启动类. <br/>
  19. * Reason: TODO ADD REASON(可选). <br/>
  20. * date: 2017年9月30日 上午10:31:26 <br/>
  21. *
  22. * @author zhangwenhao
  23. * @version 1.0
  24. * @since JDK 1.8
  25. */
  26. @Configuration
  27. public class JobStart {
  28.  
  29. @Autowired
  30. private ZookeeperRegistryCenter zookeeperRegistryCenter;
  31.  
  32. @Autowired
  33. private JobEventConfiguration jobEventConfiguration;
  34.  
  35. @Bean("fundCarryJob")
  36. public FundCarryJob fundCarryJob() {
  37. return new FundCarryJob();
  38. }
  39.  
  40. private LiteJobConfiguration getLiteJobConfiguration(String cron, int
  41. shardingTotalCount, @SuppressWarnings("rawtypes") Class clazz) {
  42. return LiteJobConfiguration.newBuilder(
  43. new SimpleJobConfiguration(
  44. JobCoreConfiguration.newBuilder(
  45. clazz.getName(), cron,
  46. shardingTotalCount).build(),
  47. clazz.getCanonicalName()))
  48. .overwrite(true).build();
  49. }
  50.  
  51. @Bean(initMethod = "init", name = "fundCarryJobScheduler")
  52. public JobScheduler fundCarryJobScheduler(final FundCarryJob fundCarryJob,
  53. @Value("${fundCarryJob.cron}") String cron,
  54. @Value("${fundCarryJob.shardingTotalCount}")
  55. int shardingTotalCount) {
  56.  
  57. return new SpringJobScheduler(fundCarryJob,
  58. zookeeperRegistryCenter,
  59. getLiteJobConfiguration(cron, shardingTotalCount,
  60. FundCarryJob.class), jobEventConfiguration);
  61. }
  62.  
  63. }
  1. 定时任务执行
    package com.zwh.pay.account.worker;
  2.  
  3. import org.slf4j.Logger;
  4. import org.slf4j.LoggerFactory;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6.  
  7. import com.dangdang.ddframe.job.api.ShardingContext;
  8. import com.dangdang.ddframe.job.api.simple.SimpleJob;
  9. import com.hivescm.pay.account.service.AccountSeqFlowService;
  10.  
  11. /**
  12. * ClassName:FundCarryJob <br/>
  13. * Function: TODO 定时任务执行. <br/>
  14. * Reason: TODO ADD REASON. <br/>
  15. * Date: 2017年9月29日 下午5:55:51 <br/>
  16. * @author zhangwenhao
  17. * @version 1.0
  18. * @since JDK 1.8
  19. * @see
  20. */
  21. public class FundCarryJob implements SimpleJob{
  22.  
  23. private Logger logger = LoggerFactory.getLogger(FundCarryJob.class);
  24. @Autowired
  25. @Override
  26. public void execute(ShardingContext arg0) {
  27. }
  28. }
  1. 配置文件
    1 #elastic job config
  2. regCenter.serverList=10.12.31.100:2181,10.12.31.105:2181,10.12.31.109:2181
  3. regCenter.namespace=fundCarryJob
  4.  
  5. fundCarryJob.cron=*/5 * * * * ?
  6. #fundCarryJob.cron=0 0 0 * * ?
  7. fundCarryJob.shardingTotalCount=1

elastic job配置的更多相关文章

  1. ELK6.6.0+filebeat6.6.0部署

    elastic不能用root用户去启动,否则会报错,所以创建elastic用户ES集群部署 1.创建elastic用户 $ useradd elastic $ passwd elastic 2..部署 ...

  2. ELK实践(二):收集Nginx日志

    Nginx访问日志 这里补充下Nginx访问日志使用的说明.一般在nginx.conf主配置文件里需要定义一种格式: log_format main '$remote_addr - $remote_u ...

  3. elasticsearch6.3.2之x-pack6.3.2破解安装并配合kibana使用

    原文链接:https://www.plaza4me.com/article/20180825223826278 由于在elasticsearch在6.3版本之后x-pack是默认安装好的,所以不再需要 ...

  4. ELK初学搭建

    目录:基础准备 修改相关系统配置 安装elasticsearch 安装 kibana 安装logstash X-pack插件的安装 登录网页查看 ELK名字解释 ELK就是ElasticSearch ...

  5. elasticsearch 5.x 系列之一 开始安装啦

    以下是镇楼用的,各路退让,我要吹liubi 了 // // _oo0oo_ // o8888888o // 88" . "88 // (| -_- |) // 0\ = /0 // ...

  6. (1)安装elastic6.1.3及插件kibana,x-pack,essql,head,bigdesk,cerebro,ik

    1.安装环境及程序版本 操作系统: centos6.7 jdk: 1.8.0_102 elastic: 1.6.3 kibana: 1.6.3 x-pack: 1.6.3 es-sql: 1.6.3 ...

  7. [Golang] 消费Kafka的日志提交到ElasticSearch

    0x0 需求 消费Kafka的日志并写入ElasticSearch供查询 0x1 依赖库 golang版Kafka客户端 https://github.com/Shopify/sarama golan ...

  8. 03_Elastic部署

    ES集群部署 elastic不能用root用户去启动,否则会报错,所以创建elastic用户 1.创建elastic用户 $ useradd elastic -s /sbin/nologin 2..部 ...

  9. Spring5 of WebClient(转载)

    前言 Spring5带来了新的响应式web开发框架WebFlux,同时,也引入了新的HttpClient框架WebClient.WebClient是Spring5中引入的执行 HTTP 请求的非阻塞. ...

随机推荐

  1. 使用AngularJS创建应用的5个框架

    [导读] 如果你计划使用AngularJS创建你的Web应用,那现在就开始吧.你不需要有任何的恐惧和担心,因为现在有很多的框架都可以很好地支持AngularJS.这些框架都有事先安装的Web组件,使用 ...

  2. Firefox模拟手机访问手机网站

    说明: 此方法只能用以那些以识别UA来判断的网站 使用步骤: 第一步:打开Firefox,点击菜单,工具-〉附加组件-〉获取附加组件: 第二步:查询安装三个组件:User Agent Switcher ...

  3. JQuery基本选择器和基本动画方法总结

    刚开始接触JQuery是在大三的时候,那时候先学的Javascript,然后跳跃到JQuery,就一个字,爽.但因为之前用的不是太多,所以很多都忘了,直接导致的后果就是之前在一家公司面试,面试官问我要 ...

  4. win7系统

    网址:http://www.xitongma.com/Windows7/ 使用方法:http://www.cnblogs.com/henrychan688/p/5223935.html

  5. Deep Learning阅读资料

    入门基础阅读:http://www.cnblogs.com/avril/archive/2013/02/08/2909344.html 书籍推荐:http://blog.chinaunix.net/u ...

  6. Telnet发送邮件之聊以自慰

    北京的冬天,闲着无聊,得做点什么暖暖脑袋,用windows系统自带工具telnet玩了把邮件发送 准备工作: 1.打开windows系统telnet客户端功能 2.准备两个邮箱帐号(xxx@163.c ...

  7. MD5文件校验

    经常看到在网上下载个什么东西,旁边经常会跟一个md5值,以前不太清楚是做什么的.今天偶然发现了一个liunux命令 md5sum.经查寻知道这个命令是用来生成或校验md5值的命令.还是刚才的问题,为什 ...

  8. Duilib教程-简单介绍

    在读这篇博客的时候,可能您已经对duilib有一定的了解.所以,我并不打算对duilib进行过多的介绍.它的内核首先由外国人编写,后来由国人一个小组接过来继续编写,于是就有了现在的Duilib. 1. ...

  9. Volley 的使用以及自定义Request

    Volley 的使用以及自定义Request 一.什么是 Volley 2013年Google I/O大会上推出了一个新的网络通信框架.Volley是Android平台上的网络通信库,能使网络通信更快 ...

  10. [转]廖雪峰Git教程总结