Spring Batch Concepts Chapter

The below figure shows two kinds of Spring Batch components:infrastructure components and application components. The infrastructure componentsare the job repository and the job launcher. Spring Batch provides implementations for both – and you do need to configure these components – but there’slittle chance you’ll have to create your own implementations.

The main Spring Batch components. The framework provides ajob repository to store job metadata and a job launcher to launch jobs, and theapplication developer configures and implements jobs. The infrastructure components– provide by Spring Batch – are in gray, and application components –implemented by the developer – are in white.

Table ‘The main components of a Spring Batch application’

Component

Description

Job repository

An infrastructure component that persists job execution metadata

Job launcher

An infrastructure component that starts job executions

Job

An application component that represents a batch process

Step

A phase in a job; a job is a sequence of steps

Tasklet

A transactional, potentially repeatable process occurring in a step

Item

A record read from or written to a data source

Chunk

A list of items of a given size

Item reader

A component responsible for reading items from a data source

Item processor

A component responsible for processing(transforming, validating, or filtering) a read item before it’s written

Item writer

A component responsible for writing a chunk to a data source

How Spring Batch interacts with the outside world

A job starts in response to an event. You’ll always use theJobLauncher interface and JobParameters class, but the event can come fromanywhere; a system scheduler like cron that runs periodically, a script thatlauncher a Spring Batch process, an HTTP request to a web container thatlaunches the job, and so on.

Batch jobs are about processing data, and that’s why belowfigure shows Spring Batch communicating with data sources. These data sourcescan be of any kind, the file system and a database being the most common, but a job can read and write messages to Java Message Service(JMS) queues as well.

Jobs can communicate with data sources, but so does the job repository. In fact, the job repository stores job execution metadata in a databaseto provide Spring Batch reliable monitoring and restart features.

Spring Batch can run anywhere the Spring Framework can run:in its own Java process, in a web container, in an application, or even in anOpen Services Gateway initiative(OSGi) container. The container depends on your requirements, and Spring batch is flexible in this regard.

Spring Batch infrastructure need to deal mainly with two components: the job launcher and the job repository. These concepts match two straightforwardjava interfaces: JobLauncher and JobRepository.

The JobLauncher interface have run function, which acceptstwo parameters: Job, which is typically a Spring bean configured in Spring BatchXML, and Jobparameters, which is usually created on the fly by the launchingmechanism.

Who calls the job launcher? Your own java program can usethe job launcher to launch a job, but so can command-line programs orschedulers(like cron or the Java-based Quartz scheduler).

The job launcher encapsulates launching strategies such asexecuting a job synchronously or asynchronously. Spring Batch provides oneimplementation of the JobLauncher interface: SimpleJobLauncher.

The job repository maintains all metadata related to jobexecutions.

The JobRepository interface provides all the services tomanage the batch job lifecycle: creation,update, and so on.

What constitutes runtime metadata? It includes the list ofexecuted steps: how many items Spring Batch read, wrote, or skipped; theduration of each step: and so forth.

Spring Batch provides two implementations of theJobRepositorty interface: one stores metadata in memory, which is useful fortesting or when you don’t want monitoring or restart capabilities; the otherstores metadata in a relational database.

最新文章

  1. VM virtuaBox异常关机启动不了的解决方案
  2. 【转】无法将notepad++添加到打开方式列表中的解决办法
  3. Top ShooterHDU2863&&继续xxx定律HDU3784
  4. hdu 1513
  5. Hadoop如何恢复被删除的文件
  6. PHP高级笔记汇总
  7. epoll使用具体解释(精髓)
  8. 使用minidwep-gtk-PJ-wifi教程中文版
  9. python selenium2 中的显示等待WebDriverWait与条件判断expected_conditions举例
  10. JAVA核心技术I---JAVA基础知识(文本文件读写)
  11. 使用CORS方式跨域
  12. makefile中的gcc -o $@ $^是什么意思?
  13. Windows 10 Manager v2.3.3
  14. git 管理和存储二进制大文件
  15. 【高并发解决方案】7、一致性hash解读
  16. 【Linux高级驱动】平台设备驱动机制的编程流程与编译进内核
  17. The Google File System 中文版
  18. msys2 启用windows PATH环境变量
  19. Android 动态设置控件高度
  20. UVALive-3989 Ladies' Choice (稳定婚姻问题)

热门文章

  1. poj 3211 Washing Clothes
  2. 【转】iOS开发UITableViewCell的选中时的颜色设置
  3. 浏览器兼容——jquery的html()不兼容IE
  4. POJ 2549 Sumsets
  5. hdu 1026 Ignatius and the Princess I(优先队列+bfs+记录路径)
  6. Android功能模块化之生成验证码Bitmap
  7. 走向DBA[MSSQL篇] - 从SQL语句的角度提高数据库的访问性能(转)
  8. HDU5739 Fantasia 树形dp + 点双缩点
  9. 读pomelo的教程-1
  10. 转载--详解tomcat配置