In day to day transfer lot of thing one place to another. Even in PC we used to move copy files from one location to another. We have this file moving requirement in Service Oriented Architecture or in IT infrastructure it's a very common requirement. WSO2 ESB has a feature rich file transport which is called VFS transport. This transport is currently used by lot of customers for implementing various file transfer and processing scenarios. VFS transport uses the versatile Apache Commons-VFS library as the underline library for various file system related operations. So I will take simple tutorial on VFS on WSO2 ESB. I will be using WSO2 4.5.0 on windows 7 (64bit).
- WSO2 ESB's VFS transport consider all file names as URIs.
- WSO2 ESB acts as file transfer and exchanger between various destinations.
Parameter | Possible value |
transport.vfs.FileURI | Input source (file or directory) |
transport.vfs.ContentType | The content type of the file |
transport.vfs.FileNamePattern | The patten of extension of the file |
transport.vfs.MoveAfterProcess | Location to move the file after process |
Let is start it.
[1] Open file “\wso2esb-4.5.0\repository\conf\axis2\axis2.xml”
[2] And uncomment two lines in axis2.xml
VFSTransportListener and VFSTransportSender
[2] Create File Structure in you file directory for test VFS Transport
[3] Start ESB from \wso2esb-4.5.0\bin\wso2server.bat \.sh and Logto WSO2 esb 4.5.0
[4] Home--> Manage--> Services--> Add--> Proxy Service and Click on "Custom Proxy"
[5]Fill the form By passing the proxy name or just click “switch to source view”
[6] Then enter below text on there.
<proxy xmlns="http://ws.apache.org/ns/synapse" name="testVFS" transports="https,http,vfs" statistics="disable" trace="disable" startOnLoad="true">
<!—JUST proxy that is sample1—>
<target>
<outSequence>
<send />
</outSequence>
<endpoint>
<address uri="https://127.0.0.1:9443/services/SimpleStockQuoteService" />
</endpoint>
</target>
<!--VFS configurations-->
<parameter name="transport.PollInterval">5</parameter>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.vfs.FileURI">file:///F:/test/Orginal/</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file:///F:/test/Pass/</parameter>
<parameter name="transport.vfs.MoveAfterFailure">file:///F:/test/Failures/</parameter>
<parameter name="transport.vfs.FileNamePattern">.*.xml</parameter>
<parameter name="transport.vfs.ContentType">text/xml</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
<description></description>
</proxy>
[7] Then click ‘save’
[8] Start SimpleStockQuoteService in sample of ESB for to test this Proxy
[09] You will see below log in WSO2 ESB from VFS proxy services.
[10] While we ask only for .xml file is Orignal Dir to move Here is new Location of the files.
It is you time to try out VFS transport with WSO2 ESB.
NOTE
You can also added those parameters from axis2.xml (\wso2esb-4.5.0-1\wso2esb-4.5.0\repository\conf\axis2\axis2.xml).
<transportReceiver name="vfs" class="org.apache.synapse.transport.vfs.VFSTransportListener">
<parameter name="transport.PollInterval">5</parameter>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.vfs.FileURI">file:///F:/test/Orginal1/</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file:///F:/test/Pass/</parameter>
<parameter name="transport.vfs.MoveAfterFailure">file:///F:/test/Failures/</parameter>
<parameter name="transport.vfs.FileNamePattern">.*.xml</parameter>
<parameter name="transport.vfs.ContentType">text/xml</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
</transportReceiver>
[1]http://www.ibm.com/developerworks/library/l-sc12/index.html
[2]http://www.arl.wustl.edu/~fredk/Courses/cs523/fall01/Papers/kleiman86vnodes.pdf
[3]http://www.w3schools.com/soap/soap_example.asp
Add a comment