View Full Version : How can I put some operations between steps?
zzpaul
Jan 13th, 2008, 07:26 PM
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.
Dave Syer
Jan 14th, 2008, 02:34 AM
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.
dkaminsky
Jan 15th, 2008, 01:42 PM
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
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.