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.
Highlighted
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

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 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Why Companies Move to the Cloud: 7 Success Stories

Learn how and why companies are moving to the Cloud

Read Now