Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am not sure on which component you want to make this change. Do you want to create a tjava component? If possible can you send me the modified job . (Shong's job is available with this thread) as I am not an expertise in java and sending the job like how you did on your previous post, it will be more understandable and can help to extend this feature by me and anybody who is having such a similar issue in future.
Kindly assist.
@rhall wrote:
OK, you can keep most of your job structure (I would used @shong's example for this). What you have to remember is that the last part of your URL will adjust with every call. The code you will need to change is below.....
//Set the limit value int limit = 1000; //Set the skip value....(1000 x the current iteration of the loop) - 1000 int skip = (1000 * ((Integer)globalMap.get("tLoop_1_CURRENT_ITERATION")).intValue()) -1000; //Set the query value String query = "?query={}&limit=" +limit+"&skip="+skip; //Assign the query value to the query globalMap variable globalMap.put("query", query);You will then need to append ((String)globalMap.get("query")) to your URL.
I'm afraid I cannot do this for you since I do not have the time to reconfigure my system to do this. However, I have given you the bulk of the code you will need for this. You are right that this will need to be done in a tJava component.
The best way for you to get better at this is to struggle through this. You have all of the information you need, you just now need to work out how to implement it. Most of the work is done, you just need to think about variable names, etc
Does this code of yours require finding the count of the records before getting into the loop (for iteration)
The code uses the number of iterations of the loop to calculate the record numbers....
//Set the limit value int limit = 1000; //Set the skip value....(1000 x the current iteration of the loop) - 1000 int skip = (1000 * ((Integer)globalMap.get("tLoop_1_CURRENT_ITERATION")).intValue()) -1000; //Set the query value String query = "?query={}&limit=" +limit+"&skip="+skip; //Assign the query value to the query globalMap variable globalMap.put("query", query);
If we assume that the first iteration is iteration 1, then the query string will be....
"?query={}&limit=1000&skip=0"
The second iteration it will be....
"?query={}&limit=1000&skip=1000"
The third iteration it will be....
"?query={}&limit=1000&skip=2000"
Hi rhall_2_0,
I am attaching you the screenshot of the job which i have build, but I could not able to join a tloop with tjavarow directly also i am not sure what should be the schema to be on the tjava as the http component can only have responsecode as an output. shall i have the schema as query and the input in thttpresponse component as query and the output to be responsecode?
Can you see if I made all the parts correctly and also how shall i connect the tloop component with tjavarow component.
Let me know if i missed anything out. Kindly assist
Use a tJava component instead of a tJavaRow. tJavaRow components cannot be connected using "iterate" links, they need "Main" rows. Since the tLoop only provides an "Iterate" link, this needs to be considered. Link the tJava to the tHttpRequest using an "Iterate" link.
It should look something like this.....
tLoop --iterate--> tJava ---iterate--> tHttpRequest
Problem fixed. Some problem with my settings. Kindly ignore my previous posts.
Huge thanks to rhall_2_0 and shong for helping me out and making me to learn more about Talend and its capabilities.
Please continue your service to the community.
Glad you got it sorted!
I felt a little bad about appearing to try to make you struggle, but I was a little busy and do think struggling a little massively increases the amount you learn 🙂
Hi rhall_2_0,
Never feel bad. Given the timeline for me, I thought it cannot be done on time, but with your help, I can able to finish it in time.Thanks anyways and perhaps it did made me to learn more about the implementation.
I am also getting a WARNING message right now, though it does not affect the outcome of the job, I am little interested to know how can this be fixed. Let me know if you have any reasons in mind due to which this WARNING pops up while executing every time. Below is the URL of the topic which I posted,