Tuesday, 26 June 2012

Oracle FTP Adapter read file as Attachment


Oracle SOA Suite FTP Adapter is used to exchange file data - it can be a read or write a file to remote server file systems. The adapter built using the well known JCA architecture to transfer files in an heterogeneous Enterprise Information Systems (EIS).

In this post, lets look at the way to read large files opaquely using the FTP Adapter. By Opaque, I meant where the file data read as such doesn't matter and the objective is to just process the file contents read by the FTP Adapter as it is.

The ideal way to get this done is using the option Read File as Attachment which is available only when you check the inbound Get operation while configuring the FTP adapter in the composite.

Let's take this up with a use case - a composite designed to read large pdf file  from the FTP server and place the same file as-is on the local server where the SOA server is running.  I shall highlight only the important steps of design of this composite with JDeveloper IDE screen snapshot.

FTP Adapter used to Get File from the remote server

Step showing the FTP Adapter Configuration Wizard with Get File as operation type selected and Read File As Attachment option checked.



FTP Configuration Wizard with file pattern to be polled mentioned with file wildcard as *.pdf




File Adapter to write the same file to the local file system where the service is running

Step showing the file path where the file will be written and the file name pattern.



File Configuration wizard to select the attachment element reference, that way the data type is same as that of the FTP Get variable.



The composite file in design mode after creating the FTP and File Adapters is as below:



Add a BPEL service component to your composite, edit it to add a receive, assign and invoke activity and wire those activities/partnerlinks appropriately as shown below:



Edit the Assign activity to map the receive GET variable value with the invoke activity write variable:



Note that in the assign activity of the BPEL component the reference value is assigned and not the actual file content. The file content are stored in the ATTACHMENT table of the SOA Infra schema as BLOB data type in Attachment column against this reference value (column name is Key). The SCA engine will take care of fetching the file content from the ATTACHMENT table at run time before the invoke activity is executed to write the file content onto the local file system. 

The above method to read a file using FTP adapter is very efficient especially if there are large files to be read from the FTP server and the content of the file does not matter. You can even combine this with encryption or compression logic in your composite before the file is passed to the target location or for further processing.

Friday, 25 May 2012

Importance of serverTimeZone property of SOA FTP Adapter Connection JNDI


Oracle SOA Suite FTP Adapter can be used to transfer files to and from an FTP server. 

Before even you can use the FTP Adapter in your SOA Composite projects, an FTP Adapter Connection JNDI will need to be created. The set up can be done in the weblogic server against the FtpAdapter resource adapter application deployment by creating a JNDI entry in the Outbound Connection Pool. As part of the setup, mandatory  properties pertaining to the FTP server such as username, password, host and port will need to be mentioned. 

The serverTimeZone property is one such property which are often ignored when a request to create a new FTP connection JNDI is made. This property signifies the time zone of the server where the FTP application is running and can play a very pivotal role when polling a file after a minimum age delay. Say, for instance, you have a SOA composite that polls a file from a FTP server location after a minimum age delay of 2 minutes. If the server on which FTP application is running is on a different time zone when compared to that of the server where SOA composite is installed, the FTP poller of the SOA Composite will not pick the file as expected which may lead to lot of confusion during testing. In order to avoid such confusion, it is always preferred to set the serverTimeZone property when setting up the FTP Adapter Connection JNDI.

Now you may ask, I never bothered setting this property while configuring the FTP Adapter Connection JNDI, but still my services with FTP Adapter was working as expected. There may be some specific reasons for it:
  • By default, serverTimeZone property is blank. When set to blank, the time zone of the SOA server is assumed. It could be that the SOA server time zone and FTP server time zone are one and the same.
  • There was no minimum age delay specified in the FTP poller of your Composite project.
  • The Adapter configured with non Get FTP operations - Put, List and Synchronized Get
It is hence recommended to set the serverTimeZone property of the FTP Connection JNDI to that of the FTP server time zone ID when you set it  up in the weblogic server especially required when your composite are having an FTP Poller in it with minimum file age set and with SOA and FTP server time zones are different; else expect the unexpected behaviour from the outcome of the service.

The time zone values that needs to go in to serverTimeZone property are those recognised by Java Classes.

No provision has been made for the SOA server to identify the Daylight Savings Time (DST) changes of the FTP server and adjust the FTP Adapter JNDI settings automatically; such changes will need to be done manually to the new time zone in the weblogic server.