tWaitforFile triggers too soon

One Star

tWaitforFile triggers too soon

I need to use the trigger tWaitforFile component and then begin processing that file. The tWaitforFile component doesn't wait for the file to complete the transmission and prematurely begins the next step. tSleep won't help me because the file can be as many as 80 million rows and take an unknown amount of time to finish copying. How can I tell the component to trigger after file is finished?
- Bob
Community Manager

Re: tWaitforFile triggers too soon

Hello
The tWaitforFile is used to minitor a folder, if there is a new file created in this folder, it will tigger another action. on the next step, you can do your transmission. Note that, you should run the job first to monitor the folder.
Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: tWaitforFile triggers too soon

Maybe I wasn't clear. I need to use the file in the next step, but it isn't done getting to the folder. How do I make Talend wait until the file is copied completely?
One Star

Re: tWaitforFile triggers too soon

you have to use the tSleep component after your tWaitForFile component, and set it to sleep for as long as it takes for the file to get fully loaded
One Star

Re: tWaitforFile triggers too soon

But I don't know how long to make it sleep. Is there a way to detect if it is done?
One Star

Re: tWaitforFile triggers too soon

Not that I know of...
5484
maybe you could link to a tFileProperties and filter on a certain file size, but then you'd have to loop through (tWaitForFile -> tFileProperties -> tFilterRow) until the file was the size you wanted, so that might not be so helpful
One Star

Re: tWaitforFile triggers too soon

Thank you for opening an issue log. I am sure I am not the only one who would like to see this. I will try the file properties loop as you suggest and hope for an easier component someday.
One Star

Re: tWaitforFile triggers too soon

One Star

Re: tWaitforFile triggers too soon

Bob,
I had the same problem as you, maybe it will help you.
I use tWaitForFile to wait until my report is generated and once it is ready I send it as attachment in e-mail (tSendMail).
I added 1 extra line at the very bottom of script where I generate report to copy created file into the same folder.
I rebuilt my job and I have now:
tWaitForFile_1 --iterate--> tWaitForFile_2 --iterate--> tSendMail_1 --onComponentOk--> tFileDelete_1
In tFileDelete_1 I delete copied file (from tWaitForFile_2).
I hope it helps for you.
Marcin
One Star

Re: tWaitforFile triggers too soon

strpdsnk,
your solution looks more profesional.
Could you provide few lines of code with how it should be written for people who are not experienced in Java, please?
Thanks,
Marcin
One Star

Re: tWaitforFile triggers too soon

Bob,
There's always the "old way." I had a similar problem and had the people who send the file add a final step to THEIR job that generates the file to create a second file called "DONE" in the same directory. So, then all I have to do is look for DONE file. Because it only shows up when the sender job has completed writing the file.
One Star

Re: tWaitforFile triggers too soon

Is there a way to specify a quiesce time? ie. where the current time - last time the file was accessed/modified >= quiesce time. Can i open a request or bug on this somewhere?
One Star

Re: tWaitforFile triggers too soon

Since our file transfer could be anywhere from 5 seconds to 5 hours, we needed a solution that was checking the file. We didn't want to check the size changing because we felt this may be unreliable and we needed a 100% failure proof solution. Our solution to this was to use the tJavaFlex component and pur this code into the "start" code area. Use this component following the tWaitforFile.
CheckFileUsage FileChecker = new CheckFileUsage();
boolean fileInUse = true;
context.customerFileIn = ((String)globalMap.get("tWaitForFile_1_FILENAME"));

while (fileInUse) {
try{FileChecker.FileUseCheck (context.nasFolderIn + context.customerFileIn);
fileInUse = false; }
catch (IOException e) {System.err.println("ERROR TRAP");
System.err.println (e);}
}
- Bob
One Star

Re: tWaitforFile triggers too soon

Oh yeah....
this line --->> try{FileChecker.FileUseCheck (context.nasFolderIn + context.customerFileIn);
should have your file name in it.
- Bob