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. IDEA中如何配置Tomcat和项目?

    IDEA是我用的挺多的一款java代码编辑工具,对于刚接触这款软件的新手来说,配置项目是很麻烦的了,更别说配置服务器Tomcat了,那么通过我的教程大家一定觉得配置IDEA项目也是很轻松的事了.   ...

  2. c# 将html添加进剪贴板(带格式)

    调用: ClipboardHelper.CopyToClipboard("<h1>hello world</h1>", ""); /// ...

  3. js事件处理函数中return的作用

    这里面的return含有一些细节知识: 例如:onClick='return add_onclick()'与 onClick='add_onclick()'的区别 JAVASCRIPT在事件中调用函数 ...

  4. IOS开发之——企业版IDP的申请及“In House”发布

    本文转载至 http://blog.csdn.net/pjk1129/article/details/7572183 企业版IDP的申请及“In House”发布 原贴地址:http://blog.c ...

  5. 高性能javascript 文件加载阻塞

    高性能javascript   javascript脚本执行过程中会中断页面加载,直到脚本执行完毕,此操作阻塞了页面加载,造成性能问题. 脚本位置和加载顺序:如果将脚本放在head内,那么再脚本执行完 ...

  6. jQuery中如何给动态添加的元素绑定事件

    jquery中绑定事件一般使用bind,或者click,但是这只能是对已经加载好的元素定义事件,那些后来添加插入的元素则需要另行绑定.在1.7版本以前使用live.但是在1.8版本以后推荐使用on.这 ...

  7. 【BZOJ2039】[2009国家集训队]employ人员雇佣 最小割

    [BZOJ2039][2009国家集训队]employ人员雇佣 Description 作为一个富有经营头脑的富翁,小L决定从本国最优秀的经理中雇佣一些来经营自己的公司.这些经理相互之间合作有一个贡献 ...

  8. mysql 获取id最大值

    数据库表中id列不为自动增加,需要程序来增加id的SQL SELECTCASE IFNULL(MAX(id),1)WHEN 1 THEN 1ELSE MAX(id) + 1END AS newmaxi ...

  9. 1 duilib 自绘标题 最大化图标显示bug ----WindowImplBase的bug

    窗口最大化之后有两个问题,     1.最大化按钮的样式还是没变,正确的样式应该是这样的     2.再次点击最大化按钮,不能还原到正常大小.     这个是WindowImplBase的bug,已经 ...

  10. SQL中的函数 •Aggregate 函数 •Scalar 函数

    合计函数  :Aggregate是针对一系列值的操作,返回一个单一的值 Scalar 函数是针对一个单一的值的操作,返回基于输入值的一个单一值 合计函数: AVG()返回某列的平均值:COUNT()返 ...