Tags
In this first part I want to demonstrate how we’re going to read a file from one directory to FileAdapter BPEL, then I will address as much as possible this wonderful component for file manipulation.
To have an example as practical as possible, I decided to create a post from and each part will be the evolution of the previous one, so if you want to follow and make the entire application is very important that you do or follow from the first part.
Here’s what I will demonstrate in the next Posts on FileAdapter:
- Working with FileAdapter in BPEL – Part 1: Reading the file from directory
- Working with FileAdapter in BPEL – Part 2: Reading the file content
- Working with FileAdapter in BPEL – Part 3: Saving the file contents in the database
- Working with FileAdapter in BPEL – Part 4: Renaming or Moving a File
- Working with FileAdapter in BPEL – Part 5: Deleting a file
Let’s start
First, create a new still empty Project with FileAdapterBPEL name as follows:
Drag a File Adapter component for Exposed Services and put the CapturaArquivo name and click Next
In option below, leave checked the Define from operation and schema (specified later) and click Next
Below select the Read File option and chooseo Do not read file content and click Next
Now, select the Logical Name option and Directory for Incoming Files place the name FILE_IN
Note: In order for you to understand, we will further define the directory where the file is and move on to the File Adapter through this variable FILE_IN
Let marked the Process files recursively and other unmarked option and click Next
Leave the File Wildcards option and Include Files with Name Pattern put the name arquivo.txt and click Next
Below I set so that our directory is read at a frequency of 5 in 5 seconds, then click Next
Note: This is interesting you understand that our File Adapter will read the contents of the folder that will further define every 5 seconds, or will not read the same file again unless it is changed or that we put a new file.
On the next screen click Finish
Then, you will have a process as follows:
Now click the right button on your composite.xml and click Generate Config Plan
Click OK
Open your file FileAdapterBPEL_cfgplan.xml and search by tag <service name=”CapturaArquivo”> and below, in <replace> place /home/uans/Arquivos (or as you want but remember to create this directories sequence in your home with the necessary permissions)
<service name=”CapturaArquivo”>
<property name=”FILE_IN”>
<replace>/home/uans/Arquivos</replace>
</property>
<binding type=”jca”/>
</service>
Save the file and let us now to deploy your project but pointing to this directory using your Config Plan.
Right on top of your design click Deploy >> FileAdapterBPEL
Click on Next
On the screen below, click the plus sign + beside SOA Configuration Plan and select FileAdapterBPEL_cfgplan.xml and check the box below Overwrite any existing composites with the same revision ID and deselect Keep running instances on after redeployment and click Next
Select the localhost option and click Next
Click Next again
Click Finish
In the Deployment tab wait for your deployment has the message
—- Deployment finished. —-
Now before we enter the directory and create a arquivo.txt, You will first enable trace and you’ll see an instance is created by putting the file.
In your browser go to the address http://localhost:10000/em
Note: The port 10000 is the number that chose to create my domain.
Login:
Click on your project: FileAdapterBEL[1.0]
Click on Settings >> Composite Audit Level and click Development, then click Yes
Now go in the directory /home/uans/Arquivos and create a file called arquivo.txt
Go back in EM (http://localhost:10000/em) and see that an instance is created, see also that he will be with status Running.
In the next post we will enter information into this arquivo.txt eand we will read the contents of this file.
Doubts? Leave your comment and download this Projet
Hugs and until the Next
/:-D