1. 程式人生 > >Elastic-Job快速使用

Elastic-Job快速使用

原文地址:https://github.com/dangdangdotcom/elastic-job

Quick Start

Add maven dependency

<!-- import elastic-job lite core -->
<dependency>
    <groupId>com.dangdang</groupId>
    <artifactId>elastic-job-lite-core</artifactId>
    <version>${lasted.release.version}</version
> </dependency> <!-- import other module if need --> <dependency> <groupId>com.dangdang</groupId> <artifactId>elastic-job-lite-spring</artifactId> <version>${lasted.release.version}</version> </dependency>

Job development

public
class MyElasticJob implements SimpleJob { @Override public void process(ShardingContext context) { switch (context.getShardingItem()) { case 0: // do something by sharding item 0 break; case 1: // do something by sharding item 1
break; case 2: // do something by sharding item 2 break; // case n: ... } } }

Job configuration

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:reg="http://www.dangdang.com/schema/ddframe/reg"
    xmlns:job="http://www.dangdang.com/schema/ddframe/job"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
                        http://www.springframework.org/schema/beans/spring-beans.xsd
                        http://www.dangdang.com/schema/ddframe/reg
                        http://www.dangdang.com/schema/ddframe/reg/reg.xsd
                        http://www.dangdang.com/schema/ddframe/job
                        http://www.dangdang.com/schema/ddframe/job/job.xsd
                        ">
    <!--configure registry center -->
    <reg:zookeeper id="regCenter" server-lists="yourhost:2181" namespace="dd-job" base-sleep-time-milliseconds="1000" max-sleep-time-milliseconds="3000" max-retries="3" />

    <!--configure job -->
    <job:simple id="myElasticJob" class="xxx.MyElasticJob" registry-center-ref="regCenter" cron="0/10 * * * * ?"   sharding-total-count="3" sharding-item-parameters="0=A,1=B,2=C" />
</beans>

相關推薦

Elastic-Job快速使用

原文地址:https://github.com/dangdangdotcom/elastic-job Quick Start Add maven dependency <!-- import elastic-job lite core --> <d

快速入門Elastic-Job

0.前言   本案例基於springboot 1.5.9 1.maven依賴 1 <dependency> 2 <groupId>com.dangdang</groupId> 3 <artifactId>elastic-job-li

SpringBoot基礎教程3-1-5 Elastic-Job-lite快速整合

1 概述 Elastic-Job-Lite定位為輕量級無中心化解決方案,使用jar包的形式提供分散式任務的協調服務,外部依賴僅Zookeeper。 具體參考,官網 2 核心理念 分散式排程 Elastic-Job-Lite並無作業排程中心節點,而是基於部署作業框架的程式在到達相應時間點時各自觸發排程

elastic-job詳解(一):數據分片

count 任務 不同的 應該 center shc 偶數 int ext 數據分片的目的在於把一個任務分散到不同的機器上運行,既可以解決單機計算能力上限的問題,也能降低部分任務失敗對整體系統的影響。elastic-job並不直接提供數據處理的功能,框架只會將分片項分配至各

elastic-job詳解(三):Job的手動觸發功能

方法 idt image blog per tle cnblogs ack display elastic-job的任務都是使用quartz來觸發的,quartz表達式一般都是定期執行。但有時候一些周期較長的任務,比如一天一次,幾小時一次的任務,我們需要等待很久才能觸發一次

elastic-job詳解(四):失效轉移

shard out utm monit 設置 borde 點滴 title 等於 elastic-job中最關鍵的特性之一就是失效轉移。配置了失效轉移之後,如果在任務執行過程中有一個執行實例掛了,那麽之前被分配到這個實例的任務(或者分片)會在下次任務執行之前被重新分配到其他

Elastic Job 入門

job elastic 實現 入門 Elastic job是當當網架構師張亮,曹昊和江樹建基於Zookepper、Quartz開發並開源的一個Java分布式定時任務,解決了Quartz不支持分布式的弊端。Elastic job主要的功能有支持彈性擴容,通過Zookepper集中管理和監控job,

分布式任務elastic-job

idata blob vnr mas 編譯安裝 當當 pre cor clas # elastic-job簡介 目前Elastic job的最新版本已經由原來的elastic-job-core分離除了兩個項目,分別為Elastic-Job-Lite和Elastic-Job-

elastic job簡單用法

uil rman source simple pat 名稱 cat out ont public class JobMain { //配置註冊中心 private ZookeeperConfiguration zkConfig = new Zookeepe

Elastic-Job-Lite 源碼分析 —— 運維平臺

job 哈哈哈 配置服務 posit rop cat jet gis nmap   本文基於 Elastic-Job V2.1.5 版本分享    1. 概述    2. Maven模塊 elastic-job-common-restful    3. Maven模塊 el

Elastic Job學習

soft clas quic body bsp 分享 elastic mic log 從執行的結果來看,隨著服務器的增加,分片的結果也不一樣 當只有一臺服務器的時候,所有分片都到這一臺服務器上 當服務器增加到兩臺的時候,分片的結果是0 1 2 3 4和5 6 7

Elastic-Job-Lite 源碼分析 —— 作業分片策略

哈希 AD hash alloc hub strings put iat 總數 摘要: 原創出處 http://www.iocoder.cn/Elastic-Job/job-sharding-strategy/ 「芋道源碼」歡迎轉載,保留摘要,謝謝! 本文基於 Elast

Elastic-Job開發指南

開發指南 程式碼開發 作業型別 目前提供3種作業型別,分別是Simple,DataFlow和Script。 DataFlow型別用於處理資料流,它又提供2種作業型別,分別是ThroughputDataFlow和SequenceDataFlow。需要繼承相應的抽象類。 Script型別用於處理指令碼,

Elastic-Job原始碼解析(三)之分片定時任務執行

通過本篇的閱讀你將學會了解Elastic-Job的定時時機,及如何通過分片方式做一個分散式的定時任務框架。瞭解常用的三種分片策略,及如何自定義分散式分片策略 目錄 Elastic-Job如何通過SpringJobScheduler啟動定時 Ela

Elastic-Job原始碼解析(二)之定時核心實現quartz

Elastic-Job是一個分散式定時任務框架,其內部的定時主要是利用quartz來實現,而Elastic-Job核心是對quartz進行了封裝,並提供了分散式任務的功能。具體是怎麼實現呢? 怎麼實現分散式呢? 主要是通過Zookeeper通訊,獲取任務伺服器ip地址,並通

Elastic-Job原始碼解析(一)之與Spring完美整合

看過小編寫SpringFramework原始碼解析的同學應該對Spring支援自定義標籤還有點印象吧,沒有的話我們回顧下,然後看看Elastic-Job是如何巧妙的利用自定義標籤生成Job任務的吧。請注意這裡用了一個巧妙關鍵字。我們看它如何巧妙的吧。 Spring自定義

Elastic-Job學習筆記-定時任務框架的搭建

官方文件:http://elasticjob.io/docs/elastic-job-lite/00-overview/ elastic-job學習(網易樂得技術團隊,具體說明) http://tech.lede.com/2017/06/23/rd/server/elasticJob/

Elastic Job入門(1) - 簡介

介紹 構建一般的業務系統來說,使用 Quartz或者 Spring Task即可基本滿足我們的 單體服用應用需要。然而隨著線上業務量的不斷髮展,這兩種定時任務已經日漸無法滿足我們的需求。一般,使用這兩種定時任務框架都會遇到如下的兩個痛點問題: 1、如果業務工程採用 叢集化的部署,可能會多

Elastic Job入門(3) - 整合Springboot

引入pom檔案      <dependency> <groupId>com.dangdang</groupId> <artifactId>elastic-job-lite-core</artifa

Elastic-Job-分散式排程解決方案

Elastic-Job是一個分散式排程解決方案,由兩個相互獨立的子專案Elastic-Job-Lite和Elastic-Job-Cloud組成。 Elastic-Job-Lite定位為輕量級無中心化解決方案,使用jar包的形式提供分散式任務的協調服務。   官方