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

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


总体表结构

本文介绍了SpringBatch批处理框架的组成及应用,包括其三个核心模块:Infrastructure、Core和Application的功能划分。深入探讨了Core模块的设计理念及其采用的领域驱动设计方法。
1659

被折叠的 条评论
为什么被折叠?



