Hi guys, in this article I share one mini scenario when working with SFTP.
Scenario
Integration Flow want get all files with extension XML from folder SFTP into flow. Do some logic and then will sent payload into queue.
Queue is JMS adapter.
All information of SFTP, ex: address, folder, credential… will be set by parameter.
This is integration flow of this scenario

#1. Configuration sender adapter

#2. Configuration SFTP sender adapter
In this configuration, we will use externalize parameter to config dynamic value for SFTP.


This is parameter table for this configuration

#3. Configuration Content Modifier
In this content modifier, we will create header with name CAMELFILENAME to get extension of file which get from SFTP folder.

When working with File, we can get some information of FILE as
${file.name} | Get full file with extension | HCI\InputFile.xml |
${file:name.ext} | Get extension of file | xml |
${file:name.noext} | Get file with no extension | HCI\InputFile |
${file:onlyname} | Get file name | InputFile.xml |
${file:onlyname.noext} | Get file name no extension | InputFile |
${file:ext} | Get extension | xml |
#4. Configuration Router
Base on value of HEADER.CAMELFILENAME, we set condition in router to get just file with extension is XML

#5. Configuration for queue. JMS receiver adapter

#6. Input value for parameters
After save, we need to input value for parameters which we define in integration flow.
Go to artifact, choose configure.


#7. Test from POSTMAN
In this step, we will do test script as
- First, send file with extension NOT equal XML. (Ex: ZIP file). In this case flow will run router default (Route 2), and we will receiver ABC as payload

- Second, send file with extension EQUAL XML, in this case flow will run route 1, and we will receiver data in JMS (data in JMS queue will be decrypt)

- Check in queue

Summary
This article just a small, very small scenario in real project, but it can help me, newbie in CPI can take more understand. And It’s very interested and thankful if I receive any advise from you. Thanks for your reading and any question or advise, kindly leave your comment on this.
Joseph.
Hi Huy,
It is a very nice blog. thanks for sharing such a brief explanation step by step. I am a beginner. i have requirment. I have to pick files from SFTP and process them to another system using the Odata service. when the file is failing to process to Target due to a connection or mapping error it has to move to the error backup folder. and should delete in the source location as well. whenever a connection is established target end, the file has to reprocess from error folder automatically. Can you suggest how to achieve this?
LikeLike