ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Handling Zip file in File Input Node

Post new topic  Reply to topic Goto page 1, 2  Next
 Handling Zip file in File Input Node « View previous topic :: View next topic » 
Author Message
chaitu
PostPosted: Sun Oct 18, 2015 11:48 pm    Post subject: Handling Zip file in File Input Node Reply with quote

Voyager

Joined: 15 Apr 2014
Posts: 89

Hello All,

I have a new requirement, which i need to unzip a file with 3 xml files and process them with validation and have to place them in a Queue.

Till now i deal with single file in file input node could anyone please guide me on this.





Regards
Back to top
View user's profile Send private message
smdavies99
PostPosted: Mon Oct 19, 2015 12:23 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

There is no direct support for unzipping a mesage in the product.

There used to be a support pack that did it but it has not been updated for at least three versions of the product.

What to do?

Write some Java to do it.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
chaitu
PostPosted: Mon Oct 19, 2015 12:45 am    Post subject: Reply with quote

Voyager

Joined: 15 Apr 2014
Posts: 89

Hi smdavies99,

Thanks for your reply.

My flow is like fileinput>> compute>> MQoutput.

My question is if i send a xml file as an request fileinput node receive the request and send it to downstream nodes for further processing, if i sent a message domain to xmlnsc

But now the request file is a Zip of 3 xml files so what i have to do to receive the request by file input node and to send it to downstream node for further processing.

what configurations i need to do to file input node.

From your below post i understood that i need to use Java compute node to unzip the file.

But any one let me know how i have to configure the file node for above requirement.

Thanks in advance.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Mon Oct 19, 2015 2:11 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

Read the file as a BLOB (i.e. configure the FileInput node properties)
Unzip
Extract each message
Send to destination
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
chaitu
PostPosted: Mon Oct 19, 2015 3:29 am    Post subject: Reply with quote

Voyager

Joined: 15 Apr 2014
Posts: 89

Hi smdavies99,

Thanks for the prompt reply.

I am able to read the file by setting the message domain to blob.

now i am trying to unzip the file. I went through some articles but using java compute node.

Is it possible to do the same in esql. It is more helpful to me as I am novice in JCN.

Thanks in Advance.
Regards.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Mon Oct 19, 2015 3:57 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

There is not ESQL function for UNZIPping data.

You will have to use some JAVA but that could be called from ESQL rather than via a JCN.
The choice is yours.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Mon Oct 19, 2015 1:45 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

You could also choose to write your own ESQL code for parsing a BLOB as a zip file.

It's a very bad idea.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
chaitu
PostPosted: Tue Oct 20, 2015 10:42 pm    Post subject: Reply with quote

Voyager

Joined: 15 Apr 2014
Posts: 89

Hi All,

Thanks for the response.

Now I am able to unzip the zip file and extracted the files. Now i am able to place the file in Q also but getting an issue while placing the files.

Like suppose i have 2 xml files on my zip file, after extracting the file and converting the blod in to xmlnsc the first xml file is saving in queue without any issue.
But after placing the first file in the queue the cursor come back and extract the 2nd file and placing 1st and 2nd files together(need to be place only 2nd).

flow is like.

filei/p>>jcn>>rcd>>compute>>mqo/p.

i am using set outputroot = inputroot;

i also tried with set outputroot = inputroot.xmlnsc;?(but it storing zero data in Q).

Could anyone please help me to figure it out.

Regards.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Oct 21, 2015 3:51 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

chaitu wrote:
i am using set outputroot = inputroot;

i also tried with set outputroot = inputroot.xmlnsc;?(but it storing zero data in Q).


The MQOutput node sends the entire Root message tree you send it.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
chaitu
PostPosted: Thu Oct 29, 2015 2:02 am    Post subject: Reply with quote

Voyager

Joined: 15 Apr 2014
Posts: 89

Hi All,

My requirement have update like instead of all XML files in ZIP file there are a combination of files(.txt,.xml,.jpg...)
I need to change my total flow like

FILE I/P>>COMPUTE>>MQOUTPUT.

i was asked to call a java class from esql.
so i am planing to use a java class to unzip the file and extract the files from it and to in C:\ drive.

From my understanding
To achieve this i must need a jar file of the java code.
i have to call this using esql.

the java code is like

Code:
package com.ibm.broker;
 
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
 
public class MyFileUnzipExmp {
 
    public void unzipFile(String filePath){
         
        FileInputStream fis = null;
        ZipInputStream zipIs = null;
        ZipEntry zEntry = null;
        try {
            fis = new FileInputStream(filePath);
            zipIs = new ZipInputStream(new BufferedInputStream(fis));
            while((zEntry = zipIs.getNextEntry()) != null){
                try{
                    byte[] tmp = new byte[4*1024];
                    FileOutputStream fos = null;
                    String opFilePath = "C:/"+zEntry.getName();
                    System.out.println("Extracting file to "+opFilePath);
                    fos = new FileOutputStream(opFilePath);
                    int size = 0;
                    while((size = zipIs.read(tmp)) != -1){
                        fos.write(tmp, 0 , size);
                    }
                    fos.flush();
                    fos.close();
                } catch(Exception ex){
                     
                }
            }
            zipIs.close();
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
     
    public static void main(String a[]){
         
        MyFileUnzipExmp mfe = new MyFileUnzipExmp();
        mfe.unzipFile("C:/GBS.zip");
    }
}

i have to give inputroot.blob.blob in place of "C:/GBS.zip".

could any one please review the above code and tell me what need to change.
and also tell me how build a jar file which i have to use in wmb.






Thanks in advance.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Oct 29, 2015 4:26 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

java developers are a dime a dozen. Get some help.
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
smdavies99
PostPosted: Thu Oct 29, 2015 5:36 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

You seem toi be doing direct file access from your Java.
This is generally regarded from 'a bit of a hack' to 'don't do it...'

You should be able to take the buffer that the FileInput node has generously read for you and do an in memory unzip which will leave another im memory structure that contains the bits that you want.

As has been said, get some proper help from people who know how to develop Java for the Message Broker/IIB environment.
This environment is not a J2EE App Server. Trating it as if it was will only lead to grief.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
chaitu
PostPosted: Wed Nov 04, 2015 5:01 am    Post subject: Reply with quote

Voyager

Joined: 15 Apr 2014
Posts: 89

Hi All,

Still I am struggling with JCN,

Requirement is same like i mentioned below.

flow is changed to FileI/P>>JCN>>compute>>fileO/P

in jcn i am calling a java class

GBSUtils c = new GBSUtils();
which i added a .java file to this project.

public void evaluate(MbMessageAssembly assembly) throws MbException {
MbOutputTerminal out = getOutputTerminal("out");
MbOutputTerminal alt = getOutputTerminal("alternate");

MbMessage message = assembly.getMessage();
GBSUtils c = new GBSUtils();
this is code in JCN

coming to .java file
private static void unzip(String zipFilePath, String destDir) {
File dir = new File(destDir);
// create output directory if it doesn't exist
if(!dir.exists()) dir.mkdirs();
FileInputStream fileInputStream;
//buffer for read and write data to file
byte[] buffer = new byte[1024];
try {
fileInputStream = new FileInputStream(zipFilePath);
ZipInputStream zipInputStreams = new ZipInputStream(fileInputStream);
ZipEntry zipEntry = zipInputStreams.getNextEntry();
what i need to give in place of zip file path
anything is needed to add in jcn
the incoming message i took in blob as it is a zip file

Any help is more appreciated.
Regards.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Wed Nov 04, 2015 5:20 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

chaitu wrote:
Hi All,

Still I am struggling with JCN,

Requirement is same like i mentioned below.

flow is changed to FileI/P>>JCN>>compute>>fileO/P

in jcn i am calling a java class

GBSUtils c = new GBSUtils();
which i added a .java file to this project.

public void evaluate(MbMessageAssembly assembly) throws MbException {
MbOutputTerminal out = getOutputTerminal("out");
MbOutputTerminal alt = getOutputTerminal("alternate");

MbMessage message = assembly.getMessage();
GBSUtils c = new GBSUtils();
this is code in JCN

coming to .java file
private static void unzip(String zipFilePath, String destDir) {
File dir = new File(destDir);
// create output directory if it doesn't exist
if(!dir.exists()) dir.mkdirs();
FileInputStream fileInputStream;
//buffer for read and write data to file
byte[] buffer = new byte[1024];
try {
fileInputStream = new FileInputStream(zipFilePath);
ZipInputStream zipInputStreams = new ZipInputStream(fileInputStream);
ZipEntry zipEntry = zipInputStreams.getNextEntry();
what i need to give in place of zip file path
anything is needed to add in jcn
the incoming message i took in blob as it is a zip file

Any help is more appreciated.
Regards.

I repeat what I said before

You seem toi be doing direct file access from your Java.
This is generally regarded from 'a bit of a hack' to 'don't do it...'

_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
timber
PostPosted: Wed Nov 04, 2015 6:24 am    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1292

You need to do something like this:
- Take the byte array that comes from the FileInput node
- Wrap it in a ByteArrrayInputStream
- Create a ZipInputStream from the resulting ByteArrrayInputStream
This does not require any file access from your JCN.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Handling Zip file in File Input Node
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.