Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Talend experts
I have got below job which reads next API URL until it finds one also it iterates for different course_ids. I have tweaked the design a bit to run parallel execution(the idea is to use parallel execution option of iterate) to execute multiple calls at a time.
StoreCourseID:
//globalMap.put("canvas_id", row1.canvas_id);
globalMap.put("V_API_URL" + row1.canvas_id, "https://swinburneonline.instructure.com/api/v1/courses/"+row1.canvas_id +"/analytics/student_summaries?per_page=100");
globalMap.put("V_LOOP"+ row1.canvas_id, true);
tLoop:
((Boolean) globalMap.get("V_LOOP"+ row1.canvas_id))
tRestClient:
((String) globalMap.get("V_API_URL" + row1.canvas_id))
GetNextUrl
System.out.println("Current URL IS: "+globalMap.get("V_API_URL"+ row1.canvas_id)); (prints correctly)
System.out.println("Rest URL"+ globalMap.get("tRESTClient_1_HEADERS")); (doesn't print and errors out to null)
java.util.List <STRING> strList = ((java.util.Map<STRING>>globalMap.get("tRESTClient_1_HEADERS")).get("Link");
SetNextURlToCurrUrl:
if ((Boolean) globalMap.get("V_LOOP"+row1.canvas_id))
; {
System.out.println("URL1 IS: "+globalMap.get("V_API_URL"));
globalMap.put("V_API_URL"+row1.canvas_id,globalMap.get("next_url"+row1.canvas_id));
System.out.println("URL IS: "+globalMap.get("V_API_URL"));
In doing so I have run into problem where Rest URL is always getting NULL when I get it from GetNextURL (tjava) component. Not sure what's wrong. Any help is really appreciated!
@rhall and @gr44: your input is really appreciated!!
Thanks
Harshal.
OK. Here is a way that might help. Put the part of the job which iterates over the web service calls in a separate job. That job should receive a context variable which holds the course_id. Keep in your current job the part of the process which iterates over the course_ids. Then use your new child job to be called by the iterate link supply the course_id. You can then try and execute that child job in parallel.
By doing this you are keeping the individual course queries in the same process. Therefore your "next_url" functionality will carry on the way it is.
If you are intending to use parallel execution you need to REALLY understand what you are doing. It won't gain you much here. I suggest you don't use it. Your problem is likely caused by the use of ....
globalMap.get("tRESTClient_1_HEADERS")This is a single instance of an object that you are using in parallel. As such you have no idea which parallel flow the result will correspond to.
OK. Here is a way that might help. Put the part of the job which iterates over the web service calls in a separate job. That job should receive a context variable which holds the course_id. Keep in your current job the part of the process which iterates over the course_ids. Then use your new child job to be called by the iterate link supply the course_id. You can then try and execute that child job in parallel.
By doing this you are keeping the individual course queries in the same process. Therefore your "next_url" functionality will carry on the way it is.
@rhall: Sorry for the earlier post. I did not quite understand. Then I implemented the way you mentioned and it is working.
It works fine.
Not sure what's the best value to parallelise. I am going to test out for 50 and see how it goes.
Make sure you test this thoroughly. You *may* find some timing issues, but this is a better way of attempting this.
I've just carried out a quick test and I don't see this issue in v6.5.1. What version are you using?