Wednesday, December 19, 2012

How to use WSO2 ESB VFS transport to transfer large files..

We can use VFS transport in WSO2 ESB as described in the sample [1]. Apart from that Supun which was a project manger of WSO2 ESB has written and article[2] on that. These articles and samples provides a great help on using VFS transport to transfer files.

But when using that configurations for transferring large files (Greater that 500 MB), i got an Out Of Memory exceptions[3] and some other errors[4].

When looking in to the problem more deeply, i could found the solution for the problem. The issue was with the message builder class that i have used and missing a property. We need to use the message builder "org.apache.axis2.format.BinaryBuilder" for this. Apart from that  we need to include the property "ClientApiNonBlocking" in the proxy configuration.

As a sample i have defined a custom content type "chs/binary".

Entries in axis2.xml

        <messageFormatter contentType="chs/binary"
        <messageBuilder contentType="chs/binary"

Then we need to have a sample VFS proxy as :

 <proxy xmlns=""
          <log level="custom">
             <property name="FileProxy" value="Processing file"/>
          <property name="OUT_ONLY" value="true"/>
          <property name="ClientApiNonBlocking"
             <endpoint name="FileEpr">
                <address uri="vfs:file:////home/shammi/file-out"/>
    <parameter name="transport.vfs.Streaming">true </parameter>
    <parameter name="transport.PollInterval">15 </parameter>
    <parameter name="transport.vfs.ActionAfterProcess">MOVE </parameter>
    <parameter name="transport.vfs.FileURI">file:///home/shammi/file-in </parameter>
    <parameter name="transport.vfs.MoveAfterProcess">file:///home/shammi/file-original </parameter>
    <parameter name="transport.vfs.MoveAfterFailure">file:////home/shammi/file-failure </parameter>
    <parameter name="transport.vfs.Locking">enable </parameter>
    <parameter name="transport.vfs.FileNamePattern">.*.zip|.*.test </parameter>
    <parameter name="transport.vfs.ContentType">chs/binary </parameter>
    <parameter name="transport.vfs.ActionAfterFailure">MOVE </parameter>


With this proxy , i could use VFS transport to transfer a file with the size 1 GB with out any issue. I have made the points bold which needs to pay more attention..

Cheers.. Thats it......

[3]2012-12-19 11:49:04,797 [-] [Framework Event Dispatcher]  WARN PollTableEntry transport.vfs.FileURI parameter is missing in the proxy service configuration
2012-12-19 11:50:08,896 [-] [vfs-Worker-3] ERROR NativeWorkerPool Uncaught exception
java.lang.OutOfMemoryError: Java heap space
at org.apache.axis2.format.BinaryBuilder.processDocument(
at org.apache.synapse.transport.vfs.VFSTransportListener.processFile(
at org.apache.synapse.transport.vfs.VFSTransportListener.scanFileOrDirectory(
at org.apache.synapse.transport.vfs.VFSTransportListener.poll(
at org.apache.synapse.transport.vfs.VFSTransportListener.poll(
at org.apache.axis2.transport.base.AbstractPollingTransportListener$1$
at org.apache.axis2.transport.base.threads.NativeWorkerPool$
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(
at java.util.concurrent.ThreadPoolExecutor$


2012-12-19 13:59:58,033 [-] [Axis2 Task] ERROR VFSTransportSender IO Error while creating response file : file:///home/shammi/wso2/foo/file-out/response.xml
org.apache.axis2.AxisFault: Error serializing binary content of element : {}binary
at org.apache.axis2.format.BinaryFormatter.writeTo(
at org.apache.synapse.transport.vfs.VFSTransportSender.populateResponseFile(
at org.apache.synapse.transport.vfs.VFSTransportSender.sendMessage(
at org.apache.axis2.transport.base.AbstractTransportSender.invoke(
at org.apache.axis2.engine.AxisEngine$
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(
at java.util.concurrent.ThreadPoolExecutor$
Caused by: org.apache.commons.vfs2.FileNotFoundException: Could not read from "file:///home/shammi/wso2/foo/file-in/" because it is a not a file.
at org.apache.commons.vfs2.provider.AbstractFileObject.getInputStream(
at org.apache.commons.vfs2.provider.DefaultFileContent.getInputStream(
at org.apache.synapse.transport.vfs.FileObjectDataSource.getInputStream(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.apache.axis2.format.ManagedDataSourceFactory$DataSourceManager.invoke(
at $Proxy15.getInputStream(Unknown Source)
at javax.activation.DataHandler.writeTo(
at org.apache.axis2.format.BinaryFormatter.writeTo(
... 7 more
Caused by: /home/shammi/wso2/foo/file-in/ (No such file or directory)
at Method)
at org.apache.commons.vfs2.provider.local.LocalFile.doGetInputStream(
at org.apache.commons.vfs2.provider.AbstractFileObject.getInputStream(
... 17 more
2012-12-19 14:00:26,458 [-] [Timer-7]  WARN TimeoutHa


  1. Helpful article. Did you test files above 1Gb? Any downside/drawback to making your configuration file properties the default option? Could the ESB recognized the filesize (from the http header) and fail gracefully or auto-adjust the processing behavior?

  2. Walk by any table game or poker room in any casino and you'll hear gambling jargon, which sounds like a foreign language to new and non-gamblers alike. Jargon at the craps table such as, "Put five on the big red! and Gimmie the Yo"! or "Double after split" while watching blackjack. Maybe during your stroll through the poker room, a player shouts to his opponent, "you're drawing dead on the river." This is gambling vocabulary. If you can't speak the language, you can't do the deeds.

  3. Corporate travel management is crucial for any corporation whether big or small. Keeping track of expenses, obtaining cheap airfares and hotel stays as well as keeping the expense accounting up to par is not a luxury, it is critical for staying competitive and running an efficient business. An established firm has the experience and expertise that will make your corporate travel organization a walk in the park. You would be surprised at how much time and money you can save on your corporate travel operations by allowing a professional to tweak, track, and trim a few things here and there. go to blog article