Over a million developers have joined DZone.

VFS Transport for WSO2 ESB

· Integration Zone

Learn how API management supports better integration in Achieving Enterprise Agility with Microservices and API Management, brought to you in partnership with 3scale

Virtual file system (VFS) is an abstraction layer on top of a more concrete file system.  It allows client applications to access different types of concrete file systems in a uniform way. Virtual File System refers to a file or a group of files[1,2].

Day to day I transfer lot of files. We have a file moving requirement in our Service Oriented Architecture. 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. The VFS transport uses the versatile Apache Commons-VFS library as the underline library for various file system related operations.  So I will show a simple tutorial on VFS in WSO2 ESB. I will be using WSO2 4.5.0 on windows 7 (64bit).

  • WSO2 ESB's VFS transport considers all file names as URIs.
  • WSO2 ESB acts as file transfer and exchanger between various destinations.
VFS transport configurations Parameters
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
image
[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”
image
[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’
image

[8] Start SimpleStockQuoteService in sample of ESB for to test this Proxy

image
[09] You will see below log in WSO2 ESB from VFS proxy services.
image
[10] While we ask only for .xml file is Orignal Dir to move Here is new Location of the files.
imageI
It is you time to try out VFS transport with WSO2 ESB.

NOTE
You can also add 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


Unleash the power of your APIs with future-proof API management - Create your account and start your free trial today, brought to you in partnership with 3scale.

Topics:

Published at DZone with permission of Madhuka Udantha, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}