Issue Details (XML | Word | Printable)

Key: BATCH-266
Type: New Feature New Feature
Status: Open Open
Priority: Major Major
Assignee: Dave Syer
Reporter: Rajiv Kumar
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Spring Batch

Need RetryPolicy at Step and Job Level

Created: 31/Dec/07 07:18 AM   Updated: 28/Oct/08 03:15 AM
Component/s: Core
Affects Version/s: 1.0.0
Fix Version/s: None

Time Tracking:
Original Estimate: 1d
Original Estimate - 1d
Remaining Estimate: 1d
Remaining Estimate - 1d
Time Spent: Not Specified
Remaining Estimate - 1d


 Description  « Hide
Currently I see the retrypolicy used for ItemProviderProcessorTasklet. We have a requirement for the retry policy at the step level (for tasklets other than ItemProviderProcessorTasklet e.g. FileTransferTasklet) and at job level

 All   Comments   Work Log   Change History   FishEye   Builds      Sort Order: Ascending order - Click to sort in descending order
Dave Syer added a comment - 31/Dec/07 07:45 AM
You may have to add the retry logic to your custom code - the Tasklet you have implemented or the client that calls the JobLauncher. N.B. it may be possible to do this declaratively using the RetryOperationsInterceptor. If this is not convenient please explain why, otherwise I'll close this issue.

Rajiv Kumar added a comment - 06/Mar/08 01:22 AM
We can put the retry logic in the tasklet only at places where we are expecting some failure but the case like above can happen anywhere in the flow of the job execution so would better be handled at the framework level.

We can also put logic in the client that calls the JobLauncher but that launcher is using threadpool executor and in that case we do not get the control back to the client.

We are having problem when the jobs abort because the connection to database is broken temporarily and status of the jobs remains as STARTING or STARTED because the spring batch also would not be able to update the database with the FAILED status. In that case, retry at job should fix the issue.

Until the retry is there at the job level, we are planning to create a cleaner job which runs every minute, checks the status of each jobs and if the job status is STARTED or STARTING but the job has aborted then restarts the job. But we do not know how to find out whether the job has really aborted or is still running. Can you guide us how we can achieve that?

Thanks,
Rajiv

Dave Syer added a comment - 06/Mar/08 02:37 AM
It would be much easier to use RetryTemplate or RetryAdvice (the name was changed) to wrap you calls to the step, job or launcher. I would not recommend implementing any of those interfaces yourself, so if you want to use RetryTemplate then it has to go in the client that calls the launcher. For the AOP approach it is non-invasive in all cases and should not require you to implement any framework interfaces. You are correct that this is a framework concern, and that is one reason why we provide those tools.

Lucas Ward added a comment - 09/Apr/08 05:41 PM
Given the StatefulRetryStepFactoryBean added in rc1, and Dave's comments about the interceptor, it looks like this issue can be closed?

Dave Syer added a comment - 10/Apr/08 02:18 AM
I'd like to leave it at 2.0. The declarative approach might be fine for some applications, but I want to revisit when we have more of an idea how people are triggering jobs, and see if we can add any value there.

Dave Syer added a comment - 02/Sep/08 10:03 AM
There isn't time to do this for 2.0. Moving to future release. Could be 2.x

Dave Syer added a comment - 28/Oct/08 03:13 AM
Step-level retry can be implemented using a StepExecutionListener that throws an exception (to trigger the retry - in 2.0 steps never throw exceptions in normal circumstances), and a RetryOperationsInterceptor around Step.execute() (targeted with bean= or an old style ProxyFactoryBean), or with a Tasklet / retry combo. We could still look at this in a later release so I'll leave it open. At the job level retry would be a scheduling concern, and not really in scope for Spring Batch. Might be addressed in the enterprise offering.