\\
The directory to monitor is the drop-in directory (that is here defined using an environment variable called _DropInDirectory_).
This directory will be polled every five seconds.
And the files to check are CSV files, i.e. files having a \*.csv extension.
\\
The service to consume is the Talend service that was exported above.
The Message Exchange Pattern must be *InOnly* (no other MEP is allowed for this component in consume mode).
The only operation that supports this MEP in the WSDL of the Talend job, is *executeJobOnly*.
Eventually, the skeleton of the message to send can be generated with a tool like SoapUI.
In this case, the sent message will only contain a reference to the attachment.
\\
Once exported, this configuration can be used for all the distributed nodes.
Here is the skeleton of the message to send to the Talend service.
{code:lang=xml}
<tal:executeJob xmlns:tal="http://petals.ow2.org/talend/">
<tal:contexts />
<tal:in-attachments>
<tal:fileLocation>
<tal:fileContent>$attachment</tal:fileContent>
</tal:fileLocation>
</tal:in-attachments>
</tal:executeJob>
{code}
\\
And here is the jbi.xml of the FileTransfer configuration.
{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 2.5-snapshot of the component.
-->
<jbi:jbi version="1.0"
xmlns:filetransfer="http://petals.ow2.org/components/filetransfer/version-2"
xmlns:gen0="http://petals.ow2.org/talend/"
xmlns:generatedNs="http://petals.ow2.org/talend/"
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="generatedNs:CommandsCollectorServicePortType"
service-name="generatedNs:CommandsCollectorService"
endpoint-name="CommandsCollectorEndpoint">
<!-- CDK specific elements -->
<petalsCDK:timeout>30000</petalsCDK:timeout>
<petalsCDK:operation>gen0:executeJobOnly</petalsCDK:operation>
<petalsCDK:mep>InOnly</petalsCDK:mep>
<!-- Component specific elements -->
<filetransfer:read-directory>${DropInDirectory}</filetransfer:read-directory>
<filetransfer:transfer-mode>content</filetransfer:transfer-mode>
<filetransfer:file-pattern>*.csv</filetransfer:file-pattern>
<filetransfer:polling-period>5000</filetransfer:polling-period>
<filetransfer:base-message><![CDATA[<tal:executeJob xmlns:tal="http://petals.ow2.org/talend/">
<tal:contexts />
<tal:in-attachments>
<tal:fileLocation>
<tal:fileContent>$attachment</tal:fileContent>
</tal:fileLocation>
</tal:in-attachments>
</tal:executeJob>]]></filetransfer:base-message>
</jbi:consumes>
</jbi:services>
</jbi:jbi>
{code}
h1. Running the use case
To test this use case, install the Petals-SE-Talend and the Petals-BC-FileTransfer components on the target nodes.
Define the environment variable _DropInDirectory_.
Then, deploy the associated configurations in Petals.
\\
To run the test, simply drop a CSV file in the drop-in directory and check the database then.