Saturday, November 5, 2011

JCA File Adapter, File read vs Synchronous File Read, Sorting Files with ListSorter

In a nutshell, the Synchronous option doesn't create a File Poller Thread, but stops execution of an existing Thread (Message Flow) to read a file with a specified name.
In the parametrization of the File Adapter, the only difference is the existence of the "File Name" attribute. This is explained in detail here.

In the official documentation, this picture is wrong:

http://download.oracle.com/docs/cd/E15523_01/integration.1111/e10231/adptr_file.htm#BABEJGJB


it should be rather this:



Bear in mind that not all properties are shown in the JDeveloper wizard. You will have to hack the JCA file for some of them.
Their list is here.

A very interesting option is ListSorter :

ListSorter="oracle.tip.adapter.file.sorter.TimestampSorterAscending" allows you to process files in order of timestamp.

You can provide your own ListSorter: just implement a java.util.Comparator, you will receive 2 objects oracle.tip.adapter.file.FileInfo, so the available properties on which you can sort are:

fileName
compressedFileName
fileExtension
fullPath
compressedFullPath
timestamp
size
processed
isActive
fileList
batchId
processHeaderOnly
headerOnlyNoDelete
distributed
inputDirectory
compressedInputDirectory
rootDirectory
compressedRootDirectory
readOnly
creationTime
raw
primaryKey
originalPrimaryKey
clusteredFileList
fileType
singleThreaded
status
usePreciseTimestamp
poller
properties

However, bear in mind that the documentation says that you should have a SINGLE THREAD to make the sorting work


When files must be processed by Oracle File and FTP Adapters in a particular order, you must configure the sorting parameters. For example, you can configure the sorting parameters for Oracle File and FTP Adapters to process files in ascending or descending order by time stamps.
You must meet the following prerequisites for sorting scenarios of Oracle File and FTP Adapters:
• Use a synchronous operation
• Add the following property to the inbound JCA file:

property name="ListSorter" value="oracle.tip.adapter.file.inbound.listing.TimestampSorterAscending"
property name="SingleThreadModel" value="true"



No comments: