Java Reference
In-Depth Information
negative is a debit). The file ends with a single summary record containing the
number of records in the file.
2.
After importing the transactions into a transaction table, apply them to a
separate account summary table that consists of the account number and the
current account balance.
Generate a summary file ( summary.csv ) that lists the account number and
balance for each account.
3.
Looking at these steps from a design perspective, you want to validate that the number of records
you import matches the summary file before applying the transactions to each user's account. This
integrity check can save you many hours of recovery and reprocessing when dealing with large amounts
of data.
To start this job, let's look at the file formats and data model. The file format for this job is simple
comma-separated value (CSV) files. This lets you easily configure the appropriate readers and writers
with no code. Listing 6-22 shows example record formats for each of the two files you're using
( transaction.csv and summary.csv , respectively).
Listing 6-22. Sample Records for Each of the Two Files
Transaction file:
3985729387,2010-01-08 12:15:26,523.65
3985729387,2010-01-08 1:28:58,-25.93
2
Summary File:
3985729387,497.72
For this example, you also keep the data model simple, consisting of only two tables: Transaction
and Account_Summary. Figure 6-6 shows the data model.
Figure 6-6. Transaction data model
To create the job, begin with a fresh copy of the Spring Batch shell from the zip distribution as
covered in previous chapters. With your project set up, configure batch.properties to use your MySQL
instance as you have up to now.
When the boilerplate shell is ready to go, you can configure the job. Create a new file,
transactionJob.xml , in the <PROJECT_HOME>/src/main/resources/jobs directory, and configure the job as
shown in Listing 6-23.
Listing 6-23. transactionJob.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns=" http://www.springframework.org/schema/batch"
 
Search WWH ::




Custom Search