阿里雲-SchedulerX分佈式調度中心

正式使用

1.maven依賴

戳 → 版本說明

<dependency>
 <groupId>com.aliyun.schedulerx</groupId>
 <artifactId>schedulerx2-spring-boot-starter</artifactId>
 <version>${schedulerx2.version}</version>
</dependency>

2.application.yml

spring:
  schedulerx2:
    # https://help.aliyun.com/document_detail/162000.html?spm=a2c4g.11186623.2.9.3869212fxto1TK
    endpoint: addr-bj-internal.edas.aliyun.com
    # namespace爲命名空間ID,可以在控制檯命名空間頁面獲取。
    namespace: dd820 ba8
    # groupId爲應用ID,appKey爲應用key,可以在控制檯應用管理頁面獲取。多個id用,號拼接
    groupId: id1,id2
    # 1.2.1及以上版本設置appKey
    appKey: key1,key2
    
# 1.2.1以下版本設置AK/SK
#spring.schedulerx2.aliyunAccessKey=${aliyunAccessKey}
#spring.schedulerx2.aliyunSecretKey=${aliyunSecretKey}   

測試使用(本地)

1.maven

<dependency>
    <groupId>com.aliyun.schedulerx</groupId>
    <artifactId>schedulerx2-worker</artifactId>
    <version>1.2.3</version>
</dependency> 

解決衝突

# 排除依賴
<exclusions>
    <exclusion>
        <groupId>com.alibaba</groupId>
        <artifactId>fastjson</artifactId>
    </exclusion>
</exclusions>

代碼示例


@Component
public class TaskAdDayOrHour extends JavaProcessor {

    @Override
    public ProcessResult process(JobContext jobContext) throws Exception {
        String param = jobContext.getJobParameters();
        return new ProcessResult(true);
    }
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章