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. 第二百四十二节,Bootstrap列表组面板和嵌入组件

    Bootstrap列表组面板和嵌入组件 学习要点: 1.列表组组件 2.面板组件 3.响应式嵌入组件 本节课我们主要学习一下 Bootstrap 的三个组件功能:列表组组件.面板组件. 响应 式嵌入组 ...

  2. jdk从1.8降到1.7的办法

    jdk从1.8降到1.7的办法 正常情况下,JDK的升降级只需更改环境变量即可,可是到了1.8版本,oracle使了一点小手段--在系统Path中添加一条变量C:/ProgramData/Oracle ...

  3. PHP第三方登录

    参考视屏:http://www.imooc.com/learn/596 php第三方登录-QQ登录OAuth协议基本原理QQ登录前置条件以及开放平台账号申请1,一个QQ号2,一个公网通过域名可访问的w ...

  4. 65、TextView 字体设置不同颜色 --- 未完

    mTextView.setText(Html.fromHtml("教练评论" + "<font color='#b0b0b0'>" + " ...

  5. 显示所有APP的进程详细信息(进程ID、进程所在UID、进程占用内存、进程名)

    main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:and ...

  6. CentOS 安装 dotnetcore

    参考官方教程:https://www.microsoft.com/net/core#linuxcentos 安装.NET CORE SDK sudo yum install libunwind lib ...

  7. 分布式服务框架:Zookeeper简介

    分布式服务框架:Zookeeper(分布式系统的可靠协调系统) 本文导读: 1 Zookeeper概述 2 Zookeeper总体结构 ——逻辑图.运转流程.特点.优点.数据结构 3 Zookeepe ...

  8. Android studio Unsupported major.minor version 52.0

    从目前以及我从网上搜索到的解决方案来说,出现此问题可以从以下两个方法入手: 1. JDK的版本和class版本不一致,通常是jdk版本过低解决方法: 1)使用Java -version和javac - ...

  9. shared_ptr & weak_ptr

    shared_ptr <1> 类模板说明 namespace boost { class bad_weak_ptr: public std::exception; template< ...

  10. JavaWeb项目(SSM)准备工作

    1.新建dynamic web project(Maven project也行) 我用的Eclipse + ssm + mysql 2.准备jar包 整合ssm的包1. springmvc: ...2 ...