Spring Batch Learning (i) Introduction

Source: Internet
Author: User

Why do we need batch processing?
    1. We don't always want to get the information we need right away, the batch allows us to start collecting information on an established process before the request is processed, such as a bank statement, which we can generate on a monthly basis and open a batch process before the user queries.
    2. Sometimes it can make the business better, for example, when shopping online, it is not that you buy a product retailer immediately delivery, but four or five hours after the unified delivery;
    3. better use of resources; Let the processing capacity that should be used idle is a big waste, we can customize the processing so that one machine one by one running job can better utilize the machine's processing power;
What is batch processing?

Batch processing refers to the data processing without interaction and interference with the user, and once started, a batch process should run to the end without any interference;

Why use spring Batch?
    1. maintainability, spring batch allows you to rely on the dependency injection that the spring framework advocates to decouple objects, and generates a robust series of test units with the test tools provided by spring, which minimizes your maintenance risk;
    2. Flexibility, using spring Batch, you can share code between systems, such as you can use services that have been tested and debugged in your Web application;
    3. extensibility, in a batch job with no transaction management, you only need to remember some principles, and with some simple configuration, the whole batch process has the ability to rollback and commit the transaction;
    4. The learning curve is low, and if you have experience using spring, you can use spring batch only with a small learning curve, because spring batch is built on the spring framework, and it follows spring's conventions, like other spring-based applications , using other features of spring;
    5. Active community support;
Background and composition of Spring batch

The Spring batch framework is a collaborative project between Accenture and SpringSource, which uses a standard-based approach to implement common batch patterns and paradigms, and it implements features such as data validation, output formatting, and a reusable way to implement complex business rules, Ability to handle large data sets;

Spring batch consists of 3 layers:

The first layer is the application layer, which includes all the custom code, all the configuration, business logic, and services for the batch process, and note that the application layer is not above the other two layers, but rather encapsulates the other two layers (the core layer and the underlying framework layer). The reason is that most of the custom code you develop in the application layer works with the core layer;

The application layer is most often interacting with the next (core) layer, which contains all the parts that define the "batch domain", the elements of the core components include the job and step interfaces, and all the interfaces that execute the job: Joblauncher and Jobparameter;

The bottom layer is the underlying framework layer, in order to do some processing, you need to read or write data from a file, a database, or to cope with a job failure, which is considered as a common basic framework, placed in the framework of the framework of the infrastructure components.

Note: The most common misconception of spring batch is that it is a scheduler, but there is no way in spring batch to start a job at a predetermined time or triggered by an event, which is done externally.

Use spring batch to define the job

Spring batch contains a number of domain-specific concepts, including job, a job is a process composed of many steps, when a step fails, the job may be rerun or may not be rerun, a job process may also be based on a condition to run ; We can define a job in a ApplicationContext file like this:

<BeanID= "Accounttasklet"class= "Com.thoughtworks.springBatchDemo.AccountTasklet"/><JobID= "Accountjob">  <StepID= "Accountstep">    <Taskletref= "Accounttasklet"/>  </Step></Job>
Spring Batch Admin Project

Spring batch provides a number of administrative tools, such as starting or stopping a Spring batch job, viewing statistics about the last job run, and spring batch includes these features in a new plugin: Spring Batch Admin Project, which provides a web-based control center that allows you to control your batch process and monitor the performance of batch processing.

Spring Batch Learning (i) Introduction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.