Petals-BC-Filetransfer 2.x

Only component release < 3.x

Features


The FileTransfer component is a Binding Component (BC) which supports file transfers. This component allows to :

  • 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.
  • Provide a standard service that write the JBI message (content and attachments) it receives into a file with a specified name and suffixed with the current date name.
  • Provide a dedicated service GetFiles, which describe 2 operations:
    • getFiles operation, to retrieve files correponding to a pattern, from a folder.
    • getFile operation, to retrieve the first file correponding to a pattern, from a folder. 

These operations are described in an embedded astract WSDL, the File Transfer dedicated WSDL.

Component Configuration


Configuration of the component (CDK)

Parameter Description Default Required Required
acceptor-pool-size The size of the thread pool used to accept Message Exchanges from the NMR. Once a message is accepted, its processing is delegated to the processor pool thread. 3 Yes Runtime
processor-pool-size The size of the thread pool used to process Message Exchanges. Once a message is accepted, its processing is delegated to one of the thread of this pool. 10 Yes Runtime
processor-max-pool-size The maximum size of the thread pool used to process Message Exchanges. The difference between this size and the processorpool-size represents the dynamic threads that can be created and destroyed during overhead processing time. 50 No Runtime
notifications Enable the EDA mode. The component produces and consumes notifications. See the EDA documentation for further details. false No Installation
properties-file Name of the file containing properties used as reference by other parameters. Parameters reference the property name in the following pattern ${myPropertyName}. At runtime, the expression is replaced by the value of the property.
The value of this parameter is:
  • an URL
  • a file relative to the PEtALS installation path
  • an empty value to stipulate a non-using file
- No Installation

Definition of CDK parameter scope :

  • Installation: The parameter can be set during the installation of the component, by using the installation MBean (see JBI specifications for details about the installation sequence). If the parameter is optional and has not been defined during the development of the component, it is not available at installation time.
  • Runtime: The paramater can be set during the installation of the component and during runtime. The runtime configuration can be changed using the CDK custom MBean named RuntimeConfiguration. If the parameter is optional and has not been defined during the development of the component, it is not available at installation and runtime times.

Service Configuration

Configuration of a Service Unit to provide a service (JBI)

Parameter Description
Default
Required
provides Describe the JBI service that will be exposed into the JBI bus. Interface (QName), Service (QName) and Endpoint (String) attributes are required. - Yes

Configuration of a Service Unit to provide a service (CDK)

Parameter Description
Default
Required
timeout Timeout in milliseconds of a synchronous send. This parameter is used by the method sendSync (Exchange exchange) proposes by the CDK Listeners classes.
Set it to 0 for an infinite timeout.
30000 No
exchange-properties This sections defines the list of properties to set to the JBI exchange when processing a service. - No
message-properties This sections defines the list of properties to set to the JBI message when processing a service. - No
validate-wsdl Activate the validation of the WSDL when deploying a service unit. true No
wsdl
Path to the WSDL document describing services and operations exposed by the provided JBI endpoints defined in the SU.
The value of this parameter is :
  • an URL
  • a file relative to the root of the SU package
    If not specified, a basic WSDL description is automaticaly provided by the CDK.
- No
forward-attachments
Defines if attachment will be forwarded from IN message to OUT message.
false No
forward-message-properties
Defines if the message properties will be forwarded from IN message to OUT message. false No
forward-security-subject
Defines if the security subject will be forwarded from IN message to OUT message. false No

Transfer files into the JBI bus

CONSUME SERVICE : Transfer file(s) from a directory to a JBI service.

Service Unit descriptor

<?xml version="1.0" encoding="UTF-8"?>
<jbi:jbi version="1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:jbi="http://java.sun.com/xml/ns/jbi"
    xmlns:petalsCDK="http://petals.ow2.org/components/extensions/version-4.0"
    xmlns:filetransfer="http://petals.ow2.org/components/filetransfer/version-2.2"
    xmlns:generatedNs="http://petals.ow2.org/filetransfer">

  <jbi:services binding-component="false">
    <jbi:consumes
        interface-name="generatedNs:FileRepo"
        service-name="generatedNs:FileRepoService"
        endpoint-name="getServiceEndpoint">

      <!-- CDK specific fields -->
      <petalsCDK:operation>test</petalsCDK:operation>
      <petalsCDK:mep>InOnly</petalsCDK:mep>

      <!-- FileTransfer specific fields -->
      <filetransfer:read-directory>${PETALS_HOME}/filetransfer/in</filetransfer:read-directory>
      <filetransfer:backup-directory>${PETALS_HOME}/filetransfer/backup</filetransfer:backup-directory>
      <filetransfer:transfer-mode>content</filetransfer:transfer-mode>
      <filetransfer:polling-period>1000</filetransfer:polling-period>
    </jbi:consumes>
  </jbi:services>
</jbi:jbi>
Configuration of a Service Unit to consume a service (JBI)

Parameter Description Default Required
consumes Refer JBI service to invoke into the JBI bus.
You can define an explicit endpoint: interface (QName) / Service (QName) / Endpoint (String) attributes.
Or define implicit endpoint, to let the container routing according to QOS configurations (HA...):
-by Interface attribute (QName)
-by Service attribute (QName)
- Yes


Configuration of a Service Unit to consume a service (CDK)

Parameter Description Default Required
mep Message exchange pattern abbreviation. This parameter can be used in conjunction with the method of the CDK Listeners: createMessageExchange(Extensions extensions).
This method returns a CDK Exchange corresponding to the type of the specified pattern.
- Yes
operation Operation to call on a service. This parameter can be used in conjunction with the sending methods of the Listeners. If no operation is specified in the Message Exchange to send, this parameter will be used. - No
timeout Timeout in milliseconds of a synchronous send. This parameter can be used in conjunction with the sendSync(Exchange exchange) method of the Listeners. Set 0 for an infinite timeout. 30000 No


Configuration of a Service Unit to consume a service (Filetransfer)

Parameter Description Default Required
read-directory The location of the directory to poll on files. The address must be absolute.
Environment variables are supported with the form ${myEnvVariable}.
- Yes
backup-directory The backup directory where files are put once a transfer has been processed. The backup files are never deleted by the component.
Environment variables are supported with the form ${myEnvVariable}.
system temporary.directory No
polling-period The period between each polling in ms. 1000 No
transfer-mode The mode of transfer of the received file(s) as message payload.
Accepted values : content, attachment.
content No

Consumer restrictions

The FileTransfer component supports only InOnly message exchange pattern as consumer.

The FileTransfer component does not support synchronous sendings as consumer.

Consumer usage

If you want to invoke a service in the JBI bus with files, put the files in the configured directory (read-directory). 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), the component creates a new message exchange and attachs the file, either as source or as 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 exchange, the component put a XML structure like following :

<attached-files>
  <file-name>myFileName</file-name>
<attached-files>

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 by the component. Otherwise the file is moved to the system temporary directory.

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

Transfer files out of the JBI bus

PROVIDE SERVICE : Write JBI messages XML content and attachments to directory.

Service Unit descriptor

<?xml version="1.0" encoding="UTF-8"?>
<jbi:jbi version="1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:jbi="http://java.sun.com/xml/ns/jbi"
    xmlns:petalsCDK="http://petals.ow2.org/components/extensions/version-4.0"
    xmlns:filetransfer="http://petals.ow2.org/components/filetransfer/version-2.2"
    xmlns:generatedNs="http://petals.ow2.org/filetransfer">

  <jbi:services binding-component="true">
    <jbi:provides
        interface-name="generatedNs:put"
        service-name="generatedNs:putService"
        endpoint-name="putServiceEndpoint">

      <!-- WSDL file -->
      <petalsCDK:wsdl xsi:nil="true" />

      <!-- FileTransfer specific fields -->
      <filetransfer:write-directory>${PETALS_HOME}/filetransfer/out</filetransfer:write-directory>
      <filetransfer:copy-mode>content-only</filetransfer:copy-mode>
      <filetransfer:file-pattern>test.xml</filetransfer:file-pattern>
    </jbi:provides>
  </jbi:services>
</jbi:jbi>
Configuration of a Service Unit to provide a service (JBI)

Parameter Description
Default
Required
provides Describe the JBI service that will be exposed into the JBI bus. Interface (QName), Service (QName) and Endpoint (String) attributes are required. - Yes

Configuration of a Service Unit to provide a service (CDK)

Parameter Description
Default
Required
timeout Timeout in milliseconds of a synchronous send. This parameter is used by the method sendSync (Exchange exchange) proposes by the CDK Listeners classes.
Set it to 0 for an infinite timeout.
30000 No
exchange-properties This sections defines the list of properties to set to the JBI exchange when processing a service. - No
message-properties This sections defines the list of properties to set to the JBI message when processing a service. - No
validate-wsdl Activate the validation of the WSDL when deploying a service unit. true No
wsdl
Path to the WSDL document describing services and operations exposed by the provided JBI endpoints defined in the SU.
The value of this parameter is :
  • an URL
  • a file relative to the root of the SU package
    If not specified, a basic WSDL description is automaticaly provided by the CDK.
- No
forward-attachments
Defines if attachment will be forwarded from IN message to OUT message.
false No
forward-message-properties
Defines if the message properties will be forwarded from IN message to OUT message. false No
forward-security-subject
Defines if the security subject will be forwarded from IN message to OUT message. false No

 

Parameter Description
Default
Required
write-directory
The location of the directory where to write JBI message. It must be an absolute address. 
The directory MUST exists.
Environment variables are supported with the form ${myEnvVariable}.
- Yes
copy-mode
Transfer either the source, the attachments or both of the payload.
Possible values are content-only, attachments-only or content-and-attachments.
content-and-attachments
No
file-pattern
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, else content.xml
No

Provider restrictions

The FileTransfer component only supports InOnly message exchange pattern as service provider.

Provider Usage

According to the configured mode (copy-mode), the XML message content, attachments or both are transfered to the target directory (write-directory). 

If the received message is an XML content, the name of the created file would be either the configured file pattern (file-pattern), the operation of the message exchange, or the default name content.xml.

If the received message contains attachments, the name of the created files would be the names of the attachments.

For each file created, the system date is appended to this file name.

When deploying a service unit like in the previous code snippet, all the JBI messages received on the putService service will produce files in the $PETALS_HOME/filetransfer/out directory.

Retrieve files from a folder : the GetFiles service

PROVIDE SERVICE : return files from a folder as XML message or attachements.

Service Unit descriptor

<?xml version="1.0" encoding="UTF-8"?>
<jbi:jbi version="1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:jbi="http://java.sun.com/xml/ns/jbi"
    xmlns:petalsCDK="http://petals.ow2.org/components/extensions/version-4.0"
    xmlns:filetransfer="http://petals.ow2.org/components/filetransfer/version-2.2"
    xmlns:generatedNs="http://petals.ow2.org/filetransfer">

  <jbi:services binding-component="true">
    <jbi:provides
        interface-name="gefiletransfer:GetFiles"
        service-name="generatedNs:myGetFilesService"
        endpoint-name="getFilesServiceEndpoint">

      <!-- WSDL file -->
      <petalsCDK:wsdl xsi:nil="true" />


      <!-- FileTransfer specific fields -->
      <filetransfer:read-directory>${PETALS_HOME}/filetransfer</filetransfer:read-directory>
    </jbi:provides>
  </jbi:services>
</jbi:jbi>
Configuration of a Service Unit to provide a service (JBI)

Parameter Description
Default
Required
provides Describe the JBI service that will be exposed into the JBI bus. Interface (QName), Service (QName) and Endpoint (String) attributes are required. - Yes

Configuration of a Service Unit to provide a service (CDK)

Parameter Description
Default
Required
timeout Timeout in milliseconds of a synchronous send. This parameter is used by the method sendSync (Exchange exchange) proposes by the CDK Listeners classes.
Set it to 0 for an infinite timeout.
30000 No
exchange-properties This sections defines the list of properties to set to the JBI exchange when processing a service. - No
message-properties This sections defines the list of properties to set to the JBI message when processing a service. - No
validate-wsdl Activate the validation of the WSDL when deploying a service unit. true No
wsdl
Path to the WSDL document describing services and operations exposed by the provided JBI endpoints defined in the SU.
The value of this parameter is :
  • an URL
  • a file relative to the root of the SU package
    If not specified, a basic WSDL description is automaticaly provided by the CDK.
- No
forward-attachments
Defines if attachment will be forwarded from IN message to OUT message.
false No
forward-message-properties
Defines if the message properties will be forwarded from IN message to OUT message. false No
forward-security-subject
Defines if the security subject will be forwarded from IN message to OUT message. false No


Configuration of a Service Unit to provide the GetFiles services (FileTransfer)
Parameter Description
Description
Required
read-directory The directory where files will be searched when GetFiles is invoked.
Environment variables are supported with the form ${myEnvVariable}.
- Yes
backup-directory The directory where files are moved after being read.
Environment variables are supported with the form ${myEnvVariable}.
The system default temporary directory
The system default temporary directory
Yes

Provider restrictions

The FileTransfer component supports only InOut or InOptionalOut message exchange pattern as service provider.

Provider Usage

GetFile operation

When the getFile operation is set on the incoming message exchange, the component returns the first file found in the configured directory, according to the file filter set in the XML request (the source of the IN message). The file is returned as an XML response message (OUT message), so the file MUST be an XML file !

The IN message looks like :

<q0:getFile xmlns:q0="http://petals.ow2.org/components/filetransfer/version-2.2">
  <q0:filepattern>*.xml</q0:filepattern>
</q0:getFile>

The OUT message returned to the consumer contains the XML content of the first file matching the pattern, in its source :

The read file is moved to the configured backup directory (backup-directory) or in the system default temporary directory.

This operation is defined in the File Transfer abstract WSDL. You can import this abstract WSDL and define a concret WSDL to reference in your SU. Thus the service provided is properly defined by its WSDL.

GetFiles operation

When the getFiles operation is set on the incoming message exchange, the component returns all the files file found in
the configured directory (read-directory), according to the files filters set in the XML request. The files are all returned
as attachments. An XML report message is returned.
When the getFiles operation is set on the incoming message exchange, the component returns all the files file found in the configured directory (read-directory), according to the files filters set in the XML request. The files are all returned as attachments. An XML report message is returned.

The IN message looks like :

<q0:getFiles xmlns:q0="http://petals.ow2.org/components/filetransfer/version-2.2">
  <q0:filepattern>*.xml</q0:filepattern>
  <q0:filepattern>picture.jpg</q0:filepattern>
  <q0:filepattern>document??.doc</q0:filepattern>
</q0:getFiles>

The OUT message returned to the consumer is defined as follow :

<q0:getFilesResponse xmlns:q0="http://petals.ow2.org/components/filetransfer/version-2.2">
  <q0:filename>file1.xml</q0:filename>
  <q0:filename>file2.xml</q0:filename>
  <q0:filename>picture.jpg</q0:filename>
  <q0:filename>document_1.doc</q0:filename>
  <q0:filename>document_2.doc</q0:filename>
</q0:getFilesResponse>

Files are returned as attachments.

The read files are moved to the configured backup directory (backup-directory) or in the system default temporary directory.

This operation is defined in the File Transfer abstract WSDL. You can import this abstract WSDL and define a concret WSDL to reference in your SU. Thus the service provided is properly defined by its WSDL.
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.