elastic job配置
- 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配置的更多相关文章
- ELK6.6.0+filebeat6.6.0部署
elastic不能用root用户去启动,否则会报错,所以创建elastic用户ES集群部署 1.创建elastic用户 $ useradd elastic $ passwd elastic 2..部署 ...
- ELK实践(二):收集Nginx日志
Nginx访问日志 这里补充下Nginx访问日志使用的说明.一般在nginx.conf主配置文件里需要定义一种格式: log_format main '$remote_addr - $remote_u ...
- elasticsearch6.3.2之x-pack6.3.2破解安装并配合kibana使用
原文链接:https://www.plaza4me.com/article/20180825223826278 由于在elasticsearch在6.3版本之后x-pack是默认安装好的,所以不再需要 ...
- ELK初学搭建
目录:基础准备 修改相关系统配置 安装elasticsearch 安装 kibana 安装logstash X-pack插件的安装 登录网页查看 ELK名字解释 ELK就是ElasticSearch ...
- elasticsearch 5.x 系列之一 开始安装啦
以下是镇楼用的,各路退让,我要吹liubi 了 // // _oo0oo_ // o8888888o // 88" . "88 // (| -_- |) // 0\ = /0 // ...
- (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 ...
- [Golang] 消费Kafka的日志提交到ElasticSearch
0x0 需求 消费Kafka的日志并写入ElasticSearch供查询 0x1 依赖库 golang版Kafka客户端 https://github.com/Shopify/sarama golan ...
- 03_Elastic部署
ES集群部署 elastic不能用root用户去启动,否则会报错,所以创建elastic用户 1.创建elastic用户 $ useradd elastic -s /sbin/nologin 2..部 ...
- Spring5 of WebClient(转载)
前言 Spring5带来了新的响应式web开发框架WebFlux,同时,也引入了新的HttpClient框架WebClient.WebClient是Spring5中引入的执行 HTTP 请求的非阻塞. ...
随机推荐
- 使用AngularJS创建应用的5个框架
[导读] 如果你计划使用AngularJS创建你的Web应用,那现在就开始吧.你不需要有任何的恐惧和担心,因为现在有很多的框架都可以很好地支持AngularJS.这些框架都有事先安装的Web组件,使用 ...
- Firefox模拟手机访问手机网站
说明: 此方法只能用以那些以识别UA来判断的网站 使用步骤: 第一步:打开Firefox,点击菜单,工具-〉附加组件-〉获取附加组件: 第二步:查询安装三个组件:User Agent Switcher ...
- JQuery基本选择器和基本动画方法总结
刚开始接触JQuery是在大三的时候,那时候先学的Javascript,然后跳跃到JQuery,就一个字,爽.但因为之前用的不是太多,所以很多都忘了,直接导致的后果就是之前在一家公司面试,面试官问我要 ...
- win7系统
网址:http://www.xitongma.com/Windows7/ 使用方法:http://www.cnblogs.com/henrychan688/p/5223935.html
- Deep Learning阅读资料
入门基础阅读:http://www.cnblogs.com/avril/archive/2013/02/08/2909344.html 书籍推荐:http://blog.chinaunix.net/u ...
- Telnet发送邮件之聊以自慰
北京的冬天,闲着无聊,得做点什么暖暖脑袋,用windows系统自带工具telnet玩了把邮件发送 准备工作: 1.打开windows系统telnet客户端功能 2.准备两个邮箱帐号(xxx@163.c ...
- MD5文件校验
经常看到在网上下载个什么东西,旁边经常会跟一个md5值,以前不太清楚是做什么的.今天偶然发现了一个liunux命令 md5sum.经查寻知道这个命令是用来生成或校验md5值的命令.还是刚才的问题,为什 ...
- Duilib教程-简单介绍
在读这篇博客的时候,可能您已经对duilib有一定的了解.所以,我并不打算对duilib进行过多的介绍.它的内核首先由外国人编写,后来由国人一个小组接过来继续编写,于是就有了现在的Duilib. 1. ...
- Volley 的使用以及自定义Request
Volley 的使用以及自定义Request 一.什么是 Volley 2013年Google I/O大会上推出了一个新的网络通信框架.Volley是Android平台上的网络通信库,能使网络通信更快 ...
- [转]廖雪峰Git教程总结