Monday, January 12, 2015

How to configure a VFS transport within WSO2 ESB?

In this tutorial I will show you the variety of options to configure a VFS transport.

What is VFS? 
Virtual File System (VFS) is an abstraction layer on top of a more concrete file system. The purpose of a VFS is to allow client applications to access different types of concrete file systems in a uniform way. 

1) Local file system
    a Windows
    b Linux 
2) FTP 
3) SFTP 
4) CIFS - SMB 

The most used VFS options are:

1a. Local file system - Windows
<proxy xmlns="http://ws.apache.org/ns/synapse" name="ProxyWinFile" transports="vfs" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>         
         <log level="custom">            
            <property name="LOG" value="=====Win File=======Win File=====Win File====="/>         
         </log>      
      </inSequence>
      <outSequence>         
         <send>            
            <endpoint>               
               <address uri="vfs:file:///D:/SPs/tmp/out"/>            
            </endpoint>         
         </send>      
      </outSequence>
   </target>
   <parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
   <parameter name="transport.PollInterval">20</parameter>
   <parameter name="transport.vfs.FileURI">file:///D:/SPs/tmp/in</parameter>
   <parameter name="transport.vfs.MoveAfterProcess">file:///D:/SPs/tmp/process</parameter>
   <parameter name="transport.vfs.MoveAfterFailure">file:///D:/SPs/tmp/fail</parameter>
   <parameter name="transport.vfs.FileNamePattern">.*\.xml</parameter>
   <parameter name="transport.vfs.ContentType">text/xml</parameter>
   <parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
   <parameter name="transport.vfs.MoveTimestampFormat">yyyyMMdd_HHmmss_</parameter>
   <description></description>
</proxy>  

1b. Local file system - Linux
<proxy xmlns="http://ws.apache.org/ns/synapse" name="ProxyFile" transports="vfs" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
         <log level="custom">
            <property name="LOG" value="=====File=======File=====File====="/>
         </log>
      </inSequence>
      <outSequence>
         <send>
            <endpoint>
               <address uri="vfs:file:///home/user/file/out"/>
            </endpoint>
         </send>
      </outSequence>
   </target>
   <parameter name="transport.PollInterval">20</parameter>
   <parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
   <parameter name="transport.vfs.MoveAfterProcess">file:///home/user/file/process</parameter>
   <parameter name="transport.vfs.FileURI">file:///home/user/file/in</parameter>
   <parameter name="transport.vfs.MoveAfterFailure">file:///home/user/file/fail</parameter>
   <parameter name="transport.vfs.FileNamePattern">.*\.xml</parameter>
   <parameter name="transport.vfs.ContentType">text/xml</parameter>
   <parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
   <parameter name="transport.vfs.MoveTimestampFormat">yyyyMMdd_HHmmss_</parameter>
   <description></description>
</proxy> 
 

2. FTP Proxy configuration
<proxy name="ProxyFTP" transports="vfs" startOnLoad="true" trace="disable">
      <description/>
      <target>
         <inSequence>
            <log level="custom">
               <property name="LOG" value="=====FTP=====FTP=====FTP====="/>
            </log>
         </inSequence>
         <outSequence>
            <send>
               <endpoint>
                  <address uri="vfs:ftp://acb:abc123@10.100.0.5/esbtest/out"/>
               </endpoint>
            </send>
         </outSequence>
      </target>
      <parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
      <parameter name="transport.PollInterval">5</parameter>
      <parameter name="transport.vfs.MoveAfterProcess">vfs:ftp://acb:abc123@10.100.0.5/esbtest/process</parameter>
      <parameter name="transport.vfs.FileURI">vfs:ftp://acb:abc123@10.100.0.5/esbtest/in?vfs.passive=true</parameter>
      <parameter name="transport.vfs.MoveAfterFailure">vfs:ftp://acb:abc123@10.100.0.5/esbtest/fail</parameter>
      <parameter name="transport.vfs.FileNamePattern">.*.xml</parameter>
      <parameter name="transport.vfs.ContentType">text/xml</parameter>
      <parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
      <parameter name="transport.vfs.MoveTimestampFormat">yyyyMMdd_HHmmss_</parameter>
</proxy>

3. SFTP Proxy configuration
<proxy name="ProxySFTP" transports="vfs" startOnLoad="true" trace="disable">
      <description/>
      <target>
         <inSequence>
            <log level="custom">
               <property name="LOG" value="=====FTPS=======FTPS=====FTPS====="/>
            </log>
         </inSequence>
         <outSequence>
            <send>
               <endpoint>
                  <address uri="vfs:sftp://abc:abc123@10.100.0.5/esbtest/out"/>
               </endpoint>
            </send>
         </outSequence>
      </target>
      <parameter name="transport.PollInterval">5</parameter>
      <parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
      <parameter name="transport.vfs.MoveAfterProcess">vfs:sftp://abc:abc123@10.100.0.5/esbtest/process</parameter>
      <parameter name="transport.vfs.FileURI">vfs:sftp://abc:abc123@10.100.0.5/esbtest/in?vfs.passive=true</parameter>
      <parameter name="transport.vfs.MoveAfterFailure">vfs:sftp://abc:abc123@10.100.0.5/esbtest/fail</parameter>
      <parameter name="transport.vfs.FileNamePattern">.*.xml</parameter>
      <parameter name="transport.vfs.ContentType">text/xml</parameter>
      <parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
      <parameter name="transport.vfs.MoveTimestampFormat">yyyyMMdd_HHmmss_</parameter>
</proxy>

4. CIFS - SMB Proxy configuration (Windows with domain)
<proxy name="ProxySMB" transports="vfs" startOnLoad="true" trace="disable">
      <description/>
      <target>
         <inSequence>
            <log level="custom">
               <property name="LOG" value="====SMB====SMB====SMB===="/>
            </log>
         </inSequence>
         <outSequence>
            <send>
               <endpoint>
                  <address uri="vfs:smb://devlab\user1:user123@10.200.3.187/test/out"/>
               </endpoint>
            </send>
         </outSequence>
      </target>
      <parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
      <parameter name="transport.PollInterval">10</parameter>
      <parameter name="transport.vfs.MoveAfterProcess">smb://devlab\user1:user123@10.200.3.187/test/process</parameter>
      <parameter name="transport.vfs.FileURI">smb://devlab\user1:user123@10.200.3.187/test/in</parameter>
      <parameter name="transport.vfs.MoveAfterFailure">smb://devlab\user1:user123@10.200.3.187/test/fail</parameter>
      <parameter name="transport.vfs.Locking">false</parameter>
      <parameter name="transport.vfs.FileNamePattern">.*\.xml</parameter>
      <parameter name="transport.vfs.ContentType">text/xml</parameter>
      <parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
      <parameter name="transport.vfs.MoveTimestampFormat">yyyyMMdd_HHmmss_</parameter>
</proxy> 
 

No comments:

Post a Comment