user1486984
user1486984

Reputation: 297

Catching ftp exception in Talend and retrying

I have a Talend job where i am making a ftp connection and downloading a file. I wanted to add capability where if the ftphost is not responding i can retry connecting n times before killing the job. I looked at lLogCatcher and tLoop but that doesn't seem to serve the purpose. Any pointers on which direction i should take would be appreciated.

Upvotes: 2

Views: 2596

Answers (1)

54l3d
54l3d

Reputation: 3973

To catch Exception, you can use a tJavaFlex containing a try and catch, then by playing with conditions you can use tLoop, I have developed this small job because i love challenging, and its works fine enter image description here

  1. We need 2 context variable:

    • trynb : int ( max tries number )
    • isitok : int (default 0, we will use it later )
  2. tLoop settings, use while type:

enter image description here

  1. tJava_1: its just to generate different ip so i can perform the test, you can remove it for your case.

  2. tJavaFlex: to catch Exception, write try{ in start code box and }catch(Exception e){System.out.println("to the next try ");} in the end code box. You MUST use iterate to connect the next component.

  3. tFTPConnection: your FTP settings.

  4. tJava_2: if tFTPConnection is ok, we need to make tLoop break looping by altering the context variable, write this line: context.isitok=1;

  5. tJava_3: just to ensure orchestration, it have no code.

  6. If (order:1) : ((Integer)globalMap.get("tLoop_1_CURRENT_ITERATION")) < context.trynb

  7. If (order:2) : ((Integer)globalMap.get("tLoop_1_CURRENT_ITERATION")) >= context.trynb

Upvotes: 4

Related Questions