The Virtual File System (VFS) transport is used by WSO2 Enterprise Integrator(WSO2 EI) to process files in the specified source directory. After processing the files, it moves them to a specified location or deletes them. Note that files cannot remain in the source directory after processing or they will be processed again, so if you need to maintain these files or keep track of which files have been processed, specify the option to move them instead of deleting them after processing. If you want to move files into a database, use the VFS transport and the DBReport mediator (for an example, see Sample 271: File Processing).
...
In
<EI_HOME>/conf/axis2/axis2.xml
, in themessageBuilders
section, add the binary message builder as follows:Code Block language html/xml <messageBuilder contentType="application/binary" class="org.apache.axis2.format.BinaryBuilder"/>
and in the
messageFormatters
section, add the binary message formatter as follows:Code Block language html/xml <messageFormatter contentType="application/binary" class="org.apache.axis2.format.BinaryFormatter"/>
In the proxy service where you use the VFS transport, add the following parameter to enable streaming (see VFS service-level parameters below for more information):
Code Block language html/xml <parameter name="transport.vfs.Streaming">true</parameter>
In the same proxy service, before the Send mediator, add the following property:
Info title Note You also need to add the following property if you want to use the VFS transport to transfer files from VFS to VFS.
Code Block language html/xml <property name="ClientApiNonBlocking" value="true" scope="axis2" action="remove"/>
For more information, see Example 3 of the Send Mediator.
...
Parameter Name | Description | Required | Possible Values | Default Value | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
FileURI | The URI of the location of your files. This should be the source location of the files (if you are configuring the ESB to read files) or the destination of the files (if you are configuring the ESB to send files). You can specify connection-level parameters on the URL (see VFS URL parameters below). When you need to access the absolute path of the URL, you can define the URL with as shown below. Also, note that transport.vfs.AvoidPermissionCheck is a mandatory parameter for this URL when SFTP is used.
| Yes | A valid file URI in the following form: | |||||||||
transport.vfs. | Content type of the files processed by the transport. To specify the encoding, follow the content type with a semi-colon and the character set. For example: <parameter name="transport.vfs.ContentType“>text/plain;charset=UTF-32</parameter> When writing a file, you can set a different encoding with the CHARACTER_SET_ENCODING property:<property name="CHARACTER_SET_ENCODING" value="UTF-8" scope="axis2" type="STRING"/> | Yes | A valid content type for the files (e.g., | |||||||||
transport.vfs. | If the VFS listener should process only a subset of the files available at the specified file URI location, use this parameter to select those files by name using a regular expression. | No | A regular expression to select files by name (e.g., | |||||||||
transport. | The polling interval for the transport receiver to poll the file URI location. The value is expressed in seconds unless you add "ms" for milliseconds, e.g., "2" or "2000ms" to specify 2 seconds. | No | A positive integer. | |||||||||
transport.vfs. | Whether to move, delete or take no action on the files after the transport has processed them. | No |
|
| ||||||||
transport.vfs. | Whether to move, delete or take no action on the files if a failure occurs. | No |
|
| ||||||||
transport.vfs. | Where to move the files after processing if ActionAfterProcess is MOVE. | Yes, if | A valid file URI | |||||||||
transport.vfs. | Where to move the files after processing if ActionAfterFailure is MOVE. | Yes, if | A valid file URI | |||||||||
transport.vfs. | The location where reply files should be written by the transport. | No | A valid file URI | |||||||||
transport.vfs. | The name for reply files written by the transport. | No | A valid file name |
| ||||||||
transport.vfs. | The pattern/format of the timestamps added to file names as prefixes when moving files. | No | A valid timestamp pattern | |||||||||
transport.vfs. | Whether files should be transferred in streaming mode, which is useful when transferring large files | No |
|
| ||||||||
transport.vfs. | Reconnect timeout value in seconds to be used in case of an error when transferring files | No | A positive integer | 30 sec | ||||||||
transport.vfs. | Maximum number of retry attempts to carry out in case of errors. | No | A positive integer | 3 | ||||||||
transport.vfs.Append | When writing the response to a file, whether the response should be appended to the response file instead of overwriting the file. This value should be defined as a query parameter in the out/reply or:
| No |
|
| ||||||||
transport.vfs. | Where to move the failed file. | No | A valid file URI | |||||||||
transport.vfs. | The name of the file that maintains | No | A valid file name |
| ||||||||
transport.vfs. | Where to store the failed records file. | No | A folder URI | |||||||||
transport.vfs. | Entries in the failed records file include the name of the file that failed and the timestamp of its failure. This property configures the time stamp format. | No | A valid timestamp pattern |
| ||||||||
transport.vfs. | The time in milliseconds to wait before retrying the move task. | No | A positive integer | 3000 milliseconds | ||||||||
transport.vfs.Locking | By default, file locking is enabled in the VFS transport. This parameter lets you configure the locking behavior on a per service basis. You can also disable locking globally by specifying the parameter at the receiver level and selectively enable locking only for a set of services. | No |
|
| ||||||||
transport.vfs. FileProcessCount | This setting allows you to throttle the VFS listener by processing files in batches. Specify the number of files you want to process in each batch. | No | A positive integer, such as 10 | N/A | ||||||||
transport.vfs. FileProcessInterval | The interval in milliseconds between two file processes. | No | A positive integer, such as 1000 | N/A | ||||||||
transport.vfs.ClusterAware | Whether VFS coordination support is enabled in a clustered deployment or not. | No | true or false | false | ||||||||
transport.vfs.FileSizeLimit | Only file sizes that are less than or equal to the defined limit are processed. | No | File size in bytes | -1(unlimited file size) | ||||||||
transport.vfs.AutoLockReleaseInterval | The timeout value for stale locks where the VFS transport will ignore those file locks once the defined time period is reached. (The time period is calculated from the time the lock is created to the time you attempt to access it.) If you need stale locks to never timeout provide -1 as the timeout value. | No | Time in milliseconds | 20000 | ||||||||
transport.vfs.SFTPIdentities | Location of the private key | No | A valid file path | N/A | ||||||||
transport.vfs.SFTPIdentityPassPhrase | Passphrase of the private key | No | A valid passphrase | N/A | ||||||||
transport.vfs.SFTPUserDirIsRoot | If the SFTP user directory should be treated as root | No | true or false | true | ||||||||
transport.vfs.ResolveHostsDynamically | Whether hostnames should be resolved at the time of deployment or whether it is necessary to resolve hostnames dynamically at runtime.
| No | true or false | false |
Anchor | ||||
---|---|---|---|---|
|
VFS URL parameters
VSF When you use the transport.vfs.FileURI parameter, you can set connection-specific VFS parameters can be set as URL query parameters. For example, to use FTPS SFTP with SSL, you could specify the URL as follows:shown below. Note that transport.vfs.AvoidPermissionCheck is a mandatory parameter for this URL when SFTP is used.
Code Block | ||
---|---|---|
| ||
<parameter name="transport.vfs.FileURI">vfs:ftps://test:test123@10.200.2.63/vfs/in?vfs.ssl.keystore=/home/user/openssl/keystore.jks&vfs.ssl.truststore=/home/user/openssl/vfs-truststore.jks&vfs.ssl.kspassword=importkey&vfs.ssl.tspassword=wso2vfs&vfs.ssl.keypassword=importkey<=importkey;transport.vfs.AvoidPermissionCheck=true</parameter> |
Following are details on the URL parameters you can set. To configure the proxy over ftp/sftp click here.
Parameter Name | Description | Possible Values | Default Value | ||||||
---|---|---|---|---|---|---|---|---|---|
| Be sure to set this parameter to true for an SFTP connection. This is because (by default) the VFS transport checks whether the user has permission to access the location of the files (the source location or the destination). However, since the system is reading files in an external server through the SFTP connection, this permission check is not required and should be avoided. | true | false | |||||||
vfs.passive | Enable FTP passive mode. This is required when the FTP client and server are not in the same network. | true | false | false | ||||||
transport. vfs . Append | If file with same name exists, this parameter tells whether to create a new file and write content or append content to existing file | true | false | false | ||||||
vfs.protection | Set data channel protection level using FTP PROT command |
| C | ||||||
vfs.ssl.keystore | Private key store to use for mutual SSL. Your keystore must be signed by a certificate authority. For more information, see http://docs.oracle.com/cd/E19509-01/820-3503/ggfen/index.html. | String - Path of keystore | |||||||
vfs.ssl.kspassword | Private key store password | String | |||||||
vfs.ssl.keypassword | Private key password | String | |||||||
vfs.ssl.truststore | Trust store to use for FTPS | String - Path of keystore | |||||||
vfs.ssl.tspassword | Trust store password | String | |||||||
transport.vfs.CreateFolder | If the directory does not exists create and write the file | true | false | false | ||||||
transport. vfs.SendFileSynchronously | Whether to send files synchronously to the file host. When this parameter is set to true , files will be sent one after another to the file host. This synchronous write can be configured on a per host basis. | true | false | false |
...