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_selenium之处理Alert窗

    Python_selenium之处理Alert窗 一.介绍 1. 介绍如何通过switch_to方法处理网页Alert窗口 2. 然后我们自己创建一个alert弹窗进行操作 二.测试脚本 1. 测试脚 ...

  2. java项目学习

    GitHub地址:https://github.com/zhanglei-workspace/shopping-management-system

  3. My97DatePicker日历控件在iframe提示没有权限的问

    修改 WdatePicker.js 文件 $crossFrame:false, 值设成 false,原来的值是 true

  4. HYSBZ 3676 回文串 (回文树)

    3676: [Apio2014]回文串 Time Limit: 20 Sec  Memory Limit: 128 MB Submit: 1680  Solved: 707 [Submit][Stat ...

  5. 手动爬虫之流程笔记1(python3)

    一.引入拓展库 由于刚刚起步学习爬虫,故从urllib库开始 首先引入urllib,这里主要用到urllib中request类 import urllib.request as ur 二.设置全局参数 ...

  6. XXE(xml外部实体注入漏洞)

    实验内容 介绍XXE漏洞的触发方式和利用方法,简单介绍XXE漏洞的修复. 影响版本: libxml2.8.0版本 漏洞介绍 XXE Injection即XML External Entity Inje ...

  7. java获取地址全路径

      String basePath = request.getScheme()+"://"+request.getServerName()+":"+reques ...

  8. IO流入门-第十一章-PrintStream_PrintWriter

    DataInputStream和DataOutputStream基本用法和方法示例 /* java.io.PrintStream:标准的输出流,默认打印到控制台,以字节方式 java.io.Print ...

  9. Spring MVC 框架结构介绍(二)

    Spring MVC框架结构 Spring MVC是围绕DispatcherServlet设计的,DispatcherServlet向处理程序分发各种请求.处理程序默认基于@Controller和@R ...

  10. TempData、ViewData和ViewBag异同

    Data ViewData ViewBag都可以用来保存数据. 它们之间的区别如下: TempData:保存在Session中,Controller每次执行请求的时候,会从Session中先获取Tem ...