This post is intended for java developers who want to write there first Spring Batch Application.
Please get the code from here.
I will explain this application in detail so that you can make modifications accordingly.
What this application does :
This post is about reading a CSV file(for this example, it is part of the application can be externalized in real time), validate the it, if valid record writes to one table, else writes to another and finally creates a email with all the records processed. In this example, email would not work since it runs on local, but if deployed on weblogic, email can be sent.
Explanation of Code:
Once you have the code add this application to your local weblogic, you can see the following files:
1. The main method of App.java, kick starts the batch. "oms-bulk-job.xml" is the file which has the batch configurations.
2. The xml file, has the reference of context.xml and database.xml which has the necessity Spring and DB configurations. Please make sure you provide your own DB configurations in dataSource section of database.xml file
Please get the code from here.
I will explain this application in detail so that you can make modifications accordingly.
What this application does :
This post is about reading a CSV file(for this example, it is part of the application can be externalized in real time), validate the it, if valid record writes to one table, else writes to another and finally creates a email with all the records processed. In this example, email would not work since it runs on local, but if deployed on weblogic, email can be sent.
Explanation of Code:
Once you have the code add this application to your local weblogic, you can see the following files:
1. The main method of App.java, kick starts the batch. "oms-bulk-job.xml" is the file which has the batch configurations.
2. The xml file, has the reference of context.xml and database.xml which has the necessity Spring and DB configurations. Please make sure you provide your own DB configurations in dataSource section of database.xml file
Also, the following section creates the necessary DB tables which is commented out in this example, Please run the batch with this section for first run and later comment out.
3. Coming back to the main xml file. Following section does the real job:
<batch:job id="OMSBulkOrgJob">
<batch:step id="step1">
<batch:tasklet>
<batch:chunk reader="cvsFileItemReader" writer="customWriter"
processor="orgItemProcessor" commit-interval="10">
<batch:listeners>
<batch:listener ref="customStepListener" />
< batch:listener ref="customItemReaderListener" />
<batch:listener ref="customItemWriterListener" />
</batch:listeners>
</batch:chunk>
</batch:tasklet>
</batch:step>
</batch:job>
This defines the reader, processor and writer with listeners.
4. The DAO impl classes write the valid data in BATCH_VALID_ORG and BATCH_VALID_ADDRESStable and invalid data in BATCH_INVALID_ORG table.
This example even the converts the input data as ACTIVE into the relevant code by looking into the master table.
5. All the listeners mentioned in this example are not exactly required, but i have kept them so that the users can get better understanding of the how the flow happens through the SOPs written
Please feel free to contact in case of any doubts!!!
.










