SchedulerX - Hello world

简介: 介绍SchedulerX 是阿里中间件团队开发的一款分布式任务调度产品,在阿里内部有着广泛的使用,经过集团内上千个业务应用历经多年打磨而成。

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
@Data
public 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-3650
2017-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}] asynchronously
2017-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}] asynchronously
2017-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:120000
14: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=xxxxx, 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

目录
相关文章
|
8月前
|
存储 安全 前端开发
SpringBoot阿里云OSS文件上传实例
本文介绍了通过阿里云OSS实现用户头像上传的功能。首先概述了OSS的特点,如高持久性、RESTful API支持及多种存储类型。接着详细描述了前期准备步骤,包括注册阿里云账号、实名认证、开通OSS服务、创建Bucket及AccessKey。注意事项中提到需调整Bucket的访问权限以支持前端访问。最后提供了基于SpringBoot的代码实现,包含配置文件与上传工具类的编写,帮助开发者快速集成OSS文件上传功能。
1745 1
SpringBoot阿里云OSS文件上传实例
|
12月前
|
SQL 关系型数据库 MySQL
MySQL 中的全文索引:强大的文本搜索利器
MySQL 的全文索引是一种用于快速搜索大量文本数据的特殊索引。它通过对文本内容进行分析(如分词、去除停用词等)并构建倒排索引,实现高效查找。创建全文索引使用 `CREATE FULLTEXT INDEX`,搜索时使用 `MATCH AGAINST` 语句。适用于 `CHAR`、`VARCHAR`、`TEXT` 等字段,但需注意性能影响和正确使用搜索语法。
578 22
|
关系型数据库 MySQL 索引
MySQL in 太多的解决方案
MySQL in 太多的解决方案
1454 0
|
消息中间件 Java 网络安全
阿里RocketMQ安装服务器及客户端
阿里RocketMQ安装服务器及客户端
1088 0
|
机器学习/深度学习 人工智能 弹性计算
阿里云GPU云服务器介绍_GPU租用费用_GPU优势和使用场景说明
阿里云GPU云服务器提供NVIDIA A10、V100、T4、P4、P100等GPU卡,结合高性能CPU,单实例计算性能高达5PFLOPS。支持多种实例规格,如A10卡GN7i、V100-16G卡GN6v等,应用于深度学习、科学计算等场景。GPU服务器租用费用因实例规格而异,如A10卡GN7i每月3213.99元起。阿里云还提供GPU加速软件如AIACC-Training、AIACC-Inference等。网络性能强大,VPC支持2400万PPS和160Gbps内网带宽。购买方式灵活,包括包年包月、按量付费等。客户案例包括深势科技、流利说和小牛翻译等。
1491 4
|
API
求助:使用阿里的通义模型如何支持运行GraphRAG项目呢?
求助:使用阿里的通义模型如何支持运行GraphRAG项目呢?
351 2
|
分布式计算 监控 大数据
任务调度scheduleX
【8月更文挑战第22天】
2400 0
|
消息中间件 Java RocketMQ
修改rocketmq的日志文件位置
修改rocketmq的日志文件位置
622 0
修改rocketmq的日志文件位置
|
机器学习/深度学习 存储 算法
逻辑回归模型
逻辑回归模型
454 0
|
XML 移动开发 小程序
小程序微信支付API?以及参数有哪些
小程序微信支付API?以及参数有哪些
833 0