Results 1 to 2 of 2

Thread: Stopping a read-write step without terminating job

  1. #1
    Join Date
    Aug 2011
    Posts
    6

    Default Stopping a read-write step without terminating job

    Hello,

    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...
    any ideas?

    Thanks

    Daniel
    Last edited by danieln; Jun 18th, 2012 at 03:48 AM.

  2. #2
    Join Date
    Aug 2011
    Posts
    6

    Default got it

    Quote Originally Posted by danieln View Post
    Hello,

    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...
    any ideas?

    Thanks

    Daniel
    I managed to find a solution, albeit not the prettiest, it surely does the job..
    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
    Code:
    <streams></streams>
    section.
    This makes sure that the open,update and close methods will be called by the framework.

    Cheers

    Daniel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •