Tuesday, June 23, 2015

Useful Oracle File Adapter's JCA configurations.

JCA configuration to debatch a file.

<adapter-config name="DebatchAdapter"
adapter="File Adapter" wsdlLocation="DebatchAdapter.wsdl" xmlns="http://platform.integration.oracle/blocks/adapter/fw/metadata">
 
  <connection-factory location="eis/HAFileAdapter" UIincludeWildcard="Test*.OUT"/>
  <endpoint-activation portType="Read_ptt" operation="Read">
    <activation-spec className="oracle.tip.adapter.file.inbound.ScalableFileActivationSpec">
      <property name="DeleteFile" value="true"/>
      <property name="MinimumAge" value="60"/>
      <property name="LogicalArchiveDirectory" value="TestFileArchiveDirectory"/>
      <property name="LogicalDirectory" value="TestFileInputDirectory"/>
      <property name="Recursive" value="false"/>
      <property name="PublishSize" value="3000"/>
      <property name="PollingFrequency" value="60"/>
      <property name="IncludeFiles" value="Test.*\.OUT"/>
      <property name="MaxRaiseSize" value="1"/>
      <property name="SingleThreadModel" value="true"/>
      <property name="UseHeaders" value="false"/>
    </activation-spec>
  </endpoint-activation>
</adapter-config>

Here location="eis/HAFileAdapter" indicates that the debatching happens in a cluster environment.
observe the className is changed as oracle.tip.adapter.file.inbound.ScalableFileActivationSpec instead of oracle.tip.adapter.file.inbound.FileActivationSpec which is default.

====================
Writing CSV file with header line.

When writing CSV using file adapter and if you want the header line to be published in the output CSV file then make sure that XSD corresponding to the file structure defined in the format builder of the File Adapter should not contain following lines.
nxsd:hasHeader="true"
nxsd:headerLines="1"

These attributes when populated within <xsd:schema> element basically skip the header row in the CSV file.
====================
JCA File Adapter's SynchRead configuration to read the file in the middle of a process and MOVE it to a particular folder.

<adapter-config name="TestFileSynchRead" adapter="File Adapter"
wsdlLocation="TestFileSynchRead.wsdl" xmlns="http://platform.integration.oracle/blocks/adapter/fw/metadata">
 
  <connection-factory location="eis/HAFileAdapter"/>
  <endpoint-interaction portType="SynchRead_ptt" operation="SynchRead">
    <interaction-spec className="oracle.tip.adapter.file.outbound.FileIoInteractionSpec">
      <property name="SourcePhysicalDirectory" value="/test/in"/>
      <property name="SourceFileName" value="Test.CSV"/>
      <property name="TargetPhysicalDirectory" value="/test/out"/>
      <property name="TargetFileName" value="Test.CSV"/>
      <property name="Type" value="MOVE"/>
    </interaction-spec>
  </endpoint-interaction>
</adapter-config>

If you just want the file to be copied then change the property Type value to COPY as below.
property name="Type" value="COPY"
Observe the file interaction spec is oracle.tip.adapter.file.outbound.FileIoInteractionSpec.

In OSB, JCA properties can be set in transport header as below.