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. python文件的编译

    背景知识 pyc文件: .pyc 是一种二进制文件,是由 .py 文件经过编译后,生成一种byte code文件. .py 文件变成 .pyc 文件后,加载的速度有所提高,而且 .pyc 是一种跨平台 ...

  2. 用MathType编辑带点星号的流程

    在数学中,在进行问题描述的同时,可能也会使用到一些文本符号,比如带点星号.这些符号嵌入在公式中,就需要在MathType数学公式编辑器中来编辑,而不是在文档中编辑.而对于公式编辑器来说,编辑一些常用的 ...

  3. 维纳滤波和编码曝光PSF去除运动模糊【matlab】

    编码曝光知识 - ostartech - 博客园 https://www.cnblogs.com/wxl845235800/p/8276362.html %%%%%%%%%%%%%%%%%%%%%%% ...

  4. 关于 HTML5 的文件上传处理,兼容性问题,以及 BLOB 对象的使用 (转载)

    研究过程中关于本主体的相关参考 好文:https://hacks.mozilla.org/2011/01/how-to-develop-a-html5-image-uploader/ 好文:http: ...

  5. Oracle11g Active Data Guard搭建、管理

    说明:參考网络众多人的笔记及思路,加上自己亲身实践之后的整理笔记.仅供參考. Data Guard与RAC不同的是.在普通情况下.Standby仅仅有一个节点处于活动状态,全部的应用都连接到主serv ...

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

  7. 一个最简单的JStorm例子

    最简单的JStorm例子分为以下几个步骤: 1.生成Topology Map conf = new HashMp(); //topology所有自定义的配置均放入这个Map TopologyBuild ...

  8. [Algorithms] Longest Common Substring

    The Longest Common Substring (LCS) problem is as follows: Given two strings s and t, find the length ...

  9. 170213、亿级Web系统搭建——单机到分布式集群

    [导读]徐汉彬曾在阿里巴巴和腾讯从事4年多的技术研发工作,负责过日请求量过亿的Web系统升级与重构,目前在小满科技创业,从事SaaS服务技术建设. 大规模流量的网站架构,从来都是慢慢“成长”而来.而这 ...

  10. Debug技巧:条件断点和远程Debug

    一.断点: 1.条件断点 本以为条件断点很难,其实就这样. 二.远程Debug 1.首先看服务器是不是在Debug模式下工作 不是则进行(tomcat/bin/catalina.sh)配置. -Xde ...