PDA

View Full Version : Retryable batch problem



prana
Feb 13th, 2008, 06:16 AM
Hi ,
I have been trying to write different batch. I finished writing Hello World batch. It does not do anything but implements a tasklet .
I have some queries

- Can i directly work with spring batch framework without studying basic spring framework ?
- Now i want to go further and explore other features of batch processing like retryable batch job.
I could find code snipplet which gives basic retrying feature from www.springframework.org ,

RetryTemplate retryTemplate = new RetryTemplate();
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(5));
Object result = retryTemplate.execute(new RetryCallback() {
public Object doWithRetry(RetryContext context) throws Throwable {
// do some processing
return result;
}
});

If i want my batch to be retriable , where exactly this code has to be placed ?
Where can i get samples .?
Awaiting for some light.

Dave Syer
Feb 13th, 2008, 09:08 AM
Hi ,
- Can i directly work with spring batch framework without studying basic spring framework ?


Yes, probably, but I don't know if I would advise it. We did not design Spring Batch to be used by someone who knows nothing about Spring - it's the same programming model.


Hi ,
Where can i get samples .?


You already have the Spring Batch samples right? Spring programming examples are pretty easy to come by in the Spring distro, and the reference guide (http://static.springframework.org/spring/docs/2.5.x/reference/index.html).



If i want my batch to be retriable , where exactly this code has to be placed ?


It depends how you want the retry to behave. Maybe nowhere if you use a RetryPolicy in the step. Maybe that's not what you mean though. What scope do you want the retry to have (you said "batch", but that means different things to different people, and isn't part of our domain language)?

If you implement your own Tasklet, then it may need to handle retry internally (in 1.0.0.m4 the transaction boundaries are also expected to be handled by a custom Tasklet, if you go down that route), if the scope of the retry is smaller than a step. In that case the imperative style you quoted could go in the Tasklet itself (or you could do it declaratively with the RetryOperationsInterceptor).

prana
Feb 13th, 2008, 09:21 AM
Thanks Dave for prompt response. Will try it out.

shamuat
Mar 13th, 2008, 06:30 AM
Hello Prana

I see you have finished the first sample. Please help me. I am very new to spring batch.

As guided by the website I followed the following steps

mvn install-in cmd prompt
mvn eclipse:eclipse-in cmd prompt
And I configured external tools to eclipse.
I run src/test/java in eclipse
Itseems runs fine.

I dont know the above steps are correct or not. If there is any error pls forgive me.

Can u tell me the exact steps to run the spring batch sample and also I want to create my own sample. Where do I check my output.

Thanks in advance. Please help me...........