Author |
Message
|
kash3338 |
Posted: Thu Apr 01, 2010 9:13 pm Post subject: Accessing Environment in Java Compute Node |
|
|
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 |
|
|
fjb_saper |
Posted: Thu Apr 01, 2010 9:22 pm Post subject: |
|
|
Grand High Poobah
Joined: 18 Nov 2003 Posts: 20729 Location: LI,NY
|
|
Back to top |
|
|
Bartez75 |
Posted: Fri Apr 02, 2010 2:05 am Post subject: |
|
|
Voyager
Joined: 26 Oct 2006 Posts: 80 Location: Poland, Wroclaw
|
|
Back to top |
|
|
Vitor |
Posted: Fri Apr 02, 2010 5:05 am Post subject: |
|
|
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 |
|
|
kash3338 |
Posted: Sun Apr 04, 2010 9:14 pm Post subject: |
|
|
Shaman
Joined: 08 Feb 2009 Posts: 709 Location: Chennai, India
|
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 |
|
|
fjb_saper |
Posted: Sun Apr 04, 2010 9:29 pm Post subject: |
|
|
Grand High Poobah
Joined: 18 Nov 2003 Posts: 20729 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 |
|
|
kash3338 |
Posted: Sun Apr 04, 2010 10:59 pm Post subject: |
|
|
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 |
|
|
Gaya3 |
Posted: Sun Apr 04, 2010 11:11 pm Post subject: |
|
|
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 |
|
|
kash3338 |
Posted: Mon Apr 05, 2010 12:37 am Post subject: |
|
|
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 |
|
|
Vitor |
Posted: Mon Apr 05, 2010 6:05 am Post subject: |
|
|
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 |
|
|
|