Announcement Announcement Module
Collapse
No announcement yet.
Stopping a read-write step without terminating job Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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, 03:48 AM.

  • #2
    got it

    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

    Comment

    Working...
    X