IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#TechXchangePresenter
 View Only
Expand all | Collapse all

Reading Large Files from file system

  • 1.  Reading Large Files from file system

    Posted Wed September 24, 2008 07:22 PM

    Hi,

    I have a requirement where i need to read a large EDI file from file system and pass that to the TN using routeXML service.
    I can’t use the convertToValues service.

    Could anyone please suggest a method for reading the file as a stream and then passing the data to TN.

    Quick help is highly appreciated.

    Thanks,
    Nis


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 2.  RE: Reading Large Files from file system

    Posted Wed September 24, 2008 08:30 PM

    you can write a java service using StringBuffer. and get the object in pipeline.


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 3.  RE: Reading Large Files from file system

    Posted Wed September 24, 2008 10:43 PM

    Or use pub.file:getFile, with loadAs set to stream.

    However, this only handles the first (and easiest) part of Nisha’s post: how to read the file as a stream.

    The second part is the tough part: how to send EDI documents to TN via routeXML without using convertToValues. Since routeXML accepts a node (which must be an XML document) as its input and an EDI document is definitely not an XML document, you’ll have to write your own code to convert from EDI to something that routeXML can understand.

    Why not just use convertToValue? It works, its modular (accepts multiple EDI document types), and its already built for you.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 4.  RE: Reading Large Files from file system

    Posted Wed September 24, 2008 11:11 PM

    How would the use of StringBuffer help with a large file?


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 5.  RE: Reading Large Files from file system

    Posted Thu September 25, 2008 07:45 AM

    Using the getFile will only do when its a small file…i need to read large files using getFile as stream and then i am lost how to handle it without using convertToValues.


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 6.  RE: Reading Large Files from file system

    Posted Thu September 25, 2008 04:00 PM

    Before routing it to TN using routeXML…why you want to call convertToValues??

    Once you load the file pass the edidata to routeXML thats it.

    First try with loadAs (stream) option…

    Also dont step thru the flow try Run directly or schedule the service and see how it goes…

    Steps:
    getFile (loadAs-stream)
    streamToString(PSUtil svc) map o/p string to edidata
    routeXML(edidata)–send EDI to TN

    HTH,
    RMG


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 7.  RE: Reading Large Files from file system

    Posted Thu September 25, 2008 04:43 PM

    Step 2 will load the entire file into memory, which Nisha appears to be trying to avoid.


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 8.  RE: Reading Large Files from file system

    Posted Thu September 25, 2008 05:22 PM

    Do you think any other way to avoid…esp. large EDI files?

    convertToValues (Iterator) job comes after routing from TN and hits a service for further processing…Isn’t it??

    HTH,
    RMg


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 9.  RE: Reading Large Files from file system

    Posted Fri September 26, 2008 08:16 AM

    Hello Guys,

    If the file is very large and the IS goes for a toss even after processing with ffiterator while convertToValues and or with Stream(streamToString), then I think splitting the file in small chunks and then validating ,routing and processing each chunk can be a way through to avoid loading of entire file. But I dont know how much can this be helpfull to nisha as splitting the the file into many smaller files would break the integrity of the records in file .

    Jiten


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 10.  RE: Reading Large Files from file system

    Posted Fri September 26, 2008 04:42 PM

    Yes i agree with you…but that is only way dealing EDI large files thru IS service…Incase use of TN LargeFile handling its a straight forward.

    HTH,
    RMG


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 11.  RE: Reading Large Files from file system

    Posted Fri September 26, 2008 05:48 PM

    Just to clarify, streamToString will always load the complete file into memory. When using a stream for large file handling, it is important to not do anything that will read the entire stream of bytes into memory.


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 12.  RE: Reading Large Files from file system

    Posted Fri September 26, 2008 07:29 PM

    But with loadAS stream always help dealing performance issues isn’t? BTW,Is there any article that confirms streamToString loads into memory?
    just incase.

    TIA,
    RMG


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 13.  RE: Reading Large Files from file system

    Posted Fri September 26, 2008 08:52 PM

    Yes, loadAs stream is the right thing to do to avoid loading an entire file into memory.

    But as soon as you do streamToString, it will read the stream until EOF and make a String object out of the bytes. streamToBytes also reads until end of stream.

    From the wM docs for streamToBytes: “This service reads all of the bytes from stream until the end of file is reached…”

    streamToString is in PSUtilities. You can review the source for that. It too reads until the end of the stream.


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 14.  RE: Reading Large Files from file system

    Posted Fri September 26, 2008 09:06 PM

    Thanks for the pointers…I will review the source now…

    HTH,
    RMG


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services