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 in Java Compute Node

Post new topic  Reply to topic
 Accessing Environment in Java Compute Node « View previous topic :: View next topic » 
Author Message
kash3338
PostPosted: Thu Apr 01, 2010 9:13 pm    Post subject: Accessing Environment in Java Compute Node Reply with quote

Shaman

Joined: 08 Feb 2009
Posts: 709
Location: Chennai, India

Hi,

I need to access few Environment variables inside my Java compute node and I am using "assembly.getGlobalEnvironment()", but I get only null values when I do this. I have set the values of Environment variable in first compute node in my flow.

Can anyone tell e how to access the Environment variable inside my JCN?
Back to top
View user's profile Send private message Send e-mail
fjb_saper
PostPosted: Thu Apr 01, 2010 9:22 pm    Post subject: Reply with quote

Grand High Poobah

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

Did you check the manual? What else have you tried?
See http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/topic/com.ibm.etools.mft.doc/ac30330_.htm#ac30330_


_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Bartez75
PostPosted: Fri Apr 02, 2010 2:05 am    Post subject: Reply with quote

Voyager

Joined: 26 Oct 2006
Posts: 80
Location: Poland, Wroclaw

I think you should call ....getGlobalEnvironment().getRootElement()

This will return you root element of Environment.
Then you have to get your element that you have saved in previous compute node. So:
Code:

MbElement env = assembly.getGlobalEnvironment().getRootElement()
MbElement yourVariable = env.getFirstElementByPath("yourVariable")
String str = yourVariable.getValue().toString();


Something like this.

Check also this help: http://publib.boulder.ibm.com/infocenter/wbihelp/v6rxmx/topic/com.ibm.etools.mft.broker.doc/com/ibm/broker/plugin/package-overview.html
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Apr 02, 2010 5:05 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

You could also try searching for the answer; this question has been asked and answered before, once quite recently IIRC
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
kash3338
PostPosted: Sun Apr 04, 2010 9:14 pm    Post subject: Reply with quote

Shaman

Joined: 08 Feb 2009
Posts: 709
Location: Chennai, India

Bartez75 wrote:
I think you should call ....getGlobalEnvironment().getRootElement()

This will return you root element of Environment.
Then you have to get your element that you have saved in previous compute node. So:
Code:

MbElement env = assembly.getGlobalEnvironment().getRootElement()
MbElement yourVariable = env.getFirstElementByPath("yourVariable")
String str = yourVariable.getValue().toString();


Something like this.

Check also this help: http://publib.boulder.ibm.com/infocenter/wbihelp/v6rxmx/topic/com.ibm.etools.mft.broker.doc/com/ibm/broker/plugin/package-overview.html



Hi, I am able to understand the syntax of parsing this Environment tree inside the JCN, but i am still not able to read the values. When i try to debug, i find the Environment, Local Environment and the Message tree coming as NULL inside the JCN evaluate method. Why is this so? Can anyone guide me on this.
Back to top
View user's profile Send private message Send e-mail
fjb_saper
PostPosted: Sun Apr 04, 2010 9:29 pm    Post subject: Reply with quote

Grand High Poobah

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

put in a trace node with :

-----------------------------------
$Root
-----------------------------------
$Environment
-----------------------------------
$LocalEnvironment
-----------------------------------

Maybe you are not trying to read what you should...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
kash3338
PostPosted: Sun Apr 04, 2010 10:59 pm    Post subject: Reply with quote

Shaman

Joined: 08 Feb 2009
Posts: 709
Location: Chennai, India

fjb_saper wrote:
put in a trace node with :

-----------------------------------
$Root
-----------------------------------
$Environment
-----------------------------------
$LocalEnvironment
-----------------------------------

Maybe you are not trying to read what you should...


When i trace it, i can see all the values populated just before the Java Compute Node. But once it comes inside, all the three roots (Message, Environment, LocalEnvironment) are set to null. Is there any property in JCN that i need to set to read the message contents?
Back to top
View user's profile Send private message Send e-mail
Gaya3
PostPosted: Sun Apr 04, 2010 11:11 pm    Post subject: Reply with quote

Jedi

Joined: 12 Sep 2006
Posts: 2493
Location: Boston, US

show us your code please
_________________
Regards
Gayathri
-----------------------------------------------
Do Something Before you Die
Back to top
View user's profile Send private message
kash3338
PostPosted: Mon Apr 05, 2010 12:37 am    Post subject: Reply with quote

Shaman

Joined: 08 Feb 2009
Posts: 709
Location: Chennai, India

Gaya3 wrote:
show us your code please


This is the piece of code that i have in my evaluvate method in my JCN. I want to get the value of UserName and Password from the Environment variables that i have set in a compute node earlier in the flow.

"MbElement env = assembly.getGlobalEnvironment().getRootElement();
MbElement UserName = env.getFirstElementByPath("Variable/UserName");
String usrName = UserName.getValue().toString();

MbElement Password= env.getFirstElementByPath("Variable/Password");
String pwd= UserName.getValue().toString();"

I have set the Environment variables in my compute node as,
SET Environment.Variable.UserName = "username";
SET Environment.Variable.Password = "password";

Now the problem is, when i debug and check, the Message, LocalEnvironment and the Environment tree comes as null inside my JCN.
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Mon Apr 05, 2010 6:05 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

kash3338 wrote:
MbElement Password= env.getFirstElementByPath("Variable/Password");
String pwd= UserName.getValue().toString();"


Shouldn't that be Password.getValue().toString() ??

kash3338 wrote:
Now the problem is, when i debug and check, the Message, LocalEnvironment and the Environment tree comes as null inside my JCN.


No, the problem is you're using the debugger when you've already been advised to take a user trace. A user trace will give you a far better picture of what's happening inside the flow. If you combine it with a Trace node (again as previously advised) this will prove to the sceptics amongst us that the Environment tree holds what you claim it does in the positions you claim they're in.
_________________
Honesty is the best policy.
Insanity is the best defence.
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 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.