App Connect

 View Only
  • 1.  Java Compute Node to Unzip multiple files

    Posted Wed June 29, 2022 02:28 AM
    Hi,

    I have requirement to unzip multiples in a directory using ACE toolkit, search for csv files within the directory and send them to the queue. I never done this before but i know is possible to do.

    Please share some approach and resolution around this.

    Thanks 

    Warm Regards
    Justice

    ------------------------------
    Tlabo Justice Theledi
    ------------------------------


  • 2.  RE: Java Compute Node to Unzip multiple files

    Posted Thu June 30, 2022 11:04 AM
    You don't actually have to unzip to a file system to do what you want, assuming that the zip file is the input data to the JCN (presumably as a BLOB).

    The java.util.zip package can be used to process the file, only really unzipping the csv files you want to process.  The JCN can then propagate the CSV data out to a MQOutput node to output the data to a queue.

    It would be something like this:

    1. Create ByteArrayInputStream from BLOB input
    2. Create ZipInputStream from ByteArrayInputStream
    3. Loop: 
    3.1.  getNextEntry() from ZipInputStream
    3.2.  If getName() matches *.csv:
    3.2.1. Create ByteArrayOutputStream to receive data, and bytes buffer for data
    3.2.2. Loop:
    3.2.2.1.  read() from ZipInputStream into bytes buffer
    3.2.2.2.  Write bytes buffer to ByteArrayOutputStream
    3.2.2.3.  Until length read == 0
    3.2.3. Convert ByteArrayOutputStream to BLOB
    3.2.4. Create OutputRoot for BLOB
    3.2.5. Propagate (presumably to MQOutput, but doesn't matter to JCN)
    3.3.  closeEntry() to go to next one
    3.4.  Until no next entry exists
    3.5.  Close ZipInputStream & ByteArrayInputStream

    If you google Java Zip, there are lots of samples out there.

    ------------------------------
    Tony Hays
    Senior IT Architect
    IBM Global Services
    Spokane WA
    706-305-8487
    ------------------------------



  • 3.  RE: Java Compute Node to Unzip multiple files

    Posted Mon July 04, 2022 08:31 AM
    Hi Tony,

    Looks good from the prototype, hopefully it works for the JCN. Well as for googling Java Zip samples, mostly they dont use JCN instead uses extenal java class. 

    But so far, i get the logic. Thanks

    --------------------------------------------
    Justice Theledi
    Integration Developer
    SPTS
    083 9600 762




    ------------------------------
    Tlabo Justice Theledi
    ------------------------------