Search This Blog

Tuesday, December 27, 2011

File/FTP Adapter - Large File Transfer (Chunk Mode)


Background

Whenever large (binary) file needs to be transferred by using PI, there might be a chance for Out of Memory error which might results in server restart.  Technically, it often fails in the sender adapter.

image

The most popular work around is to split the file in to multiple parts in Sender Adapter and Combining them in Receiver Adapter (via OS Scripts)
From PI 7.30 onwards File/FTP adapter natively supports transferring large size files by splitting them in to smaller chunks based on the configured size. Each chunk will be processed as an individual XI Message in sender adapter and all the chunks are combined based on the sequence in receiver adapter. Since all the chunks have to be combined in the actual order, QoS EOIO has to be used to enable this feature.

image

Configuration Options

Select 'EOIO' as a QoS under Processing tab.

image

After that select 'Advanced Mode' under 'Advanced' Tab

Option 1

You can choose the required chunk size option from the given list of 1, 2, 5, 10, 20 and 50 MB.

image

Option 2

Custom values which are not possible in default options can also be configured in additional parameters.

Parameter Name
Possible Values
chunkMode  
Non emptry string  will be considered as true
chunkSizeKB
Positive Numeric  Value


image

Processing in Sender Adapter

  • Basic Mode will be enabled only if QoS is EOIO
  • Chunk Mode related Advanced Mode parameters will be ignored if QoS  not EOIO
  • If chunkSizeKB is not defined /incorrect value, default is 10KB
  • If both are configured, Basic mode will have higher precedence
Sender Adapter will create XI message with additional dynamic headers for each chunk and forwarded to Messaging System for IRD processing.

 Example

For this example, chunk size is configured as 2 MB and the below input file (~4.5 MB) is used.
 image

For demo purpose and to identify/analyze how the actual split happens, the input file is created with the data like below ( 1 to 600000)
 image

As per the configuration, three chunks should be created with the size of 2 MB, 2MB and ~500 KB.
image

Chunk 1 (2 MB)

Transferring first 2 MB
image

Chunk 2 (2 MB) 

Transferring next 2 MB (Total 4 MB)
image

Chunk 3 (~500 KB)

Transferring the remaining ~500 KB (Total ~4.5 MB)
image

Dynamic Headers

The entire chunk mode related dynamic headers will be set under the namespace http://sap.com/xi/XI/System/Generic
HeaderValue
ChunkStartStart of the Chunk (Position of bytes)
ChunkModeActive/End
ChunkKeyUnique Key (Same for all the chunks for a particular file)

 The corresponding screenshots for all 3 chunks are given below.

First Chunk

image

Next Chunk 

image

Last Chunk

image

If multiple files sent from different file sender channels, receiver adapter uses the chunk key to identify the proper output file(for combining). During the creation(and append) of output file, it uses the chunk key like below.

image

In Temp mode, the temp files won’t be deleted till the last chunk is received.

Overall Control Flow


image

Recovery Mode

If the input file is very large, it would normally take more time to be transferred completely.  If there is any server failure in the middle, the transfer can resumed from the chunk it stopped (Not from the beginning)

Individual Payloads after Split

Though this feature operates only on binary mode, text file is used to analyze how the split happens during chunk creation.

Payload of Chunk 1

image

Payload of Chunk 2

image

Payload of Chunk 3

image
As per the above screenshots, the split never cosiders the payload. It's just a binary split. So the following limitations would apply
  • Only for File Sender to File Receiver
  • No Mapping
  • No Content Based Routing
  • No Content Conversion
  • No Custom Modules

How to choose the chunk size? Smaller chunk size ensures more reliability?
Yes.  But significantly affects the performance. Smaller chunk size creates more chunks (more XI messages)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.