Apr 7th, 2009, 08:15 AM
How to loop on a step ?
Evreything is in the title...how is it possible to loop on a step ?
I've got a list of item which are processed through a step (reader, processor, writer).
But these list is itself contained in an item which belongs to a list too.
so, I'd like to loop on this list and execute my step for each elements.
Is there a way to do that ? I saw something called "RepeatTemplate, RepeatCallBack, RepeatOperations" in the documentation. But I did not manage to understand how it works.
Is it possible to read a step ?
How should I configure this in the context.xml ?
Thanks a lot for helping me !
Apr 7th, 2009, 08:42 AM
The other option is write a JobLauncher that loops through items in the outer list and launches a job for each one. Then you could use the ItemReader to read items from the inner list.
It really depends on whether you need to be able to skip individual inner-list items or if skipping an entire outer-list item is ok.
Apr 7th, 2009, 08:49 AM
Thanks for your answer.
Actually, I need to be able to skip each individual inner-list items.
That's why I thought that I could configure my step for the inner list. And then, loop on this step for each element of the outter list.
And, it seems that it is not possible so easily ? right ?
Apr 7th, 2009, 08:53 AM
This problem is that you can only skip an "item" where an "item" is the thing returned from an ItemReader. So i would suggest that you put the loop in the JobLauncher and launch a job for each outer-list item.
Apr 7th, 2009, 09:00 AM
Ok, I'll try that. But the documentation does not provide lot of information about the JobLauncher. Is there a link where I could find more information ?
Moreover, just one more question, if I cannot repeat my step. What's the aim of the RepeatTemplate ?
Thank for your help.
Apr 7th, 2009, 09:12 AM
For the JobLaucher, you should just copy the SimpleJobLaucher and modify it to fit your needs.
As for the RepeatTemplate, there is looping happening: at the job-level over steps and at the step-level over items. There just isn't looping at a level below that.
Apr 7th, 2009, 09:35 AM
I'm trying to implement what you said. But, actually, there still is a problem with this solution.
How can I provide my outer-list to the job launcher as it is not provided as a parameter.
Here is the process I need (maybe I was not clear enough)
1) Call to a service which provides the outer-list
2) Iteration on this outer-list (L1)
3) For each item, call to a service with L1 item as a parameter
4) Get the inner-list from each item of the outer-list
5) Iteration on this inner-list (L2)
6) For each item, call to a service with L2 item as a parameter
7) Call to a service with L1 item as a parameter
So, looping in the JobLauncher will help for steps 2 to 7. But what about the step 1 ?
Where could I call my service ? I don't know...
Apr 7th, 2009, 09:53 AM
You can call the service from the JobLauncher
Apr 7th, 2009, 09:57 AM
Sorry, this, I could have found it by myself. I'm wondering so many questions that I even don't see the evidence...
Apr 7th, 2009, 10:07 AM
By the way, do you think that, by modifying the task executor, it would be possible to process these jobs in parallel threads ?