Announcement Announcement Module
Collapse
No announcement yet.
AbstractStep and failed steps Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AbstractStep and failed steps

    Hi,

    i am new to Spring batch and I have a question regarding the usage of AbstractStep. I have a step class that extends it and in case of an in-complete execution, the execute method returns ExitStatus.CONTINUABLE. I think that AbstractStep's doExecute, returns a status of Completed and there for my job, which only contains this single step, is not allowed to re-execute with the same parameters?

    is there a way of setting the exitStatus to failed without throwing an exception from the step's execute?

    thanks everybody,
    shahar

  • #2
    Actually, not being able to start multiple instances of the same Job is considered to be an important feature by design (as per the user guide). If you want to subvert that you can set the allowStartIfComplete flag on the Step (if you use one of the out of the box factory beeans).

    It shouldn't be necessary to implement the Step interface to achieve anything as simple as a status change. You can set the status using a listener. We usually recommend STOPPED (not FAILED) for a Job/Step that has been paused and will be restarted manually, which sounds like your use case. (Note also that in 2.0 a Step is no longer expected to throw an exception on failure, but that's a detail.)

    Comment

    Working...
    X