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.

Spring Batch Concepts Chapter的更多相关文章

  1. spring batch(一):基础部分

    spring batch(一):基础部分 博客分类: Spring java   spring batch 官网: http://www.springsource.org/spring-batch 下 ...

  2. Spring Batch Framework– introduction chapter(下)

    Extract,Transform, and load(ETL) Briefly stated, ETL is a process in the database anddata-warehousin ...

  3. spring batch(二):核心部分(1):配置Spring batch

    spring batch(二):核心部分(1):配置Spring batch 博客分类: Spring 经验 java   chapter 3.Batch configuration 1.spring ...

  4. Spring Batch在大型企业中的最佳实践

    在大型企业中,由于业务复杂.数据量大.数据格式不同.数据交互格式繁杂,并非所有的操作都能通过交互界面进行处理.而有一些操作需要定期读取大批量的数据,然后进行一系列的后续处理.这样的过程就是" ...

  5. spring batch资料收集

    spring batch官网 Spring Batch在大型企业中的最佳实践 一篇文章全面解析大数据批处理框架Spring Batch Spring Batch系列总括

  6. Spring Batch学习笔记三:JobRepository

    此系列博客皆为学习Spring Batch时的一些笔记: Spring Batch Job在运行时有很多元数据,这些元数据一般会被保存在内存或者数据库中,由于Spring Batch在默认配置是使用H ...

  7. Spring Batch学习笔记二

    此系列博客皆为学习Spring Batch时的一些笔记: Spring Batch的架构 一个Batch Job是指一系列有序的Step的集合,它们作为预定义流程的一部分而被执行: Step代表一个自 ...

  8. 初探Spring Batch

    此系列博客皆为学习Spring Batch时的一些笔记: 为什么我们需要批处理? 我们不会总是想要立即得到需要的信息,批处理允许我们在请求处理之前就一个既定的流程开始搜集信息:比如说一个银行对账单,我 ...

  9. Spring Batch 中文参考文档 V3.0.6 - 1 Spring Batch介绍

    1 Spring Batch介绍 企业领域中许多应用系统需要采用批处理的方式在特定环境中运行业务操作任务.这种业务作业包括自动化,大量信息的复杂操作,他们不需要人工干预,并能高效运行.这些典型作业包括 ...

随机推荐

  1. 【JS】js获得下拉列表选中项的值和id

    function tijiao(){ var elem = document.getElementById("dish_sort"); var index=elem.selecte ...

  2. Python easy_install

    系统中有高版本的Python, 直接pip3 install ipcalc安装,都是装到高版本的Python 系统默认的Python是2.7.6,现在想装到默认版本中,可以使用easy_install ...

  3. innodb buffer pool

    add page to flush list buffer pool中的page,有三种状态: l  free:      当前page未被使用 l  clean:    当前page被使用,对应于数 ...

  4. 滑屏 H5 开发实践九问

    滑屏的交互形式自从在 H5 中流行起来,便广泛应用在产品宣传.广告.招聘和活动运营等场景中,作为微信朋友圈广告惯用的形式,其影响力更是得到了强化与放大.如今滑屏H5可谓玲琅满目,数不尽数. 作为一个 ...

  5. equals(),hashcode()方法详解

    Java中的equals方法和hashCode方法是Object中的,所以每个对象都是有这两个方法的,有时候我们需要实现特定需求,可能要重写这两个方法,今天就来介绍一些这两个方法的作用. equals ...

  6. Reading or Writing to Another Processes Memory in C# z

    http://www.jarloo.com/reading-and-writing-to-memory/ Declarations [Flags] public enum ProcessAccessF ...

  7. BLOCK 死循环

    __weak typeof(self) weakSelf = self; myObj.myBlock =  ^{     __strong typeof(self) strongSelf = weak ...

  8. 让Apache支持ASP.NET

    Apache是目前广泛使用的一种网络服务器程序,不仅在UNIX/LINUX平台上被大量使用,而且在Windows平台上也有许多站点放弃了IIS 而转向Apache..NET是微软推出的功能强大的开发技 ...

  9. Handling HTTP 404 Error in ASP.NET Web API

            Introduction: Building modern HTTP/RESTful/RPC services has become very easy with the new AS ...

  10. csv文件与DataTable互相导入处理

    封装处理下,以后项目用到可以直接使用,比较简单. 1.首先看封装好的类 using System; using System.Data; using System.IO; using System.T ...