Java Reference
In-Depth Information
}
public void close() throws ItemStreamException {
delegate.close();
}
public void open(ExecutionContext arg0) throws ItemStreamException {
delegate.open(arg0);
}
public void update(ExecutionContext arg0) throws ItemStreamException {
delegate.update(arg0);
}
public void setResource(Resyource arg0) {
delegate.setResource(arg0);
}
}
The sole difference from a processing standpoint between what is shown in Listing 7-33 and what
you originally wrote in Listing 7-26 is the ability to inject a Resource. This allows Spring Batch to create
each of the files as needed and inject them into the ItemReader instead of the ItemReader itself being
responsible for file management.
When you run this example, Spring Batch will iterate through all of the resources that match your
provided pattern and execute your reader for each file. The output for this job is nothing more than a
larger version of the output from the multiline record example.
Listing 7-33. Output from Multiline Job
Warren Q. Darrow has 1 transactions.
Ann V. Gates has no transactions.
Erica I. Jobs has 5 transactions.
Joseph Z. Williams has 2 transactions.
Estelle Y. Laflamme has 3 transactions.
Robert X. Wilson has 1 transactions.
Clement A. Blair has 1 transactions.
Chana B. Meyer has 1 transactions.
Kay C. Quinonez has 1 transactions.
Kristen D. Seibert has 1 transactions.
Lee E. Troupe has 1 transactions.
Edgar F. Christian has 1 transactions.
It is important to note that when dealing with multiple files like this, Spring Batch provides no
added safety around things like restart. So in this example, if your job started with files
customerFile1.csv , customerFile2.csv , and customerFile3.csv and it were to fail after processing
customerFile2.csv , and you added a customerFile4.csv before it was restated, customerFile4.csv would
be processed as part of this run even though it didn't exist when the job was first executed. To safeguard
against this, it's a common practice to have a directory for each batch run. All files that are to be
processed for the run go into the appropriate directory and are processed. Any new files go into a new
directory so that they have no impact on the currently running execution.
 
 
Search WWH ::




Custom Search