Jun 18th, 2012, 02:54 AM
Stopping a read-write step without terminating job
I implemented a chunk tasklet with a flat file reader.
I would like to implement a stop mechanism that will exit this chunk read-write step according to a business stop condition. I want the step to exit with a specific exit status according to the stop condition met (there are few).
However, I don't want the Job to terminate, I want to examine the exit status and invoke other steps accordingly.
So far, I did not find any way to accomplish that.
* setTerminateOnly() terminates the job
* throwing an exception terminates the job
* i cannot return null in the reader, since i user the provided flat file reader.
Only option i see is extend FlatFileItemReader and override read() to return null if should stop. Ugly...
Last edited by danieln; Jun 18th, 2012 at 03:48 AM.
Jun 19th, 2012, 12:31 AM
I managed to find a solution, albeit not the prettiest, it surely does the job..
Originally Posted by danieln
So here it is, in hope it might help someone in need..
What I did is wrap FlatFileItemReader inside a class (proxy) and implement the read() method, in which the stop logic is implemented and null is returned accordingly.
Other than that there is nothing more in the proxy class.
In the XML configuration I declared the proxy as the reader attribute of the chunk and the wrapped FlatFileItemReader as a stream in the
This makes sure that the open,update and close methods will be called by the framework.