Capture the output of tJava in a file or another Talend Component?

One Star

Capture the output of tJava in a file or another Talend Component?

Hello. I use a tJava component to call a third party API - the method being SHOWRUNNINGTASKS in their API library.
The tJava writes the following XML to the output console when the task is run. But how do I capture this output and save it in a file or use it for processing further such as extracting the TaskID element's value?
I'm new to Talend, and I couldn't find anything along this scenario in the forums.
Thank you.

<Response>
<CmdName>SHOWRUNNINGTASKS</CmdName>
<ReqID>4</ReqID>
<RepCode>0</RepCode>
<RepText></RepText>
<Time>2010-09-15 12:57:44</Time>
<Output>
<Tasks>
<SchedulerStatus>On</SchedulerStatus>
<Task>
<TaskID>847934091</TaskID>
<TaskName>SomeTask</TaskName>
<NominalStart>2010-09-15 12:46:00.00</NominalStart>
<TimeStarted>2010-09-15 12:50:17</TimeStarted>
<StartedBy>Scheduler</StartedBy>
<Status>Finding matching files on \\ShareX\ftp</Status>
<CurFileBytes>0</CurFileBytes>
<TotFileBytes>0</TotFileBytes>
<LastErrorType>0</LastErrorType>
<LastErrorText></LastErrorText>
</Task>
</Tasks>
</Output>
</Response>

If a similar question is asked before, please point me to it. Thank you again.
One Star

Re: Capture the output of tJava in a file or another Talend Component?

Can anyone help me with this please?
Community Manager

Re: Capture the output of tJava in a file or another Talend Component?

Hello
Export the job script, create a new job and use tSystem component to call this job script. On tSystem, select "to global variable' on the standard output list. On a tJava component, get value of global variable and parse/split it to the expected result as you showed in the post, store the expected result to a global variable. In the next process, get the value of global variable on tFixedFlowInput and extract the TaskID element's value on tExtractXMLField, For example:
tSystem_1
|
onSubJobOK
|
tJava
|
onsubjobok
|
tFixedFlowInput--main--tExtractXMLField--tLogRow
on tJava:
String result=((String)globalMap.get("tSystem_1_OUTPUT");

Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.

Download

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch

Downloads and Trials

Test drive Talend's enterprise products.

Downloads