This short blog post is to demonstrate on how to connect WSO2 EI/MI with SFTP endpoint. Here, we will use SFTP docker image and read xml file content on it.
- Pull the following Docker image from the DockerHub
docker pull atmoz/sftp
2. Start the docker container as the SFTP server. Here I used 3022 as the port mapping to avoid conflict between host server:
docker run -p 3022:22 -d atmoz/sftp foo:pass:::upload
3. Start the EI server and add the following sequence that log the file data.:
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="logdata" xmlns="http://ws.apache.org/ns/synapse">
<log/>
<drop/>
</sequence>
4. Add following inbound endpoint to the EI:
<inboundEndpoint name="abcd" onError="fault" protocol="file"
sequence="logdata" suspend="false">
<parameters>
<parameter name="interval">3000</parameter>
<parameter name="sequential">true</parameter>
<parameter name="coordination">true</parameter>
<parameter name="transport.vfs.FileURI">sftp://foo:pass@192.168.43.152:3022/upload?transport.vfs.AvoidPermissionCheck=true&vfs.passive=true </parameter>
<parameter name="transport.vfs.ContentType">text/plain</parameter>
<parameter name="transport.vfs.Locking">enable</parameter>
<parameter name="transport.vfs.ActionAfterProcess">DELETE</parameter>
<parameter name="transport.vfs.ActionAfterFailure">DELETE</parameter>
<parameter name="transport.vfs.AutoLockRelease">false</parameter>
<parameter name="transport.vfs.LockReleaseSameNode">false</parameter>
<parameter name="transport.vfs.DistributedLock">false</parameter>
<parameter name="transport.vfs.FileSortAttribute">NONE</parameter>
<parameter name="transport.vfs.FileSortAscending">true</parameter>
<parameter name="transport.vfs.CreateFolder">true</parameter>
<parameter name="transport.vfs.Streaming">false</parameter>
<parameter name="transport.vfs.Build">false</parameter>
<parameter name="transport.vfs.SFTPUserDirIsRoot">true</parameter>
</parameters>
</inboundEndpoint>
Remember to change your host IP, sftp username and password on the FileURI
connection string.
5. Now you can test the inbound endpoint by creating new text/xml file on the ftp location. EI server will log the content.
Comments
Post a Comment