Skip to Content
author's profile photo Former Member
Former Member

File receiver - Get file size

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Feb 26, 2007 at 09:08 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 27, 2007 at 04:18 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • author's profile photo Former Member
    Former Member
    Posted on Feb 27, 2007 at 04:23 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 27, 2007 at 04:27 AM

    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..

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.