Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: How to loop on a step ?

  1. #1
    Join Date
    Feb 2009
    Location
    Paris
    Posts
    30

    Default How to loop on a step ?

    Hi all,

    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 !

  2. #2
    Join Date
    Feb 2008
    Posts
    488

    Default

    See: http://forum.springsource.org/showpo...20&postcount=9

    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.

  3. #3
    Join Date
    Feb 2009
    Location
    Paris
    Posts
    30

    Default

    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 ?

  4. #4
    Join Date
    Feb 2008
    Posts
    488

    Default

    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.

  5. #5
    Join Date
    Feb 2009
    Location
    Paris
    Posts
    30

    Default

    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.

  6. #6
    Join Date
    Feb 2008
    Posts
    488

    Default

    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.

  7. #7
    Join Date
    Feb 2009
    Location
    Paris
    Posts
    30

    Default

    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...

  8. #8
    Join Date
    Feb 2008
    Posts
    488

    Default

    You can call the service from the JobLauncher

  9. #9
    Join Date
    Feb 2009
    Location
    Paris
    Posts
    30

    Default

    mmmmh...true !
    Sorry, this, I could have found it by myself. I'm wondering so many questions that I even don't see the evidence...

    Thanks !

  10. #10
    Join Date
    Feb 2009
    Location
    Paris
    Posts
    30

    Default

    By the way, do you think that, by modifying the task executor, it would be possible to process these jobs in parallel threads ?

Posting Permissions

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