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 » getGlobalEnvironment

Post new topic  Reply to topic
 getGlobalEnvironment « View previous topic :: View next topic » 
Author Message
goffinf
PostPosted: Wed Dec 03, 2008 8:51 am    Post subject: getGlobalEnvironment Reply with quote

Chevalier

Joined: 05 Nov 2005
Posts: 401

Broker version 6.1 / Windows

Is it possible to call getGlobalEnvironment() from the constructor of a custom node ?

I want to add stuff onto the global environment when the node is loaded by the broker rather when the evaluate() method is called.

My node is not an MBInputNode (if that makes a difference).

Obviosuly when evaluate is called an MbMessageAssembly is passed in, and from there it is possible to get to the global environment thus :-

public void evaluate(MbMessageAssembly contact admin) throws MbException {

....
MbMessage inMessage = contact admin.getMessage();
MbMessage outMessage = new MbMessage(inMessage);

MbMessageAssembly outAssembly = new MbMessageAssembly(contact admin, outMessage);

MbElement envRoot = outAssembly.getGlobalEnvironment().getRootElement();

...

but I don't have an MbMessageAssembly in the constructor. Is it possible to create one from scratch ??

Thanks

Fraser.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Dec 03, 2008 8:55 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

The Global Environment doesn't exist outside the execution of a message flow.

You can create persistent data structures in the constructor and then populate Global Environment from that, but the Environment tree does not exist until you are in the evaluate method or in a run method of an Input plugin node.
Back to top
View user's profile Send private message
goffinf
PostPosted: Wed Dec 03, 2008 9:27 am    Post subject: Reply with quote

Chevalier

Joined: 05 Nov 2005
Posts: 401

mqjeff wrote:
The Global Environment doesn't exist outside the execution of a message flow.

You can create persistent data structures in the constructor and then populate Global Environment from that, but the Environment tree does not exist until you are in the evaluate method or in a run method of an Input plugin node.


Yes I see. Thanks.

Slight change of direction then. Actually all I need is an MbElement to hold some XML as a string (i.e. I don't want it to be parsed/escaped). Can I cruft up an MbElement like this ? :-

MbMessage msg = new MbMessage();
MbElement msgRoot = msg.getRootElement();
MbElement msgParser = msgRoot.createElementAsLastChild(MbBLOB.PARSER_NAME);

MbElement tempElement = msgParser.createElementAsLastChild(MbElement.TYPE_NAME);
tempElement.setName("myElement");

MbElement finalElement = tempElement.createElementAsLastChild(MbElement.TYPE_VALUE, "myElementname", "<foo/>");

Fraser.
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed Dec 03, 2008 11:38 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

I assume that your goal is not just to put stuff into the global environment. You want it there in order to do something, What are you really trying to do?
Back to top
View user's profile Send private message
goffinf
PostPosted: Wed Dec 03, 2008 1:36 pm    Post subject: Reply with quote

Chevalier

Joined: 05 Nov 2005
Posts: 401

kimbert wrote:
I assume that your goal is not just to put stuff into the global environment. You want it there in order to do something, What are you really trying to do?


Actually I was using the Environment as a location for data that I was passing to the IA91 CacheNodes putIntoNamedCache method. It expects 2 arguments of type MbElement. This was fine until I realised that I wanted to load data into the cache at the point when one of my custom nodes was loaded by Broker (the cached data is for this nodes use later on when it gets called in a flow), and that I don't have access to the Environment until evaluate is called (as mqjeff said above).

Anyway it looks like I can construct an MbMessage from scratch and from that an MbElement. I've tested it and it seems to work OK.

Thanks for asking

Fraser.
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 » getGlobalEnvironment
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.