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 » To store string value in Local environment

Post new topic  Reply to topic Goto page 1, 2  Next
 To store string value in Local environment « View previous topic :: View next topic » 
Author Message
gagan.maverick
PostPosted: Mon Oct 06, 2014 1:07 am    Post subject: To store string value in Local environment Reply with quote

Acolyte

Joined: 30 Sep 2014
Posts: 50

Hi Guys I need to store a string value which contains file name in Local environment in JCN ..

String s = String.format("Entry: %s ",
entry.getName());
System.out.println(s);

Basically value of s to local environment in Jcn
Back to top
View user's profile Send private message
gagan.maverick
PostPosted: Mon Oct 06, 2014 1:52 am    Post subject: Reply with quote

Acolyte

Joined: 30 Sep 2014
Posts: 50

if i can't modify the local env in JCN then can you tell me how can i add the file name in the msgbody which i have populated as outputroot.blob.blob.. I mean in headers or in any variable
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Oct 06, 2014 3:56 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

You will need to explain slowly and carefully what you want to do, and (this is important) why you want to do it. Right now, I have no idea what you need.
_________________
Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too.
Back to top
View user's profile Send private message
tank_n_spank
PostPosted: Mon Oct 06, 2014 4:10 am    Post subject: Reply with quote

Apprentice

Joined: 02 Sep 2014
Posts: 37

I am with Kimbert on this one.

I honestly have no idea what you have pasted, but from what I've gathered, is that what you're after?
Code:

DECLARE FILE_NAME CHARACTER;
         SET FILE_NAME = 'Local Test' ||'.txt';
         SET OutputLocalEnvironment.Destination.File.Name = FILE_NAME;
         
Back to top
View user's profile Send private message
gagan.maverick
PostPosted: Mon Oct 06, 2014 4:21 am    Post subject: Reply with quote

Acolyte

Joined: 30 Sep 2014
Posts: 50

Sorry guys for the ambiguity..

My requirement was to unzip the zip files in JAVA , which I did. now in JCN i want to store the file names of the contents of zip file in local environment or any where in the output message to use it for further processing.. in JCN i have stored the file name in s...

Code:
 while ((entry = zipStream.getNextEntry()) != null) {
                         
                         
                           String s = String.format("Entry: %s ",                               
                                entry.getName());               
                          System.out.println(s);

int len= 0;
                         
                          StringBuffer sb_result = new StringBuffer();

                          while ((len = zipStream.read(buffer)) > 0) {
                                  sb_result.append(new String(buffer, 0, len));
                          }
                         
                         
                          zipStream.closeEntry();
                          String result = sb_result.toString();

                          file_num = file_num + 1;
                          MbElement root = outAssembly.getMessage().getRootElement();
             
                          msgBytes = result.getBytes();
               
                          msgBody = outMessage.getRootElement().createElementAsLastChildFromBitstream(msgBytes,"NONE", "", "", "", 0, 0, 0);
                         
                          out.propagate(outAssembly);
                          msgBody.detach();
Back to top
View user's profile Send private message
McueMart
PostPosted: Mon Oct 06, 2014 4:21 am    Post subject: Reply with quote

Chevalier

Joined: 29 Nov 2011
Posts: 490
Location: UK...somewhere

I think gagan just want to put some data (in this case a String) into the LocalEnvironment within a Java Compute Node.

This is very simple and is the same as modifying any of the other parts of the logical tree in a JCN.

When forming the Output MbMessageAssembly, look at the second constructor options here:

http://www-01.ibm.com/support/knowledgecenter/SSKM8N_8.0.0/com.ibm.etools.mft.plugin.doc/com/ibm/broker/plugin/MbMessageAssembly.html
Back to top
View user's profile Send private message
gagan.maverick
PostPosted: Mon Oct 06, 2014 4:26 am    Post subject: Reply with quote

Acolyte

Joined: 30 Sep 2014
Posts: 50

Yes correct i would like to assign the value of s to local environment .. but i am getting type mismatch error.. how to resolve that..
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Oct 06, 2014 6:33 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Thanks for explaining - I get the general idea now. But I still have questions.
Which of the following options are you trying to do:
a) pass a list of zip file entries to the remainder of the same message flow
or
b) pass a list of zip file entries to another message flow
_________________
Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too.
Back to top
View user's profile Send private message
gagan.maverick
PostPosted: Mon Oct 06, 2014 11:08 pm    Post subject: Reply with quote

Acolyte

Joined: 30 Sep 2014
Posts: 50

I am sending the unzipped files as blob to the same message flow for processing as the zip file contained an xml file and one pdf file . I need to do further processing on XML file. so in order to know which files has come out I am trying to store its name in local environment for routing.
Back to top
View user's profile Send private message
gagan.maverick
PostPosted: Tue Oct 07, 2014 1:20 am    Post subject: Reply with quote

Acolyte

Joined: 30 Sep 2014
Posts: 50

Hi i created an mb element for local environment..

MbElement env = assembly.getLocalEnvironment().getRootElement();
MbElement newEnv = env.getFirstElementByPath("messageType");


but how to assign the string s to it.. I mean to newEnv and propagate to Output localenv..
Back to top
View user's profile Send private message
Esa
PostPosted: Tue Oct 07, 2014 2:08 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

gagan.maverick wrote:
Hi i created an mb element for local environment..

MbElement env = assembly.getLocalEnvironment().getRootElement();
MbElement newEnv = env.getFirstElementByPath("messageType");



No, you didn't create anything yet. You just tried to access a non-existent element.
Back to top
View user's profile Send private message
kimbert
PostPosted: Tue Oct 07, 2014 5:54 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
I am sending the unzipped files as blob to the same message flow for processing as the zip file contained an xml file and one pdf file . I need to do further processing on XML file. so in order to know which files has come out I am trying to store its name in local environment for routing.
Sounds like a long-winded way to do it. I don't understand why you need to put the filename into the LocalEnvironment. Is there any reason why you are not doing this:
- extract the XML file as as BLOB. Your loop is already doing that.
- parse the XML file using MbElement.createElementAsLastChildFromBitstream(...). Google will help you with the details.
- Allow the message tree to propagate onward to the downstream nodes in the flow.

One other point - if you know that the zip file contains exactly two entries then the while loop is probably not the best solution. Your code should extract each entry in turn, check that it is the expected type of entry, and complain if it gets unexpected input.
_________________
Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too.
Back to top
View user's profile Send private message
gagan.maverick
PostPosted: Tue Oct 07, 2014 10:04 pm    Post subject: Reply with quote

Acolyte

Joined: 30 Sep 2014
Posts: 50

Hi, Actually in my zip file I have one pdf file as well and i need to store that pdf file name somewhere .. so i was wondering if i could store that name coz i will need it afterwards .. there will be plenty of these pdf files and one xml .. in a zip file
Back to top
View user's profile Send private message
gagan.maverick
PostPosted: Thu Oct 09, 2014 10:27 pm    Post subject: Reply with quote

Acolyte

Joined: 30 Sep 2014
Posts: 50

Hi guys , can you direct me how can i achieve the above .. I mean storing the file name either in message header or in local environment
Back to top
View user's profile Send private message
Esa
PostPosted: Fri Oct 10, 2014 2:52 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

gagan.maverick wrote:
Hi guys , can you direct me how can i achieve the above .. I mean storing the file name either in message header or in local environment


You almost did it already.

Take a look at this
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 » To store string value in Local environment
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.