View Source

{section}
{column}

{warning}This version must be installed on Petals ESB 5.0.2+{warning}

h1. Features

The FileTransfer component is a Binding Component which supports file transfers.

This component allows to:

* Expose a file system access as a service which provide a set of 8 operations:
** *put:* Write the received JBI messages in a file with a specified name
** *mput:* Write the JBI message attachments it receives into files.
** *get:* Retrieve *Xml* file corresponding to a pattern, from a folder. Return it as message payload.
** *getAsAttachment:* Retrieve the first file corresponding to a pattern, from a folder. Return it as message's attachment.(XOP standard)
** *mGet:* Retrieve files corresponding to a pattern, from a folder. Return them as message's attachment.
** *checkFile:* Check the availability of a file.
** *del:* Delete one file.
** *dir:* List the content of a folder.

* Poll a configured directory for incoming files. At a poll, each file retrieved is put into a new JBI message, set as source or attachment. The message is sent to a target JBI service.

{info}All attachment are processed by using XOP rules.(XML-binary Optimized Packaging : [http://www.w3.org/TR/xop10/] ){info}

{column}
{column:width=25%}
{panel:title=Table of contents}{toc:outline=true}{panel}
{panel:title=Contributors}{contributors:order=name|mode=list|showAnonymous=true|showCount=true|showLastTime=true}{panel}
{column}
{section}

h1. Exposing a file system access as a service (Provides mode)

{info}
All operations support wild card character.
{info}

{tip}
All operations are in namespace {{http://petals.ow2.org/components/filetransfer/version-3}}.
{tip}

h2. Usage

h3. Put Operation

When the _put_ operation is set on the incoming IN message, the component writes the XML message to the configured directory.

The created file takes the name described in the service unit (filename parameter) otherwise the operation name is taken. For each file created, the system date is appended to this file name.

The IN message looks like :
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<ver:put xmlns:ver="http://petals.ow2.org/components/filetransfer/version-3">?</ver:put>
{code}
The service does not return a message.
The available exchange pattern is : *InOnly*.

h3. MPut Operation

When the _mput_ operation is set on the incoming IN message, the component writes the attachments on the configured directory.
The IN message looks like :
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<ver:mput xmlns:ver="http://petals.ow2.org/components/filetransfer/version-3">
<ver:attachments>
<!--1 or more repetitions:-->
<ver:filename><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:test1.xml"/></ver:filename>
<ver:filename><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:test2.xml"/></ver:filename>
</ver:attachments>
</ver:mput>
{code}
The service does not return a message.

The available exchange pattern is : *InOnly*.

h3. Get Operation

When the _get_ operation is set on the incoming IN message, the component retrieves ONE file from the configured directory and return it as an XML message content.
\\

The name of the file to retrieve is set in the XML IN content of the message.
\\

The IN message looks like :
\\
{code:lang=xml}<?xml version="1.0" encoding="UTF-8"?>
<ver:get xmlns:ver="http://petals.ow2.org/components/filetransfer/version-3">
<ver:filename>file name to retrieve</ver:filename>
</ver:get>
{code}
The OUT message returned to the consumer is the content of the XML file
\\

The service might return a Fault when an element in the request is missing or if an IO error occurs.
\\

The available exchange patterns is : *InOut*.

{info}Only xml file could be processed otherwise an error will be raised.{info}

h3. GetAsAttachement Operation

When the _getAsAttachment_ operation is set on the incoming IN message, the component retrieve ONE file from the configured directory according to the filename(or filter) set in the XML request.
The retrieved file is set in the OUT message as an attachment.

The IN message looks like:
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<ver:getAsAttachment xmlns:ver="http://petals.ow2.org/components/filetransfer/version-3">
<ver:filename>file name to retrieve</ver:filename>
</ver:getAsAttachment>
{code}

The OUT message returned to the consumer contains file, as attachment:
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<tns:getAsAttachmentResponse xmlns:tns="http://petals.ow2.org/components/filetransfer/version-3">
<tns:attachment>
<tns:filename><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:test1.xml"/></tns:filename>
</tns:attachment>
</tns:getAsAttachmentResponse>
{code}

The service might return a Fault when an element in the request is missing or if an IO error occurs.

The available exchange pattern is : *InOut*.

h3. MGet Operation

When the _mget_ operation is set on the incoming IN message, the component retrieves files from the configured directory, according to the filenames (or filters) set in the XML request.
There is no recursion, sub folders are ignored.

Each file is set in the OUT message as an attachment.
The IN message looks like:
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<ver:mget xmlns:ver="http://petals.ow2.org/components/filetransfer/version-3">
<\!\--1 or more repetitions:-\->
<ver:filename>*.xml</ver:filename>
<ver:filename>myFile.txt</ver:filename>
</ver:mget>
{code}

The OUT message returned to the consumer contains files, as attachments:
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<tns:mgetResponse xmlns:tns="http://petals.ow2.org/components/filetransfer/version-3">
<tns:attachments>
<tns:filename><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:test1.xml"/></tns:filename>
<tns:filename><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:myFile.txt"/></tns:filename>
</tns:attachments>
</tns:mgetResponse>
{code}

The service might return a Fault when an element in the request is missing or if an IO error occurs.

The available exchange pattern is : *InOut*.

h3. CheckFile Operation

When the _check_ operation is set on the incoming IN message, the component check
if the specified file exist. The IN message looks like&nbsp;:
{code:lang=xml}
<ver:checkFile xmlns:ver="http://petals.ow2.org/components/filetransfer/version-3">
<ver:filename>?</ver:filename>
</ver:checkFile>
{code}

The OUT message returned to the consumer looks like&nbsp;:
{code:lang=xml}
<ver:checkFileResponse xmlns:ver="http://petals.ow2.org/components/filetransfer/version-3">
<ver:filename>?</ver:filename>
<ver:exist>true|false</ver:exist>
</ver:checkFileResponse>
{code}

The service might return an ioFault.
The available exchange pattern is : *InOut*.

h3. Del Operation

When the _del_ operation is set on the incoming IN message, the component deletes the remote files. The IN message looks like :
{code:lang=xml}<?xml version="1.0" encoding="UTF-8"?>
<ver:del xmlns:ver="http://petals.ow2.org/components/filetransfer/version-3">
<ver:filename>?</ver:filename>
</ver:del>
{code}
The service does not return a message.

The available exchange pattern is : *InOnly*.

h3. Dir Operation

When the _dir_ operation is set on the incoming IN message, the component returns the file names listed from the configured directory. A wild card expression can be given to filter files returned. f no wild card expression is given, or if it is empty, all files will be listed:
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<ver:dir xmlns:ver="http://petals.ow2.org/components/filetransfer/version-3" >
<ver:filename>*.xml</ver:filename>
</ver:dir>
{code}

The OUT message returned to the consumer looks like&nbsp;:
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<tns:dirResponse xmlns:tns="http://petals.ow2.org/components/filetransfer/version-3">
<tns:filename>file.xml</tns:filename>
<tns:filename>file1.xml</tns:filename>
<tns:filename>file2.xml</tns:filename>
</tns:dirResponse>
{code}

The service might return an ioFault.
The available exchange pattern is : *InOut*.

h2. Configuration

h3. Service Unit descriptor

Example of a File Transfer Service Unit descriptor that provides a Service:

{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
    <!--
        JBI descriptor for the PEtALS' "petals-bc-filetransfer" component
        (FileTransfer). Originally created for the version 3.0 of the component.
    -->
<jbi:jbi version="1.0"
    xmlns:filetransfer="http://petals.ow2.org/components/filetransfer/version-3"
    xmlns:jbi="http://java.sun.com/xml/ns/jbi" xmlns:petalsCDK="http://petals.ow2.org/components/extensions/version-5"
    xmlns:generateNs="http://petals.ow2.org/filetransfer" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <!--
        Import a Service into PEtALS or Expose a PEtALS Service => use a BC.
    -->
    <jbi:services binding-component="true">

        <!-- Import a Service into PEtALS => provides a Service. -->
        <jbi:provides endpoint-name="myFileTransferSUEndpointName"
            interface-name="filetransfer:FileTransfer" service-name="filetransfer:myFileTransferSUServiceName">

            <!-- CDK specific elements -->
            <petalsCDK:wsdl>FileTransferService.wsdl</petalsCDK:wsdl>
            <petalsCDK:validate-wsdl>true</petalsCDK:validate-wsdl>

            <!-- Component specific elements -->
            <filetransfer:folder>${PETALS_HOME}/filetransfer/out</filetransfer:folder>
            <filetransfer:backup-directory>${PETALS_HOME}/filetransfer/backup</filetransfer:backup-directory>
            <filetransfer:filename>gettingstarted.xml</filetransfer:filename>
        </jbi:provides>
    </jbi:services>
</jbi:jbi>
{code}

{include:0 CDK SU Provide Configuration}
{center}{*}Configuration of a Service Unit to provide a service (File Transfer)*{center}

{table-plus}
|| Attribute || Description || Default value || Required ||
| filename | The name of the file where the JBI message (the XML content) will be written in. \\
The system date is appended on each created file. | The operation name | {center}No{center} |
| backup-directory | The directory where files are moved before being read.Environment variables are supported with the form $\{myEnvVariable\}. | system's temporary directory | {center}No{center} |
| folder | Working directory where files are written or retrieved. Environment variables are supported with the form $\{myEnvVariable\} | | {center}Yes{center} |
{table-plus}

{include:0 CDK SU Interceptor configuration|]}

h3. Service Unit content

The Service Unit has to contain the following elements, packaged in an archive:
\\
* The META-INF/jbi.xml descriptor file, has described above,
* An optional wsdl file describing the related service

{code}service-unit.zip
+ META-INF
- jbi.xml (as defined above)
- service.wsdl (optional)
{code}

h1. Invoking service on incoming file (Consumes mode)

If you want to invoke a service in the JBI bus with files, put the files in the configured directory (folder). At each configured polling period (polling-period), the component fetchs the incoming files.

For each received files and according to the transfer mode (transfer-mode or base-msg), the component creates a new message exchange and attachs the file, either as source or attachment.


If a file is put as a attachment, the name of the attachment is set to the name of the file, and in the source of the message&nbsp;exchange, the component put a XML structure ccording to xop rules.


The resulted message exchange(s) are sent to the target endpoint.

During the transfer, if the backup directory (backup-directory) is set, the transfered file is moved into it and never deleted&nbsp;by the component. Otherwise the file is moved to the system temporary directory.

When deploying a service unit like in the following code snippet, all the files put in the directory $PETALS_HOME/filetransfer/in would be set as the payload of an invocation to the _ftContentNoBaseMsgService_ service.

h2. Configurations

h3. Service Unit descriptor


*Example 1{*}*: use of the parameter* *transfer{*}*\-mode*
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<jbi:jbi xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:petalsCDK="http://petals.ow2.org/components/extensions/version-5"
    xmlns:wsdl="http://petals.ow2.org/filetransfer"
    xmlns:filetransfer="http://petals.ow2.org/components/filetransfer/version-3"
    xmlns:jbi="http://java.sun.com/xml/ns/jbi" version="1.0">
    <jbi:services binding-component="false">
        <jbi:consumes interface-name="wsdl:ftContentNoBaseMsg"
            service-name="wsdl:ftContentNoBaseMsgService"
            endpoint-name="ftContentNoBaseMsgEndpoint">

            <petalsCDK:timeout>20</petalsCDK:timeout>
            <petalsCDK:mep>InOnly</petalsCDK:mep>
            <petalsCDK:operation>simplefiletransfer</petalsCDK:operation>
            <filetransfer:folder>${PETALS_HOME}/filetransfer/in</filetransfer:folder>
            <filetransfer:polling-period>3000</filetransfer:polling-period>
            <filetransfer:transfer-mode>content</filetransfer:transfer-mode>
        </jbi:consumes>
    </jbi:services>
</jbi:jbi>
{code}

*Example 2 : use of the parameter base-msg*
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<!-- JBI descriptor for the Petals' "petals-bc-filetransfer" component (FileTransfer).
    Originally created for the version 3.0 of the component. -->
<jbi:jbi version="1.0"
    xmlns:filetransfer="http://petals.ow2.org/components/filetransfer/version-3"
    xmlns:generatedNs="http://petals.ow2.org/filetransfer" xmlns:jbi="http://java.sun.com/xml/ns/jbi"
    xmlns:petalsCDK="http://petals.ow2.org/components/extensions/version-5"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <!-- Import a Service into Petals or Expose a Petals Service => use a BC. -->
    <jbi:services binding-component="true">
        <!-- Expose a Petals Service => consumes a Service. -->
        <jbi:consumes interface-name="itfNs:ftAttachmentBaseMsg"
            service-name="generatedNs:ftAttachmentBaseMsgService" endpoint-name="ftAttachmentBaseMsgEndpoint"
            xmlns:itfNs="http://petals.ow2.org/filetransfer">
            <!-- CDK specific elements -->
            <petalsCDK:timeout>30000</petalsCDK:timeout>
            <petalsCDK:mep>InOnly</petalsCDK:mep>
            <!-- Component specific elements -->
            <filetransfer:folder>${PETALS_HOME}/filetransfer/in4
            </filetransfer:folder>
            <filetransfer:polling-period>1000</filetransfer:polling-period>
            <filetransfer:base-message>
<![CDATA[<customMessage><attachments><filein>$attachment</filein></attachments></customMessage>]]>
</filetransfer:base-message>
        </jbi:consumes>
    </jbi:services>
</jbi:jbi>
{code}

{include:0 CDK SU Consume Configuration}
\\
{center}{*}Configuration of a Service Unit to consume a service (File Transfer)*
{center}
|| Attribute || Description || Default Value || Required ||
| folder | Working directory where files are written or retrieved. $ \{myEnvVariable\} environment variables are supported. | {center}\-{center} | {center}Yes{center} |
| backup-directory | The directory where files are moved before being read.Environment variables are supported with the form $\{myEnvVariable\}. | {center}default system temporary directory {center} | {center}No{center} |
| polling-period | Polling period in milliseconds | {center}1000{center} | {center}No{center} |
| filename | Pattern used filter files to read | {center}\*{center} | {center}No{center} |
| transfer-mode | The mode of transfer of the received file(s) as message payload. \\
Accepted values : content, attachment. | {center}attachment{center} | {center}No{center} |
| base-message | The skeleton of XML-message to send to the consumed service. It may contain *$content* or *$attachment*, or none of them. This is the way the component should link the file with the returned message. \\
* *$content* will be replaced by the file content.
* *$attachment* will set the file in attachment. It will be replaced by a xop:include element which references the attachment (MTOM-like). | {center}\-{center} | {center}No{center} |
| processor-pool-size | For each service-unit, the component create a poller. This parameter defines the maximum number of processor thread created by the poller to process file. If no more processor thread are available, file to process are queued. | {center}5{center} | {center}No{center} |
| processor-pool-timeout | Define eviction time in milliseconds for processor thread created by the poller. | {center}10000ms{center} | {center}No{center} |

{note}The parameter "transfer-mode" and "base-msg" can not be used at the same time.{note}

h1. Component Configuration

{include:0 CDK Component Configuration Table 5.6.0}
{include:0 CDK Parameter scope}
{include:0 CDK Component Interceptor configuration}

h1. Monitoring the component

h2. Using metrics

Several probes providing metrics are included in the component, and are available through the JMX MBean '{{org.ow2.petals:type=custom,name=monitoring_*<component-id>*}}', where {{*<component-id>*}} is the unique JBI identifier of the component.

h3. Common metrics

{include:0 CDK Component Monitoring Metrics 5.6.0}

h3. Dedicated metrics

No dedicated metric is available.

h2. Receiving alerts

Several alerts are notified by the component through notification of the JMX MBean '{{org.ow2.petals:type=custom,name=monitoring_*<component-id>*}}', where {{*<component-id>*}} is the unique JBI identifier of the component.

{tip}To integrate these alerts with Nagios, see [petalsesbsnapshot:Receiving Petals ESB defects in Nagios].{tip}

h3. Common alerts

{include:0 CDK Component Monitoring Alerts 5.6.0}

h3. Dedicated alerts

No dedicated alert is available.