rss
SOATUBE
Oracle
Custom Search SOABYTE here

Friday, January 28, 2011

Copy a very large file (~gigs) from one directory to in BPEL/ESB

Use case I: Move an extremely large file from one directory to another in an opaque manner

 There are cases where the customer just wants to move/copy a file from one directory to another without reading the content of the file into BPEL/ESB. In order to do so, you will need to configure the FileAdapter in the following manner:
     <jca:binding  />
        <operation name="MoveFile">
      <jca:operation
          InteractionSpec="oracle.tip.adapter.file.outbound.FileIoInteractionSpec"
          SourcePhysicalDirectory="foo1"
          SourceFileName="bar1"
          TargetPhysicalDirectory="foo2"
          TargetFileName="bar2"
          Type="MOVE">
      </jca:operation>
Please note that the Source/Target endpoint details can be overridden via the header mechanism.

Use case II: Move an extremely large file from one directory on one FTP Server to a Local file-system and vice-versa

There are cases where the customer just wants to move/copy a file from the ftp server to a local file system folder and vice versa.
The new interaction has the concept of source and/or target being remote or local e.g.
    <binding name="IO_binding" type="tns:SynchRead_ptt">
    <jca:binding  />
        <operation name="IO">
      <jca:operation
         FileType="binary"
          InteractionSpec="oracle.tip.adapter.ftp.outbound.FTPIoInteractionSpec"
          SourcePhysicalDirectory="foo1"
          SourceFileName="bar1"
          TargetPhysicalDirectory="foo2"
          TargetFileName="bar2"
          Type="MOVE">
     </jca:operation>
        </operation>
    </binding>
    <service ..>
        <port ..>
        <jca:address location="eis/Ftp/FtpAdapter" />
        </port>
    </service>
In this case, both foo1 and foo2 are considered to be folders on a remote ftp server. The location of the server is governed by the JNDI location e.g. eis/Ftp/FtpAdapter.
However, if we want foo1 to be a folder on the remote ftp server and foo2 be a folder on the local system running the adapter then, we need to specify that in the interaction spec e.g.
 <jca:operation
         FileType="binary"
          InteractionSpec="oracle.tip.adapter.ftp.outbound.FTPIoInteractionSpec"
          SourcePhysicalDirectory="foo1"
          SourceFileName="bar1"
          TargetPhysicalDirectory="foo2"
          TargetFileName="bar2"
          TargetIsRemote="false"
          Type="MOVE">
     </jca:operation>
By specifying a TargetIsRemote as "false", we're saying that the TargetPhysicalDirectory is a local file system. Hence in this case, the MOVE operation will move the file "bar1" a remote file system on ftp server (foo1) to a local file system (foo2).
Similarly,  
 <jca:operation
         FileType="binary"
          InteractionSpec="oracle.tip.adapter.ftp.outbound.FTPIoInteractionSpec"
          SourcePhysicalDirectory="foo1"
          SourceFileName="bar1"
         SourceIsRemote="false"
          TargetPhysicalDirectory="foo2"
          TargetFileName="bar2"
          Type="MOVE">
     </jca:operation>
By specifying a SourceIsRemote as "false", we're saying that the SourcePhysicalDirectory is a local file system. Hence in this case, the MOVE operation will move the file "bar1" a local file system (foo1) to a remote file system on ftp server(foo2). 
If these parameters are both absent, they default to true e.g. 
 <jca:operation
         FileType="binary"
          InteractionSpec="oracle.tip.adapter.ftp.outbound.FTPIoInteractionSpec"
          SourcePhysicalDirectory="foo1"
          SourceFileName="bar1"
         SourceIsRemote="true"
          TargetPhysicalDirectory="foo2"
          TargetFileName="bar2"
         TargetIsRemote="true"
          Type="MOVE">
     </jca:operation> 

Use case III: Move an extremely large native file (in csv format) to another directory (in fixed length format) using the new interaction [Basically the FlatStructure sample on a 1 gig file]

 There are cases where the customer wants to do the following:
i) Read a huge native csv file(~1 gig) from a directory
ii) Translate the csv into XML
iii) Run the resulting XML through a transformation
iv) Translate the transformed XML back to a delimited file.
    <jca:binding  />
        <operation name="MoveWithXlate">
      <jca:operation
          InteractionSpec="oracle.tip.adapter.file.outbound.FileIoInteractionSpec"
          SourcePhysicalDirectory="foo1"
          SourceFileName="bar1"
          TargetPhysicalDirectory="C:\JDevOOW\jdev\FileIoOperationApps\MoveHugeFileWithXlate\out"
          TargetFileName="purchase_fixed.txt"
          SourceSchema="address-csv.xsd" 
          SourceSchemaRoot ="Root-Element"
          SourceType="native"
          TargetSchema="address-fixedLength.xsd" 
          TargetSchemaRoot ="Root-Element"
          TargetType="native"
          Xsl="addr1Toaddr2.xsl"
          Type="MOVE">
      </jca:operation>
      <input>
        <jca:header message="hdr:OutboundHeader_msg" part="outboundHeader"/>
      </input>
        </operation>
    </binding>
As you can see that we have the schema details for the source file and target file. These schemas should be imported into the process. The Xsl parameter specifies which XSL file to use.


0 comments:

Post a Comment

 
Blogger Profile