zookeeper注册中心配置
1 package com.zwh.pay.account.worker; import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration;
import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; /**
* Created by Administrator on 2017/7/10.
*/
@Configuration
public class RegistryCenterConfig { @Bean(initMethod = "init")
public ZookeeperRegistryCenter createZookeeperRegistryCenter(@Value("${regCenter.serverList}") final String serverLists, @Value("${regCenter.namespace}") final String namespace){
ZookeeperConfiguration zookeeperConfiguration = new ZookeeperConfiguration
(serverLists,namespace);
return new ZookeeperRegistryCenter(zookeeperConfiguration);
}
}
 开启事件追踪器
1 package com.zwh.pay.account.worker; import com.dangdang.ddframe.job.event.JobEventConfiguration;
import com.dangdang.ddframe.job.event.rdb.JobEventRdbConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import javax.sql.DataSource; /**
* Created by Administrator on 2017/7/10.
*/
@Configuration
public class JobEventConfig { @Autowired
private DataSource dataSource; @Bean("jobEventConfiguration")
public JobEventConfiguration createJobEventConfiguration(){
return new JobEventRdbConfiguration(dataSource);
}
}
 配置任务启动类
1 package com.zwh.pay.account.worker; import com.dangdang.ddframe.job.config.JobCoreConfiguration;
import com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration;
import com.dangdang.ddframe.job.event.JobEventConfiguration;
import com.dangdang.ddframe.job.lite.api.JobScheduler;
import com.dangdang.ddframe.job.lite.config.LiteJobConfiguration;
import com.dangdang.ddframe.job.lite.spring.api.SpringJobScheduler;
import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; /**
*
* ClassName: JobStart <br/>
* Function: TODO 定时任务启动类. <br/>
* Reason: TODO ADD REASON(可选). <br/>
* date: 2017年9月30日 上午10:31:26 <br/>
*
* @author zhangwenhao
* @version 1.0
* @since JDK 1.8
*/
@Configuration
public class JobStart { @Autowired
private ZookeeperRegistryCenter zookeeperRegistryCenter; @Autowired
private JobEventConfiguration jobEventConfiguration; @Bean("fundCarryJob")
public FundCarryJob fundCarryJob() {
return new FundCarryJob();
} private LiteJobConfiguration getLiteJobConfiguration(String cron, int
shardingTotalCount, @SuppressWarnings("rawtypes") Class clazz) {
return LiteJobConfiguration.newBuilder(
new SimpleJobConfiguration(
JobCoreConfiguration.newBuilder(
clazz.getName(), cron,
shardingTotalCount).build(),
clazz.getCanonicalName()))
.overwrite(true).build();
} @Bean(initMethod = "init", name = "fundCarryJobScheduler")
public JobScheduler fundCarryJobScheduler(final FundCarryJob fundCarryJob,
@Value("${fundCarryJob.cron}") String cron,
@Value("${fundCarryJob.shardingTotalCount}")
int shardingTotalCount) { return new SpringJobScheduler(fundCarryJob,
zookeeperRegistryCenter,
getLiteJobConfiguration(cron, shardingTotalCount,
FundCarryJob.class), jobEventConfiguration);
} }
定时任务执行
package com.zwh.pay.account.worker; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.hivescm.pay.account.service.AccountSeqFlowService; /**
* ClassName:FundCarryJob <br/>
* Function: TODO 定时任务执行. <br/>
* Reason: TODO ADD REASON. <br/>
* Date: 2017年9月29日 下午5:55:51 <br/>
* @author zhangwenhao
* @version 1.0
* @since JDK 1.8
* @see
*/
public class FundCarryJob implements SimpleJob{ private Logger logger = LoggerFactory.getLogger(FundCarryJob.class);
@Autowired
@Override
public void execute(ShardingContext arg0) {
}
}
配置文件
1 #elastic job config
regCenter.serverList=10.12.31.100:2181,10.12.31.105:2181,10.12.31.109:2181
regCenter.namespace=fundCarryJob fundCarryJob.cron=*/5 * * * * ?
#fundCarryJob.cron=0 0 0 * * ?
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. 第二百一十七节,jQuery EasyUI,NumberSpinner(数字微调)组件

    jQuery EasyUI,NumberSpinner(数字微调)组件 学习要点: 1.加载方式 2.属性列表 3.事件列表 4.方法列表 本节课重点了解 EasyUI 中 NumberSpinner ...

  2. linx常用查看命令和内存分配及释放

    1.命令行 运行时间多久:uptime 查看时间日期: date:date  -s '2014-7-4 10:35:20' hwcloc 查看内存分配: top free:http://blog.cs ...

  3. 多线程之使用读写锁ReentrantReadWriteLock实现缓存系统

    简单地缓存系统:当有线程来取数据时.假设该数据存在我的内存中.我就返回数据.假设不存在我的缓存系统中,那么就去查数据库.返回数据的同一时候保存在我的缓存中. 当中涉及到读写问题:当多个线程运行读操作时 ...

  4. 邮件正文及其附件的发送的C++实现

     这段代码我花了整整一天来编写,假设转载,请注明出处,谢谢!    前面的一篇文章已经讲了怎样发送邮件正文,原理我就不再叙述了.要了解的同学请到这里查看!    http://blog.csdn.ne ...

  5. hdu 4568(SPFA预处理+TSP)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4568 思路:先用spfa预处理出宝藏与宝藏之间的最短距离,宝藏到边界的最短距离,然后就是经典的求TSP ...

  6. asscert断言的几种方法

    一.什么是断言 执行完测试用例后,最后一步是判断测试结果是通过还是失败,在自动化脚本中一般把这种生成测试结果的方法叫做断言 它用来检查一个条件,如果它为真,则不做任何事,如果它为假,则会跑出Asser ...

  7. [原创]Nexus5 移植OneStep

    OneStep 简介 https://github.com/SmartisanTech/android One Step 涉及的工程列表: frameworks_base (需要更改WindowMan ...

  8. mysql的增量备份与全备的脚本

    mysql全量备份.增量备份.开启mysql的logbin日志功能.在/etc/my.cnf文件中加入以下代码: [mysqld]log-bin = "/home/mysql/logbin. ...

  9. 【BZOJ4704】旅行 树链剖分+可持久化线段树

    [BZOJ4704]旅行 Description 在Berland,有n个城堡.每个城堡恰好属于一个领主.不同的城堡属于不同的领主.在所有领主中有一个是国王,其他的每个领主都直接隶属于另一位领主,并且 ...

  10. @RequestMapping中method的默认值是什么?

    @RequestMapping中method的默认值是什么? 没有默认值,如果不配置method, 则以任何请求形式 RequestMethod.GET, RequestMethod.POST, Re ...