Spring Batch(一)

最近因爲工作需要抽空學習了一下Spring Batch,本次學習基於Spring Batch2.1.8。

Spring Batch是一個進行批處理的框架,系統中可能會有需要在後臺執行的不需要人工干預的任務處理要求,比如說定時計算報表數據,定時抽取數據等。

先來看Spring Batch官方給出的兩張圖:

 


從圖中可以看到Spring Batch被劃分爲三個模塊,Application,Core,Infrastructure,這三個模塊的定義是這樣的:

The Infrastructure provides the ability to batch operations together, and to retry an piece of work if there is an exception. 

The Core module is the batch-focused domain and implementation.

The Application module is focused on the business logic.

從三個模塊的定義可以看出三個模塊分別的關注點,Infrastructure 提供了一些基礎服務,Core提供了批處理領域相關的模型,Application則主要關注業務處理邏輯。平常對於使用Spring Batch主要在Application模塊。

Core模塊專注於批處理領域,它的設計採用了Domain-Driven Design,極大的簡化了理解的難度。最後設計出來的領域模型如下圖:


A Job has one to many steps, which has exactly one ItemReader, ItemProcessor, and ItemWriter. A job needs to be launched (JobLauncher), and meta data about the currently running process needs to be stored (JobRepository).


下面是JOB相關的幾個概念的類圖


從中可以看到一個JobInstance = Job + JobParameters,即表示Job運行時的一種狀態,如圖所示。


對應的表結構如下,這裏只是列舉一些表明關係的字段。


總體表結構




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