|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Accessing Global Environment in Java Compute node |
« View previous topic :: View next topic » |
Author |
Message
|
akmar2k |
Posted: Tue Jun 22, 2010 7:50 am Post subject: Accessing Global Environment in Java Compute node |
|
|
Novice
Joined: 01 Jun 2006 Posts: 22
|
Hi All,
I am using the Global Environment in Java Compute node to store two xml messages which are retrieved using MQGet nodes. I need to combine these messages to create a final output message.
The issue that I am facing is that, when I retrieve and store the second message, the first message also get overwritten within the Global environment.
Has any one faced this problem? The code snippet for storing the message is below.
MbMessage inMessage = contact admin.getMessage();
// create new message
MbMessage outMessage = new MbMessage(inMessage);
MbMessageAssembly outAssembly = new MbMessageAssembly(contact admin,
outMessage);
try {
// ----------------------------------------------------------
// Add user code below
MbMessage env = contact admin.getGlobalEnvironment();
MbElement outRoot = outMessage.getRootElement();
MbElement firstMessage= outRoot.getLastChild().getFirstChild();
// Store the XMLNS Variable in the Global environment variable
env.getRootElement().createElementAsFirstChild(MbElement.TYPE_NAME, "Variables", null);
env.getRootElement().getFirstChild().createElementAsFirstChild(MbElement.TYPE_NAME, "FirstInputMessage", null);
env.getRootElement().getFirstChild().getFirstChild().addAsFirstChild(firstMessage.copy());
// End of user code
// ----------------------------------------------------------
// The following should only be changed
// if not propagating message to the 'out' terminal
out.propagate(outAssembly);
} |
|
Back to top |
|
 |
Vitor |
Posted: Tue Jun 22, 2010 7:54 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Well I don't know Java from a hole in the ground, but I don't see anything in the code that provides for 2 messages to be stored separately.
I also don't see why you're using this method instead of a collector node. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Jun 22, 2010 9:07 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Vitor wrote: |
Well I don't know Java from a hole in the ground, but I don't see anything in the code that provides for 2 messages to be stored separately. |
Maybe my coffee hasn't kicked in yet, but reading that Java code, I almost expect it to produce a new "Variables" element each time through, and produce a new "FirstInputMesage" under that. So that there would be the ESQL equivalent structure of Environment.Variables[].FirstInputMessage
But maybe repeated createElementAsFirstChild calls will overwrite the current first child rather than move it to the 2nd child? |
|
Back to top |
|
 |
joebuckeye |
Posted: Wed Jun 23, 2010 5:00 am Post subject: |
|
|
 Partisan
Joined: 24 Aug 2007 Posts: 365 Location: Columbus, OH
|
Why don't you capture the MbMessage objects being created in each of your steps instead of repeatedly calling env.getRootElement() and then env.getRootElement().getFirstChild()?
May make it easier to debug the problem you are having.
I also agree with Jeff in that you seem to be creating two Variable elements under the global environment root. |
|
Back to top |
|
 |
prasad.edlabadkar |
Posted: Wed Jun 30, 2010 11:23 pm Post subject: Re: Accessing Global Environment in Java Compute node |
|
|
Novice
Joined: 10 Feb 2006 Posts: 21 Location: Pune, India
|
akmar2k wrote: |
Code: |
MbMessage env = contact admin.getGlobalEnvironment(); |
|
Hi,
You are getting the environment tree from the input Assembly and propagating the output assembly. Try changing it to
Code: |
MbMessage env = outAssembly.getGlobalEnvironment(); |
_________________ Thanks and Regards
Prasad Edlabadkar
Tech Lead - Websphere Business Integration |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|