
What is the Spring Batch and why do we need it? This course describes some batch process requirement and a real-world use case.
Spring Batch has following characters:
Able to Process the large amount of data
Automation
Robustness
Reliability
Performance
There are a lot of out of boxes components you can use to quickly create a batch job to process CSV file, JSON, XML, Message queue and RDBMS. You can also turn an existing batch to a high performance batch with adding a few lines of code.
This session walks you through how to use IntelliJ to create a Spring Batch job. It uses Spring Initializer and Maven to create the basic project structure. It also discussed two important annotations, @EnableBatchProcessing and @SpringBootApplication.
The Helloworld Spring Batch is simply print a "Hello World" on the console, but it touches a few important components, such as JobBuilderFactory, StepBuilderFactory and in-memory H2 Database as Job Repository.
Review the key annotations, @EnabledBatchProcessing, @SpringBootApplication, and H2 Database.
Discuss the basic difference between Task-based step and Chunk-based Step.
Discuss the Joblunacher, Job, and Job Repository
Discuss what is Job, Job Instance and Job Execution
Discuss what is the step, step execution and execution context.
Review Spring Batch architecture, how each component works together.
Through a real example, to understand Job, job Instance, Job Execution, Step, Step Execution, and Step Excution Context.
Discuss what is a chunk-based step and how the reader, processor, and writer works together?
Walk you through an example to create customized the item reader and customized item writer.
Summary of the customized item reader and customized item writer.
How to download MySQL binary and install it and create a Spring batch schema from MySQL Workbench.
How to configure the MySQL into application properties
Add the MySQL Driver into the InteliJ
Use MySQL as the batch job repository and understand how the job instance and job execution are represented in the database.
Job Parameter determines job instance, understands how to make Job re-runnable.
How the Job Parameters works in Spring Batch.
Review the core concept and domain language of the Spring Batch Job.
Introduce the Spring Batch Item Reader
Create your first Item reader - Flat File ItemReader which read from the CSV file and printed on the console.
Improve the FlatFileItemReader you created in the previous session. This video shows you how to use Job Parameter to pass the filename to the reader.
How to set different delimiter in the reader.
Introduce the XML Item Reader
XML reader is required a bit more than a flat-file Item reader, but Spring batch made it easier. In this video, we will show you how easy you can create an Itemreader to the reader from an XML file.
Introduce the Fixed-Length Item Reader
In this example, we will show you how quickly you can create an item reader that reads from a flat-file.
Read from the database is a very common task in the enterprise. In the next few sessions, we will cover these topics in detail.
We will cover the JDBC Cursor Item reader in this example. It will show you how to connect to MySQL database, convert the database row to the domain object.
With the non-structure database used by more organizations, reading from the JSON file is getting more popular inside the enterprise.
In this video, we will demonstrate how to create ItemReader that can read from the JSON file and convert it into the domain object.
You will not always able to access directly to the database, especially in large organizations and banks, the only thing you can access is the service bus, web service. Reading from the existing Web Service and process them become extremely important in recent times.
In this video, we will create a REST Web Service to provide the products.
In this video, we will create an ItemReader to read from our Product REST Service. You will learn what is Service Adapter in Spring Batch.
Review the read from service.
We will introduce the three major ItemWriter. FlatFile ItemwWirter, XML ItemWriter and Database ItemWriter.
Writing into the flat file is a reversed process of reading from it. You need to construct the Resource and LineAggregator.
Create a Simple FlatFile Item Writer.
Create the header and footer into the file.
Summary of what we have learned in FlatFileItemWriter.
Introduce XML ItemWriter
Create an XML ItemWriter.
Introduce Database ItemWriter.
Create the JDBC Item Writer.
Processing an Item.
Introduce the Item Processor
In the real world, your application will encounter the bad records, or network issues, in this session, we will discuss what is available to allow you to create a robust Spring Batch Jobs.
In this video, we will show you how to configure the job to Skip the bad record.
Skip Policy will provide more comprehensive settings to allow you to control how to skip and when to skip.
How to Skip the record during the writing.
In this video, we will show you how to Skip a bad record during the writing process.
How to create the retry logic.
How transaction management works in Spring Batch.
Spring Batch provides a scaling framework and various implementations to improve the performance of jobs and steps through configuration changes with minimum code. We will discuss the following four methods to improve job execution: Multi-threaded job, Async step, Parallel flow, and Partitioning.
The easiest way to improve the job performance is to make it multi-threaded. In this video, we walk you through the basic concept of the multi-threaded step.
You will be amazed at how little the code is needed to make an existing job multi-threaded. The example demonstrated how to turn an existing job into a multi-threaded job.
Summary of what is needed to create a multi-Threaded job.
Async Step allows the processor not to wait for the execution to complete and move on to the next item.
In this video, we will show you how to Async process with minimum code
Summary of the Async processing
Introduce the Parallel Flow in Spring Batch
By creating a few dummy spring batch tasklets, you will understand how the Parallel flow works in the context.
Review what we have learned of the Parallel flow job.
In many scenarios, you want to take different actions based on the result of the step or flow. Spring Batch allows you to trigger different steps or flows based on the success or failure of previous steps.
Through a coding example, walk you through how to control flow based on the result of the previous steps.
Review what needs to happen in Spring Batch Flow control.
Partitioning uses multiple threads to process a range of data sets. The range of data sets can be defined programmatically. It’s on the use case, how many threads we want to create to be used in a partition(s). The number of threads is purely based on the need/requirement.
Partitioning is useful when we have millions of records to read from source systems and we can’t just rely on a single thread to process all records, which can be time-consuming. We want to use multiple threads to read and process data to effectively use the system resources
By creating the RangePartitioner, you will understand how the partition works in Spring Batch. This example also demonstrated how to create a partition step and how to link the partition step with slave steps.
Creating a generic ColumnRangePartitioner which can handle any table and any column. This will be a very useful code for your production.
Through a real example to demonstrate how to organize the Batch configuration more organized and modular.
Enterprise still running on Batch jobs. During the night, tons of batch processing will be kicked out. In this course, we will introduce the Spring Batch, a mature framework to allow you to create a professional batch job without much effort. In the olds days, you will take days to create a good batch job, with spring batch it takes no more than 1 hour. The most important thing is that Spring batch provides a standard framework so all you batch jobs will become supportable and maintainable.