SchedulerX
来源:互联网 发布:java编写验证身份证号 编辑:程序博客网 时间:2024/06/05 09:16
介绍
SchedulerX 是阿里中间件团队开发的一款分布式任务调度产品,在阿里内部有着广泛的使用,经过集团内上千个业务应用历经多年打磨而成。每天非常稳定的运行着集团内几十万个任务以及完成每天几亿次的任务调度。在未来 SchedulerX 将支持更多特性以满足集团内外不断增长的用户需求。用户在应用中依赖 SchedulerX-Client,并在 SchedulerX 控制台创建定时任务,进行相应的参数配置后,启动该应用就可以接收到定时任务的周期调度。SchedulerX-Server 集群为调度触发提供高可用性和高稳定性的保证,并且可以实现对用户客户端机器集群进行分布式调度详细请查看
spring boot 整合
添加依赖
<dependency> <groupId>com.alibaba.edas</groupId> <artifactId>schedulerX-client</artifactId> <version>1.6.6</version></dependency>
boot 配置
package com.xescm.tfc.config;import com.alibaba.dts.common.exception.InitException;import com.alibaba.edas.schedulerX.SchedulerXClient;import lombok.Data;import org.springframework.boot.autoconfigure.EnableAutoConfiguration;import org.springframework.boot.context.properties.ConfigurationProperties;import org.springframework.context.annotation.Bean;/** * The class Schedual x config. * Created by paascloud.net@gmail.com */@ConfigurationProperties(prefix = SchedulerXConfig.JOB_PREFIX)@EnableAutoConfiguration@Datapublic class SchedulerXConfig { /** * The constant JOB_PREFIX. */ public static final String JOB_PREFIX = "aliyun.schedulerX"; private String groupId; private String regionName; /** * Scheduler x client scheduler x client. * * @return the scheduler x client */ @Bean public SchedulerXClient schedulerXClient(){ SchedulerXClient schedulerXClient = new SchedulerXClient(); schedulerXClient.setGroupId(getGroupId()); schedulerXClient.setRegionName(getRegionName()); try { schedulerXClient.init(); } catch (InitException e) { e.printStackTrace(); } return schedulerXClient; }}
创建任务HelloWorldJobProcessor
/** * The class Hello world job processor. * Created by paascloud.net@gmail.com */public class HelloWorldJobProcessor implements ScxSimpleJobProcessor { /** * Process process result. * * @param scxSimpleJobContext the scx simple job context * * @return the process result */ @Override public ProcessResult process(ScxSimpleJobContext scxSimpleJobContext) { System.out.println("Hello World!"); return new ProcessResult(true); }}
application.properties增加配置
aliyun.schedulerX.groupId=201-3-2-****aliyun.schedulerX.regionName=cn-test
添加密钥信息
创建文件
E:\xescm\aliyun\job\accessKey\accessKey.txt
修改文件信息
accessKey=LTAIMrsQ********secretKey=22YzqR6Gjy********************
配置Idea的VM options
-Dspas.identity=E:\xescm\aliyun\job\accessKey\accessKey.txt
创建测试用例
import com.alibaba.dts.common.exception.InitException;import com.alibaba.edas.schedulerX.SchedulerXClient;/** * The class Job test. * Created by paascloud.net@gmail.com */public class JobTest { public static void main(String[] args) throws InitException { SchedulerXClient schedulerXClient = new SchedulerXClient(); schedulerXClient.setGroupId("201-3-2-****"); schedulerXClient.setRegionName("cn-test"); schedulerXClient.init(); }}
执行结果
2017-09-20 14:54:16 WARN [com.alibaba.dts.common.util.RemotingUtil:144] - [RemotingUtil]: ipv4Result last ip, ipv4Result:[192.168.241.1, 192.168.32.191]14:54:17.021 [main] WARN com.alibaba.dts.client.DtsClient - [SchedulerXClient]: tell initialized, thread:main, groupId:201-3-2-36502017-09-20 14:54:17 INFO [com.alibaba.dts.common.remoting.netty.NettyRemotingClient:439] - createChannel: begin to connect remote host[{112.124.219.1:80}] asynchronously2017-09-20 14:54:17 INFO [com.alibaba.dts.common.remoting.netty.NettyRemotingClient$NettyConnetManageHandler:129] - NETTY CLIENT PIPELINE: CONNECT {UNKNOW} => {/112.124.219.1:80}2017-09-20 14:54:17 INFO [com.alibaba.dts.common.remoting.netty.NettyRemotingClient:459] - createChannel: connect remote host[{112.124.219.1:80}] success, {DefaultChannelPromise@60f00693(success)}2017-09-20 14:54:17 INFO [com.alibaba.dts.common.remoting.netty.NettyRemotingClient:439] - createChannel: begin to connect remote host[{112.124.219.2:80}] asynchronously2017-09-20 14:54:17 INFO [com.alibaba.dts.common.remoting.netty.NettyRemotingClient$NettyConnetManageHandler:129] - NETTY CLIENT PIPELINE: CONNECT {UNKNOW} => {/112.124.219.2:80}2017-09-20 14:54:17 INFO [com.alibaba.dts.common.remoting.netty.NettyRemotingClient:459] - createChannel: connect remote host[{112.124.219.2:80}] success, {DefaultChannelPromise@14f232c4(success)}14:54:17.983 [main] WARN c.a.d.client.remoting.ClientRemoting - [ClientRemoting]: initHeartBeatTimer success, heartBeatIntervalTime:12000014:54:18.031 [main] WARN com.alibaba.dts.client.DtsClient - [SchedulerXClient]: init over, clientConfig:ClientConfig [remotingThreads=32, heartBeatIntervalTime=120000, connectionTimeout=3000, groupId=201-3-2-3650, zkHosts=null, namespace=zk-dts-root, zkSessionTimeout=10000, zkConnectionTimeout=10000, isSpring=false, queueSize=10000, consumerThreads=5, consumerThreadsMap=null, version=1.6.13-SNAPSHOT, pageSize=1000, pageSizeMap=null, accessKey=LTAIMrsQLm2RypHN, secretKey=null, localAddress=192.168.241.1, clientId=a8cbca9b-28cb-42a9-b869-d85ef418d289:192.168.241.1, crashRetry=false, pullTaskListOverSleepTime=20000, failureJobProcessorMap=null, stopJobProcessor=null, finishLog=true, isEveryTimeNew=false, zkHostsAutoChange=true, maxBodySize=65536, environment=SchedulerX, signature=wIhotPp56AtUEhiFlqtcw1rTsrY=, jobMap=null, machine=null, domainName=schedulerx.console.aliyun.com, serviceGroup=null, regionName=cn-test, serviceGroupId=null, autoInit=true, isAgent=false, newInstance=true, configPath=null, connectTime=1505890457908, innerDebug=0]Hello World!
Hello World! 完毕
在本地启动出现 “授权失败,无效的时间戳时修改时间服务器npt1.aliyun.com
阅读全文
0 0
- SchedulerX
- 分布式任务调度中间件SchedulerX
- [门户自用]在div显示时间,年月日,星期
- SSM+Maven 分页查询
- 在Salesforce标准页面上使用Url传参
- 自媒体淘客收入到底有多客观?你不知道的自媒体技巧!
- Android SDK Manager 下载镜像
- SchedulerX
- springboot 的pom文件
- 自练题20170727
- 安卓软件安全与逆向分析学习笔记<一>
- 【案例】湘潭大学一体化运维管理平台
- Android踩坑日记:Okhttp设置User-Agent你可能没遇到的坑
- PoJ 2417 Discrete Logging BSGS裸题
- ReactNative基础(一)编写一个登录页面
- 鏖战字符串