Results 1 to 3 of 3

Thread: How can I put some operations between steps?

  1. #1
    Join Date
    Oct 2007
    Posts
    2

    Default How can I put some operations between steps?

    How can I put some operations between steps?
    For example, how can I put a process to sleep for a period of time before continuing to the next step.

  2. #2
    Join Date
    Jun 2005
    Posts
    4,241

    Default

    I can suggest a few ways (there may be more): make a new step, or add a RepeatInterceptor to one of the other steps via the stepOperations, or use step scope for your tasklet and add code to the initializer (eg unit-method). Have a look in the samples for a job using a repeat interceptor.
    Last edited by Dave Syer; Jan 14th, 2008 at 02:35 AM. Reason: spelling

  3. #3

    Default

    As Dave points out, there are several ways to accomplish this. To expound a little on one of his suggestions, when you use "step" scoped beans, you gain access to all of the Spring features that wrap the bean's lifecycle, for instance, the "init-method" and "destroy-method" attributes of the <bean> tag. Alternatively, you can declare your beans as InitializingBean or DisposableBean and handle your needs that way. Similarly, you can use the RepeatInterceptor pattern.

    This is very useful for cleaning up connections or open files (or gathering custom metadata / performing extra logging in the case of the repeat interceptor), but I would not recommend using this for business logic. I submitted an issue to address this, please comment on it if you have any suggestions.

    See: http://jira.springframework.org/browse/BATCH-151

Posting Permissions

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