cancel
Showing results for 
Search instead for 
Did you mean: 

File receiver - Get file size

Former Member
0 Kudos

Hi all,

In my scenario, the message mapping is such that the target message may or may not have child nodes created depending on certain conditions. I am using file receiver channel to write this target message as xml file on another server.

The issue I am facing is - suppose child nodes are not created, the target message has only root node, and nothing else. i.e. it is empty.

But still the file gets written on destination, because file adapter doesn't seem to have intelligence to look into the payload. So I have to manually delete such 'almost-empty' files.

Although PI 7.0 has feature of ignoring empty files, the file I am talking of is really not of 0 kb size, as it contains namespace and root node tag. It has very small size of 1 kb, this is fixed and thus the file is easily distinguished from other larger files which contain child nodes. File size is a parameter that can be certainly used as a key here, but don't know how.

Does anyone have any idea on -

1) How to check file size before file receiver adapter writes it,

2) How to prevent such file from getting written, or

3) run a script which can detect the file size and delete them periodically / or every time file receiver writes files ?

Regards,

- Shankar.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Shankar,

In the sender communication channalel set the Set Adapter-Specific Message Attributes indicator and get the file size. Also first get the size of file with out payload i.e, with namespace etc as told by you. Then in the receiver determination just take the xpath of the file size and give the size what you got manually. If it is greater than that value write the file else then it will not write.

Give a try with this approach. It may resolve your issue.

---Satish

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

We have an option of empty file handling in receiver file adapter..

<i> Select the Handling of Empty Messages: Write Empty File

An empty file (length 0 bytes) is put in the target directory.

Ignore No file is put in the target directory.</i>

But your case namespace and root node only are available you said.

In this type of situations ..

We can handle in the following way..

If target side root node having the recordset node

root

recordset 0..unbound

child1 0.1

child2 0.1

Then create a UDF

map from left side one node -


exists --- UDF ---to right side root node

In UDF

//handle business logic and

....ResultList.SUPPRESS.

if your target side does not have any recordset type of structure then..

In messages tab change the occurrences of msg to 0..unbound and use the above UDF.

Regards

Chilla..

Former Member
0 Kudos

hi,

using condition editor in Directory for incoming payload and check if the child node exhists use EX as exhists and it exhists create a file else dont create.

let me know if you still face any problems

Regards

Sreeram.G.Reddy

Former Member
0 Kudos

Shankar,

In the reciever determination , specify a condition against the target Business system. In this condition, try making an EXISTS check on a field in the XML payload that should be present for Xi to write a file. In this way i believe you can avoid writing an almost empty file. try it and let know if it helps

Regards

Saravana

Former Member
0 Kudos

Hi,

You can even use the standard Context Object <b>Source File Size</b> while specifying the condition in Receiver Determination. But all these work on sender Interface only. I hope, the requirement is to check the size after mapping . Is my understanding right?

So try the following option.

Try suppressing the Message type itself. Go to Your Message Mapping, Messages Tab. Change the occurences of Target Message Type to 0:1 and in ur mapping, use ur logic and don't populate Message Type if ur logic is not satisfied. Give it a shot.

Regards,

Sudharshan

Message was edited by:

Sudharshan Aravamudan