现在的位置: 首页 > 综合 > 正文

Spring Batch(一)

2018年05月19日 ⁄ 综合 ⁄ 共 916字 ⁄ 字号 评论关闭

最近因为工作需要抽空学习了一下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运行时的一种状态,如图所示。


对应的表结构如下,这里只是列举一些表明关系的字段。


总体表结构

抱歉!评论已关闭.