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.

 View Only
  • 1.  Using object stream from java

    Posted Tue November 27, 2007 09:11 PM

    I have a image file that need to be exposed as stream. So I have written a fs which reads the image from File system and outputs stream as object.
    We have a java client which calls this flow service.

    Do anybody have any examples of java code in using the stream, convert this stream back to image?


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


  • 2.  RE: Using object stream from java

    Posted Wed November 28, 2007 12:14 PM

    You might want to use the javax.imageio package provided in versions above J2SE 1.4.

    Check with your resources about the java version.

    HTH
    Malhar


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


  • 3.  RE: Using object stream from java

    Posted Wed November 28, 2007 04:10 PM

    Couple of things:

    • “I have a image file that need to be exposed as stream.” I’m willing to bet that that is not true. Rather, you simply need to return the contents of the file, which happens to be an image file, correct?

    • Do not expose the “image” as a stream object. It won’t work across the network. Just return the bytes. The Java client will handle what it should do with the bytes.

    • A stream object is only valid in the context of the current JVM–you can’t hand it off to another JVM.

    • A stream isn’t a useful object in and of itself. It is always “backed” by something else (bytes in a file, bytes in an array, etc.). One doesn’t “convert” a stream to anything. One reads from the stream. In this case, the bytes of the image file–but the fact the bytes are an image is immaterial. It could be a Word document, a PDF file, etc.

    • javax.imageio is in no way or form needed for this sort of operation, given the info so far.


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


  • 4.  RE: Using object stream from java

    Posted Wed December 05, 2007 02:54 PM

    Thank you for your details.

    What is the best way to transfer an image. I was able to transfer image in bytes and client was able to successfully read the image in our POC.

    But We are expecting lots of load with image transfers.

    So we want to handle the transfer of these images the best possible way in terms of cosuming less memory and best performance.

    Can you provide any suggestions regarding this?


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


  • 5.  RE: Using object stream from java

    Posted Wed December 05, 2007 05:01 PM

    To keep memory usage to a minimum, use streams within IS when retrieving the image file from disk. Depending on how you are passing the bytes to the client, you may be able to avoid loading entire image files into memory.


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


  • 6.  RE: Using object stream from java

    Posted Wed December 05, 2007 06:07 PM

    I am unclear about -->avoid loading entire image files into memory

    How can I do that?


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


  • 7.  RE: Using object stream from java

    Posted Wed December 05, 2007 08:04 PM

    In addition to:

    1. how to avoid loading entire image files into memory
    2. Can we use any compression mechanisms?

    to improve memory usage and performance.


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


  • 8.  RE: Using object stream from java

    Posted Wed December 05, 2007 11:56 PM
    1. Use streams where possible. You can learn more about those on the web. Depending on how your service is constructed, you may or may not be able to respond to the client without loading the entire file.
    2. Compression will decrease performance. And most image files are already compressed to the extent that they can be.

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