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 Global Environment in Java Compute node

Post new topic  Reply to topic
 Accessing Global Environment in Java Compute node « View previous topic :: View next topic » 
Author Message
akmar2k
PostPosted: Tue Jun 22, 2010 7:50 am    Post subject: Accessing Global Environment in Java Compute node Reply with quote

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
View user's profile Send private message
Vitor
PostPosted: Tue Jun 22, 2010 7:54 am    Post subject: Reply with quote

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
View user's profile Send private message
mqjeff
PostPosted: Tue Jun 22, 2010 9:07 am    Post subject: Reply with quote

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
View user's profile Send private message
joebuckeye
PostPosted: Wed Jun 23, 2010 5:00 am    Post subject: Reply with quote

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
View user's profile Send private message
prasad.edlabadkar
PostPosted: Wed Jun 30, 2010 11:23 pm    Post subject: Re: Accessing Global Environment in Java Compute node Reply with quote

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
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Accessing Global 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.