[resolved] How to catch tFileFetch error

Hello everybody,
attached is the job I'm trying to make.
What I want is simply download a file with a tFileFetch and when it throws a error or exception loop it again until it succeed (I'm using a while loop).
When I pass a wrong uri to my tFileFetch, it loops exactly the way I expected. But when I pass the correct uri, it stills loop infinite times.
The question is, how can I know when my tFileFetch downloaded the file or when it throws a exception/error.

Thanks in advance,
Gabriel
8 REPLIES
Moderator

Re: [resolved] How to catch tFileFetch error

Hi,
Is there any response printed on your console when you check out option "Print response to console" in tFileFetch?
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.

Re: [resolved] How to catch tFileFetch error

Hi Sabrina,
the response is
*** Response Header ***
Date: Mon, 14 Jul 2014 13:11:56 GMT
Server: Apache/2.2.15 (CentOS)
Cache-Control: private
Expires: Wed, 31 Dec 1969 18:00:00 CST
P3P: CP="ALL"
Set-Cookie: JSESSIONID=8E295490C34A5AE3485802B92A5202EC; Path=/jasperserver-pro/; Secure; HttpOnly
Set-Cookie: userLocale=en_US;Expires=Tue, 15-Jul-2014 13:11:56 GMT;HttpOnly
Content-Length: 85406
Connection: close
Content-Type: application/pdf
and it keeps printing it infinite times and downloading the file infinite times.

Thanks for your help,
Gabriel
Four Stars

Re: [resolved] How to catch tFileFetch error

Hi Gabriel...
Set some flag at the end of file download...
Modify design and use RunIf condition on flag status, this will execute the download in case flag is unset ...
Vaibhav

Re: [resolved] How to catch tFileFetch error

Hi Vaibhav
I already tried it with tJavaRow, tJava and tJavaFlex with somthing like:
if(new java.io.File(context.filepath + "//" + context.filename).exists()){
globalMap.put("go_again", false);
}
but it didnt work (I don't know why...I think it should work)

Do you know another way of doing it?

thanks,
Gabriel
One Star

Re: [resolved] How to catch tFileFetch error

How about something like this instead? With the FileExists, you're breaking up the subjob, which in your case (being the same across) is causing the multiple downloads for each iteration. Hope this helps...
Four Stars

Re: [resolved] How to catch tFileFetch error

Hi Gabriel,
You have onSubJobOk link from loop... so, that subjob will continue forever
You will have to use one more link ahead of your last component and change the loop condition or break the loop...
Or use RunIf from loop while checking file download step for each iteration..
Vaibhav

Re: [resolved] How to catch tFileFetch error

Hi guys,
thank you all for the responses and help.
I solve it using a run if in my tFileFetch, checking if the file exists.
For this problem, it will work and I believe I won't have future problems with this solution. But the problem is that I am not getting the error or exception of the tFileFetch component (it could be a timeout, a bad request, etc) and I believe it would be interesting to have this kind of control on this component.

My job is working and if someone needs it in the future, the solution is attached. I put the run if on the tFileFetch component because I want to overwrite the file if it exists (only one time =D).

Thanks again for the help,
Gabriel

PS: now the solution is attached =D
Four Stars

Re: [resolved] How to catch tFileFetch error

Hi Gabriel,
Good that it resolved, whether the solution is same as Will have uploaded... if not can you pl upload the screenshot of your design?
thanks
vaibhav