Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

tBufferOutput reset when runjob is finished

Hello all,
I have a main job which calls many child jobs. For each child job which ended normally, I add a line to a tBufferOutput to tell which one went OK.
The Talend job class is loaded with Spring in a Map, as a singleton bean (one process can call many jobs, listed in that Map). So, each time I run the job, it is the same instance (not the child jobs as the parent job instantiates them when needed).
My problem is that form the second time I call the job, it also returns the entries I added during the previous call(s) in the tBufferOutput.
I think this is 'normal' as I use it as a singleton, but it is well a bug for me.
Here is the runjob method when a tBufferOutput is added to the job :
	public final java.util.List<String[]> globalBuffer = new java.util.ArrayList<String[]>();
...
...
public String[][] runJob(String[] args) {
int exitCode = runJobInTOS(args);
String[][] bufferValue = (String[][]) globalBuffer.toArray(new String[]);
return bufferValue;
}

The cleanest way would be to clear the globalBuffer as soon as it is copied to 'bufferValue'.
What do you think?
Cheers,
Labels (3)
6 Replies
Anonymous
Not applicable
Author

I noticed this problem a little time ago, and created a component to solve it :
http://www.talendforge.org/exchange/tos/extension_view.php?eid=152
This component is a fork of "tBufferOutput" with an option to clear the buffer before using it.
Anonymous
Not applicable
Author

Maybe it's a little too late to answer but it could help other people which came on the forum.
to clear the buffer you can place a tJava on your job and write into "globalBuffer.clear()".
It could more easy to use than importing developed componant. 0683p000009MACn.png
Anonymous
Not applicable
Author

Maybe it's a little too late to answer but it could help other people which came on the forum.
to clear the buffer you can place a tJava on your job and write into "globalBuffer.clear()".
It could more easy to use than importing developed componant. 0683p000009MACn.png

Hi
Good tip! Thank you~
Best regards
Shong
josephmundadan
Contributor
Contributor

Maybe it's a little too late to answer but it could help other people which came on the forum.
to clear the buffer you can place a tJava on your job and write into "globalBuffer.clear()".
It could more easy to use than importing developed componant. 0683p000009MACn.png

Thanks. That has really helped.
Anonymous
Not applicable
Author

Maybe it's a little too late to answer but it could help other people which came on the forum.
to clear the buffer you can place a tJava on your job and write into "globalBuffer.clear()".
It could more easy to use than importing developed componant. 0683p000009MACn.png

Thanks! Thats really helpfull 0683p000009MACn.png You could also use tHashOutputs like this if you were planning on linking more than one tBufferOutput to a tBufferInput:
---> tHashOutput1 (append off) ---> tHashInput1 \
--> tUnite1 --> rest of job
---> tHashOutput2 (append off) ---> tHashInput2 /
Although theres no need to do this if you use Dolans suggestion 0683p000009MACn.png
Anonymous
Not applicable
Author

Thank you!