Automated, complex processing of large volumes of information that is most efficiently processed without user interaction, including time-based events (such as month-end calculations, notices, or correspondence).
Periodic application of complex business rules processed repetitively across very large data sets (for example, insurance benefit determination or rate adjustments).
Integration of information that is received from internal and external systems that typically requires formatting, validation, and processing in a transactional manner into the system of record.
Batch Stereotypes
A Job has one to many steps, each of which has exactly one ItemReader, one ItemProcessor, and one ItemWriter. A job needs to be launched (with JobLauncher), and metadata about the currently running process needs to be stored (in JobRepository).
In software engineering, a fluent interface is an object-oriented API whose design relies extensively on method chaining. Its goal is to increase code legibility by creating a domain-specific language. The term was coined in 2005 by Eric Evans and Martin Fowler.
https://en.wikipedia.org/wiki/Fluent_interface
Batch Step
A Step is a domain object that encapsulates an independent, sequential phase of a batch job and contains all of the information necessary to define and control the actual batch processing.
public interface ItemWriter<T>
voidwrite(java.util.List<? extends T> items)throws java.lang.Exception
Process the supplied data element.
Will not be called with any null
items in normal operation.
Parameters:
items - items to be written
Throws:
java.lang.Exception - if there are errors.
Chaining ItemProcessors
publicclassFoo{}
publicclassBar{
publicBar(Foo foo){}
}
publicclassFoobar{
publicFoobar(Bar bar){}
}
publicclassFooProcessorimplementsItemProcessor<Foo,Bar>{
public Bar process(Foo foo)throws Exception {
returnnew Bar(foo); //Perform simple transformation, convert a Foo to a Bar
}
}
publicclassBarProcessorimplementsItemProcessor<Bar,Foobar>{
public Foobar process(Bar bar)throws Exception {
returnnew Foobar(bar);
}
}
publicclassFoobarWriterimplementsItemWriter<Foobar>{
publicvoidwrite(List<? extends Foobar> items)throws Exception {
//write items
}
}
TaskExecutor implementation that fires up a new Thread for each task, executing it asynchronously.
Supports limiting concurrent threads through the "concurrencyLimit" bean property. By default, the number of concurrent threads is unlimited.
As requests come in, threads will be created up to 2 and then tasks will be added to the queue until it reaches 20. When the queue is full new threads will be created up to maxPoolSize, i.e. 4. Once all the threads are in use and the queue is full tasks will be rejected. As the queue reduces, so does the number of active threads.