Skip to Content

Hi All,

Recently, we have received one requirement where we were picking files from three different systems using FTP server and then merge them. The requirement become complex when we had to check the existence of all files at their source directory and stop if any one of the file is absent.

To achieve this requirement, we have made one scenario where we will create one sender channel which will be in test mode. That channel will always pick test file and consequently our mapping will execute. In message mapping, we have written three single values udf which will check for the files on ftp server and and pick all three files. If any one of the file is absent,it will throw runtime exception and mapping execution will stop there itself.

For better understanding you can follow below map.

diagram.PNG

For working on FTP server from PI, we have used Apache FTP executable libraries which you can find on apache.org

Step1: To import Jar file on apache libraries in imported archive

archive.PNG

Step 2: Accessing FTP Server using FTPClient class

init.PNG

We can connect using connect and login method FTPClient and get all files list in the directory and then check for our file if it exists there.

def1.PNG

At last we will read all data of file and store it in global variable “file1data” which can be appended with other files data.

def2.PNG

If any one of the file is not present in directory it will be return empty. On which runtime exception will be thrown.

exception.PNG

Mapping for this is given below, in which three function modules are created for each system.

mapping.PNG

All three function modules will return blank string if any of the file is not found. And on receiving blank exception_check udf will throw exception.

You post your reviews in comment section if you face any issue while implementing this requirement

Regards,

Shankul

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. mastan vali

    Hi Shankul,

    very good blog…indeed its a complex requirement, but you choose nice approach 🙂

    Keep up the good work.

    regards,

    Mastan vali

    (0) 

Leave a Reply