tWaitForFile : how to know that no file has been detected

Highlighted
One Star
One Star

tWaitForFile : how to know that no file has been detected

I specified a timeout time (in seconds) in tWaitForFile component
but at the end, how to know if no file has been detected ?
I tried a ((Integer)globalMap.get("tWaitForFile_1_CURRENT_ITERATION")) == 0 in a "if" link
But it dosen't work
What can I do ?
Highlighted
Moderator

Re: tWaitForFile : how to know that no file has been detected

Hi,
Component tWaitForFile provide several globalMaps.
You can get the file name and the number of iterations by using them.
For example, I have designed a job as:tWaitfile-->tjava(see my pic 12).
Get the globalMap in tjava
String filename=((String)globalMap.get("tWaitForFile_1_FILENAME"));
int Iteration=((Integer)globalMap.get("tWaitForFile_1_CURRENT_ITERATION"));
System.out.println(filename);
System.out.println(Iteration);

In tWaitFile, set the "a file is created" as trigger.
At last, when I create files in my directed folder, the result will give "filename" and number of "iteration" to us.
but at the end, how to know if no file has been detected ?
I tried a ((Integer)globalMap.get("tWaitForFile_1_CURRENT_ITERATION")) == 0 in a "if" link

If you want to get the number of detected files, you should define a counter by yourself and the code in tjava is
context.counter=context.counter 1;
System.out.println(context.counter);

(see my pic 3,4,5)
Please refer to my screenshots
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Highlighted
One Star
One Star

Re: tWaitForFile : how to know that no file has been detected

Thanks for your help
But I found the solution by myself :
To know if no file has been detected in a tWaitForFile component after its max duration (sort of timeout), we have to test the "((Integer)globalMap.get("tWaitForFile_1_CURRENT_ITERATION")) == <max iterations> " in a "if" link

2019 GARTNER 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

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog