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 » Getting null while accessing UDP in JCN impl

Post new topic  Reply to topic
 Getting null while accessing UDP in JCN impl « View previous topic :: View next topic » 
Author Message
vininx
PostPosted: Fri Oct 21, 2011 7:17 am    Post subject: Getting null while accessing UDP in JCN impl Reply with quote

Acolyte

Joined: 13 Oct 2009
Posts: 69

Hi All,
I am facing 2 problems in my user defined node,
Problem 1:-
-------------
While accessing the user defined node properties, in the Java implementation, I am getting null values, please find below the code.

public void onInitialize ()
{
System.out.println (">>> Getting user defined properties");
this.logVar = (String) this.getUserDefinedAttribute ("LogText");
System.out.println (">>> Log Variables" + logVar);
this.attnVar = (String) this.getUserDefinedAttribute("AttnCode");
System.out.println (">>> Attention code" + attnVar);
this.evntVar = (String) this.getUserDefinedAttribute("EventCode");
System.out.println (">>> Event code" + evntVar);
}

Output in console:-
--------------------
>>> Getting user defined properties
>>> Log Variablesnull
>>> Attention codenull
>>> Event codenull

I am having getter and setter methods for UDP's as well.

Problem2:-
------------
I am populating the environment in Java implementation as below

public void evaluate(MbMessageAssembly contact admin, MbInputTerminal arg1)
throws MbException {
// TODO Auto-generated method stub
System.out.println (">>> User defined node implementation");
MbMessage newMsg = new MbMessage(contact admin.getMessage());
MbMessageAssembly newAssembly = new MbMessageAssembly (contact admin, newMsg);
System.out.println (">>> New message assembly created");
MbElement env = newAssembly.getGlobalEnvironment().getRootElement();
System.out.println (">>> New global environment created");
MbElement var = env.createElementAsFirstChild(MbElement.TYPE_NAME, "Variables", null);
System.out.println (">>> Variables created");
var = var.getFirstElementByPath("Variables");
MbElement esb = var.createElementAsFirstChild(MbElement.TYPE_NAME, "ESB", null);
System.out.println (">>> ESB created");
esb = esb.getFirstElementByPath("ESB");
esb.createElementAsFirstChild(MbElement.TYPE_NAME_VALUE, "LogText", this.logVar);
esb.createElementAsFirstChild(MbElement.TYPE_NAME_VALUE, "AttnCode", this.attnVar);
esb.createElementAsFirstChild(MbElement.TYPE_NAME_VALUE, "EventCode", this.evntVar);
System.out.println (">>> Children's added to ESB");

MbOutputTerminal out = getOutputTerminal ("out");
out.propagate(newAssembly);

}
Event Log:-
-----------
( MB7BROKER.default ) Java exception: ''java.lang.NullPointerException''; thrown from class name: ''com.bankofny.plugins.PassMessageNode'', method name: ''evaluate'', file: ''PassMessageNode.java'', line: '42'

and then 42nd line is,
MbElement esb = var.createElementAsFirstChild(MbElement.TYPE_NAME, "ESB", null);

My intention is to create something like, Environment.Variables.ESB.LogText = 'XYZ'; which should be propagated out.

Please help me out, what I am missing in the implementation
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Oct 21, 2011 7:33 am    Post subject: Reply with quote

Grand High Poobah

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

Quote:
Code:
and then 42nd line is,
MbElement esb = var.createElementAsFirstChild(MbElement.TYPE_NAME, "ESB", null);

My understanding you really meant the type to be NAME_VALUE. As a name type only, wouldn't passing null mean you delete the element just after creating it?
Have you tried passing it an empty string, instead of null?

Are you sure that the offending line is not this one?
Code:
esb = esb.getFirstElementByPath("ESB");

Wouldn't that be looking for .....ESB.ESB (ESB as the first occurrence of a child of tag ESB) and as such return null (not found)?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
vininx
PostPosted: Fri Oct 21, 2011 9:26 am    Post subject: Getting null while accessing UDP in JCN impl Reply with quote

Acolyte

Joined: 13 Oct 2009
Posts: 69

Hi...
I have corrected the second problem putting like,

Code:

globEnv.getRootElement().createElementAsFirstChild(MbElement.TYPE_NAME, "Variables", "").
                              createElementAsFirstChild(MbElement.TYPE_NAME, "ESB", "").
                              createElementAsFirstChild(MbElement.TYPE_NAME_VALUE, "LogText", "MyValue");


It is working fine now.

But still I am facing issue with accessing User defined node's UDP. The getUserDefinedAttribute method is returning null. I have defined the UDP in the User defined node, promoted it across the flow to configure in BAR file and then accessed it via java implementation. Please let me know whether I am missing anything while accessing the user defined properties.
Back to top
View user's profile Send private message
vininx
PostPosted: Fri Oct 21, 2011 10:18 am    Post subject: Getting null while accessing UDP in JCN impl Reply with quote

Acolyte

Joined: 13 Oct 2009
Posts: 69

please confirm whether I need to access the UDP's in the constructor or in onInitialize() method. I have read that it can be done by onInitialize() method, but I am only getting null values.
Back to top
View user's profile Send private message
Gaya3
PostPosted: Fri Oct 21, 2011 10:29 am    Post subject: Re: Getting null while accessing UDP in JCN impl Reply with quote

Jedi

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

vininx wrote:
please confirm whether I need to access the UDP's in the constructor or in onInitialize() method. I have read that it can be done by onInitialize() method, but I am only getting null values.


use localEnvironment to store the values, and try to fetch it will work.
_________________
Regards
Gayathri
-----------------------------------------------
Do Something Before you Die
Back to top
View user's profile Send private message
vininx
PostPosted: Fri Oct 21, 2011 10:35 am    Post subject: Getting null while accessing UDP in JCN impl Reply with quote

Acolyte

Joined: 13 Oct 2009
Posts: 69

Hi Gayathri,
There is a need for me to keep the variables as user defined nodes and access it at run time. How the variables can be kept in localEnvironment Tree... please elaborate....
Back to top
View user's profile Send private message
vininx
PostPosted: Fri Oct 21, 2011 10:37 am    Post subject: Getting null while accessing UDP in JCN impl Reply with quote

Acolyte

Joined: 13 Oct 2009
Posts: 69

Sorry... a small typo... There is a need for me to keep variables as user defined properties....
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Oct 21, 2011 10:39 am    Post subject: Re: Getting null while accessing UDP in JCN impl Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

vininx wrote:
Hi Gayathri,
There is a need for me to keep the variables as user defined nodes and access it at run time. How the variables can be kept in localEnvironment Tree... please elaborate....


You are still apparently trying to populate the contents of UDPs into the Environment tree that will then be read by a common subflow further downstream.

This is an extra, unnecessary, step that is requiring you to create an extra, unnecessary user-defined node.

There is nothing about the use of User Defined Properties that requires that you create a user defined node. There is nothing that prevents any flow from declaring and accessing User Defined Properties directly. There is nothing that makes the properties of a user defined node any more customizable than normal User Defined Properties.

You do not need to define a user defined node if you want to expose properties that can be set in the runtime. You can define User Defined Properties.
Back to top
View user's profile Send private message
Gaya3
PostPosted: Fri Oct 21, 2011 10:47 am    Post subject: Re: Getting null while accessing UDP in JCN impl Reply with quote

Jedi

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

vininx wrote:
Hi Gayathri,
There is a need for me to keep the variables as user defined nodes and access it at run time. How the variables can be kept in localEnvironment Tree... please elaborate....


a small conversation happened before in this forum

http://www.mqseries.net/phpBB2/viewtopic.php?p=260404&sid=434349308f63e2b3760c48c2bd80226b

you have to use LocalEnv to make use of UDP
_________________
Regards
Gayathri
-----------------------------------------------
Do Something Before you Die
Back to top
View user's profile Send private message
Gaya3
PostPosted: Fri Oct 21, 2011 10:49 am    Post subject: Reply with quote

Jedi

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

i still did not understand what you are trying to achieve by this design ?

Let us know what you are looking for
_________________
Regards
Gayathri
-----------------------------------------------
Do Something Before you Die
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Oct 21, 2011 10:55 am    Post subject: Reply with quote

Grand High Poobah

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

As per the examples in the JAVA API (infocenter), this is how you get UDP's in Java:
Code:
MessageFlow mf1 = patternInstanceManager.getMessageFlow("MyFlowProject", "main.msgflow");
Vector<FlowProperty> flowProperties = mf1.getFlowProperties();


So the different UDPS will be in flowProperties... amongst other properties?
see http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/topic/com.ibm.etools.mft.doc/ac30220_.htm
and http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/topic/com.ibm.etools.mft.doc/ac00643_.htm?path=1_7_0_0_8_2#ac00643_

and let's not forget the MbNode methods that you would call on initialization? http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/topic/com.ibm.etools.mft.plugin.doc/com/ibm/broker/plugin/MbNode.html


_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Esa
PostPosted: Mon Oct 24, 2011 4:14 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

fjb_saper wrote:
As per the examples in the JAVA API (infocenter), this is how you get UDP's in Java:
Code:
MessageFlow mf1 = patternInstanceManager.getMessageFlow("MyFlowProject", "main.msgflow");
Vector<FlowProperty> flowProperties = mf1.getFlowProperties();




I think this is quite a misleading code snippet as it is from the new Java API for user defined patterns. For developing ordinary JCN:s you would use the MbNode method getUserDefinedAttribute.

The OP's problem is that he or she is calling the method from onInitialize(). That method is called upon deployment and the UDP:s propably won't be available yet. Anything you put in LocalEnvironment in onInitialize() will not be available when processing the actual messages, and trying to access LocalEnvironment will also give a nullPointerException (I am not sure of it as it has never crossed my mind to try such a bad idea ). Implementing a cache for UDP:s does not make any sense as there is no overhead in calling getUserDefinedAttribute. And LocalEnvironment is definitely not the place for implementing any cache as anyone who has read the manuals can tell.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Mon Oct 24, 2011 4:30 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Esa wrote:
The OP's problem is that he or she is calling the method from onInitialize().


More generally, the OP seems to be confusing User Defined Properties and node properties, and trying to access node properties as if they were User Defined Properties.

Node properties need to be defined as member variables and have appropriately named getters and setters defined on the node, and then can be accessed as member variables or using the getters during evaluate() without needing to do anything special in onInitialize().

User Defined properties require no special considerations when defining the class, but merely require being accessed by the getUserDefinedAttribute method.

And, again, there's no specific need to create a new node just to define or access User Defined Properties.
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 » Getting null while accessing UDP in JCN impl
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.