retransmission of failed files via ftp

Can someone guide me on how you achieve the retransmission of failed files via ftp? My flow logic is build using pub.client.ftp:login, cd, put, logout. And, it is executed one after another based on the returncode. And, catches any error occurs. But, I don’t know how to retrasmit those failed files? Is there a service which does it?

regards,
sanjay

Hey Sanjay,
Use Repeat for the complete FTP steps. This helps most times.

However, if you encounter failure after repeating “n” times, better is save the contents of the file in the IS and try later using a separate Schedule, that agian FTP this file.

HTH
BS

Hi Bash,

If you could please elaborate on saving file in the IS and using separate scheduler that will be really appreciated as i don’t have indepth experience.
The service is defined on the routing rule and is triggered based on the IDOC message type and the vendor(receiver). But, i can’t think of a scheduler to automate the failed transmission.

Thanks

Sanjay,

I believe what Bash meant is do a repeat on the ftp for loging in and sending, in case if failed after several times, you ouput the file to some temp directory in IS, giving it a unique filename (can be based on timestamp or contextID).

Then you can run a scheduler to poll from that directory and send the file to your destination again with using FTP in the same behaviour. Of course if the transmission is succesful you will have to remove the file from that directory so it doesn’t get picked up again.

If you have a dynamic destination for each file, you can store the destination information in a repository somewhere, can be a DB if you like. Use a key value pair, (just like Java hash-map) take the filename as key and the destination as values. Actually you can improvize, and the possibilities are endless.

Good luck;

KK

Hi KK,

Thanks for the reply. But, what service is there to load multiple files from the directory. If not how it is done? Any, help will be much appreciated?

thanks,
sanjay…

Sanjay,

Basically you can use WmSamples/samples/IO/utils/listFilesInDirectory service for getting list of files/directories and then loop thru the files use getFile for processing.

Also using ftp services ftp:ls you can check this too.

HTH,
RMG

Thankyou all. And, speacial thanks to Rama as you have been a great help now and in the past as well.
Thankyou you all again.

thanks,
sanjay

HI Rmg,

I have run into a little problem. When i save a failed ftp transmission, the original Idoc-xml data is slightly altered while using savePipelineToFile.
I have created a recordX from one of these failed XML files for reference. So, that i can map the failed files into a recordY which is a reference of recordX. The whole idea is to map the Idoc-xml data in the failed file into a Idoc type record(ORDERS05) thus get rid of the unwanted stuff and then do the normal processing to retransmit the data. But, i have not been able to extract any data from recordY to map it to a record, string or string list or array. I have tried the list services but that too doesn’t help.

thanks,
sanjay

There is one more way to check correctness ot the sent file:

  1. Calculate expected size of the file:

pub.string:bytesToString (input: *content (file to send) as “*bytes”; output: StringToSend as string)

pub.string:length (input: StringToSend as InString; output: SentBytes as value)

  1. prepare pattern for LS:
    pub.string:concat (input: "-la " as inString1, as inString2; output: FileToSearch as value)

  2. REPEAT (count = 5):

3.1 pub.client.ftp:put (input: *content, , transfermode = binary)

3.2 pub.client.ftp:ls (input: FileToSearch (from step 2) as filenamepattern; output: dirlist)

3.3 LOOP over /dirlist (there is only one item in this one):

3.3.1 pub.string:tokenize (input: dirlist as inString, empty delim; output: valueList)

3.3.2 Get Length of sent file from response of LS:
pub.list:getStringListItem (input: valueList as list, “4” as item; output: item) - if file exists, then 4-th item is the size of this file, else - file doesn’t exist.

3.3.3 BRANCH (evaluate-labels = “true”) - compare size of sent file with expected length.
3.3.3.1 SEQUENCE (label = %/SentBytes%=%/item%) - PUT is successful, make appropriate actions and exit from REPEAT (step 3)
3.3.3.2 SEQUENCE (label = $default) - File doesn’t exist or transfer of the file doesn’t complete. Make appropriate actions (and repeat the PUT and checking - go to step 3.1)