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 » Accessing Environment by path in Java compute node

Post new topic  Reply to topic
 Accessing Environment by path in Java compute node « View previous topic :: View next topic » 
Author Message
KIT_INC
PostPosted: Wed Jan 06, 2010 6:41 am    Post subject: Accessing Environment by path in Java compute node Reply with quote

Knight

Joined: 25 Aug 2006
Posts: 589

The input to the JCN has
Environment.data.Mydata = 'WMB';

In the JCN , I tried to access the value by doing

MbMessage env = contact admin.getGlobalEnvironment();
MbElement Mydata = env.getRootElement().getFirstElementByPath("/Environment/data/Mydata");

I also tried
MbElement Mydata = env.getRootElement().getLastChild();

But I am not getting the value.
Can anyone help?
Back to top
View user's profile Send private message
WMBDEV1
PostPosted: Wed Jan 06, 2010 10:15 am    Post subject: Reply with quote

Sentinel

Joined: 05 Mar 2009
Posts: 888
Location: UK

When using:

Code:

env.getRootElement().getLastChild();


Have you tried printing out the name of the node that this points to using the getName() method.

I suspect you need to navigate the tree some more to get to the element you're after.[/code]
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed Jan 06, 2010 10:51 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Your environment tree does not have a root element called 'Environment'.
You need:
Code:
MbMessage env = contact admin.getGlobalEnvironment();
MbElement Mydata = env.getRootElement().getFirstElementByPath("/data/Mydata");
Back to top
View user's profile Send private message
KIT_INC
PostPosted: Fri Jan 08, 2010 8:25 am    Post subject: Reply with quote

Knight

Joined: 25 Aug 2006
Posts: 589

Thanks Kimbert, I am now able to pickup the Environment using

MbElement Mydata = env.getRootElement().getFirstElementByPath("/data/Mydata");

Since I need to use the Environment value as a string, so I use

String Mydata1 = Mydata.toString() ;

I found that Mydata1 actually contains
MbElement( type: 3000000 name: FileName value: WMB ) and not just WMB which is my original input to the JCN (Environment.data.Mydata = 'WMB'; ).

I am now using substring function to get WMB out of the Mydata1.

Am I doing it right thing? or there is a better way to do it ?
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Jan 08, 2010 8:50 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

That's the wrong way to get the value of an MBElement object.

Go back to the javadoc.
Back to top
View user's profile Send private message
KIT_INC
PostPosted: Fri Jan 08, 2010 9:20 am    Post subject: Reply with quote

Knight

Joined: 25 Aug 2006
Posts: 589

Hi mqjeff. thanks for stopping me from going down the wrong path. I have it working now.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Accessing Environment by path in Java compute 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.