Create loop, execute, then continue with main flow

One Star

Create loop, execute, then continue with main flow

Hi
Im trying to solve something like this :
In main flow I call webservice, got list of items, then I need to call webservice for each item I've received in a loop, find correct subitem (response from webservice in loop) and continue with main flow.
So basically in pseudocode I need this :
list = webserviceCallback();
foreach(item : list) {
   response = webserviceCallback(item);
   if(item == expectedResult) {
       result = item;
       break;
   } 
}
continue main flow ...

What is the best way to achieve this ?
I tried the subjob, but Im not sure how to pass input variable there and retrieve output.
Another posibility would be create some sort of 'subflow' in main job, but Im not sure how to do this either.
Any thought or suggestions are welcome...
One Star

Re: Create loop, execute, then continue with main flow

I found a solution - 
1. create subjob
2. you can send input variables using context - subjob can has his own variables, which are not visible to context of main job
3. Output can be done via context variable by passing something by reference (e.g. concurenthashmap) 

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog