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 » Java Plugin Node Initialization and Destruction problem

Post new topic  Reply to topic
 Java Plugin Node Initialization and Destruction problem « View previous topic :: View next topic » 
Author Message
Irena
PostPosted: Tue Feb 26, 2002 1:32 am    Post subject: Reply with quote

Novice

Joined: 03 Feb 2002
Posts: 11
Location: IBM

My Java plugin node uses resources which have to be appropriately initialized & released.
Since its super class MbNode and its interface MbNodeInterface do not have sort of "createNodeContext" & "deleteNodeContext" methods (like in C nodes), I do not know what is the right place to create & delete the stuff.
Currently, I make resource initialization only in the first "evaluate" call, which creates serious performance & logical problems.
I can not initialize resources in the node constructor since the node attributes are unavailable at that moment.
The only methods called between constructor & "evaluate" - are the attributes' set methods.
The resource destruction problem is even worse because there is no place to know that a node is not in use anymore until the next call of node constructor.

Did anybody come across the same problems ? Any ideas ?
Thank you,
Irena.
Back to top
View user's profile Send private message Send e-mail
mpuetz
PostPosted: Wed Feb 27, 2002 5:45 am    Post subject: Reply with quote

Centurion

Joined: 05 Jul 2001
Posts: 149
Location: IBM/Central WebSphere Services

Hi Irena,

you would do allocation of resources in your Node contructor.
If you need to clean up resources which are not handled entirely
in your JVM (i.e. other pure Java objects) you have to override the
finalize() method of your Node.
Note, there are some implicitations to this, since Java uses
garbage collection which cleans up unused objects. Only when
the garbage collection is done will the finalize() method be
called and your other resources be cleaned up. To my knowledge
there is no documented way of influencing the scheduling of the MQSI JVM
garbage collection.
I don't know if MQSI forces the JVM to garbage collect at flow destruction
time (e.g. after a re-deploy).


_________________
Mathias Puetz

IBM/Central WebSphere Services
WebSphere Business Integration Specialist
Back to top
View user's profile Send private message
Irena
PostPosted: Wed Feb 27, 2002 10:49 pm    Post subject: Reply with quote

Novice

Joined: 03 Feb 2002
Posts: 11
Location: IBM

Hello Mathias,

thank you.
The problem with the node constructor is that neither node properties, nor node context are available at the moment of call to constructor. But I need both these things to properly initialize resources.
I think that Java plugin interface needs createNodeContext & deleteNodeContext methods like C plugins have.
Back to top
View user's profile Send private message Send e-mail
kolban
PostPosted: Thu Feb 28, 2002 4:45 pm    Post subject: Reply with quote

Grand Master

Joined: 22 May 2001
Posts: 1072
Location: Fort Worth, TX, USA

Ah ... but the node context is the instance of your Java MbNode object. There is no need for an explicit chunk-o-data to hold your state as the state of your object will be the state for this logical instance of the node. If you create instance variables, these will be visible only to the instance of the node in the message flow.

As for the node properties ... these were never available in the C plugins at CreateNodeContext time. I suggest that you register a callback for each of your properties arriving from customization on your Control Center and when all the properties have been supplied, you then do your initialization.

So ... the path would be:

- node instance is created ... do as much initialization you can in your classe's constructor
- as properties are set (which will happen before the first evaluate() call, perform initialization based on the incoming properties ...

Back to top
View user's profile Send private message
Irena
PostPosted: Fri Mar 01, 2002 6:21 am    Post subject: Reply with quote

Novice

Joined: 03 Feb 2002
Posts: 11
Location: IBM

Hello & thanks.
Yes, I also thought about the possibility to initialize resources upon the last call, setting the properties.
However, logically it seems somehow strange to make heavy node initialization either in a setProperty or in an evaluate methods, but I understand that there is no choice currently.
Regarding resource release, did I understand correct that there is no guarantee that the finalize method will be called before creation of a new node instance (after re-deploy) ?
Thanks a lot.
Irena.
Back to top
View user's profile Send private message Send e-mail
marko
PostPosted: Fri Mar 01, 2002 8:30 am    Post subject: Reply with quote

Apprentice

Joined: 28 Feb 2002
Posts: 27

I have been dealing with the same issue. I posted the following question to IBM's mqintegrator newsgroup, and I received a reply pointing to this thread.

As for finalization, I have never been able to have a finizler be called - even if I call Runtime.runFinalizersOnExit(true). This is with testing on Win2k and HPUX.

Thanks for your help.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
I have some static resources in a custom Java plugin node that I would like to
release before the execution group (or Broker) is stopped. Is there any way
of doing this? I have not been able to find any callback that is part of
the plugin API? I also tried to used Java finalizers with no luck (they are
not reliable any way). I also tried to use the Java (jre 1.3+) "shutdown
hook". Unfortunately, shutdown hooks do not seem to be working within the
WMQI environment (tried under win2k or HPUX)?

Marko.
.

Back to top
View user's profile Send private message
kolban
PostPosted: Fri Mar 01, 2002 9:06 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2001
Posts: 1072
Location: Fort Worth, TX, USA

To the best of my knowledge, there is no explicit way to acheive this in the Java node interfaces. I agree, that this seems to be a deficiency.
Back to top
View user's profile Send private message
Irena
PostPosted: Sun Mar 10, 2002 12:15 am    Post subject: Reply with quote

Novice

Joined: 03 Feb 2002
Posts: 11
Location: IBM

So, to resume the discussion, the best current solution is:

Do resource initialization either in the node constructor (if it does not depend on the node properties) or upon the last call to the node set method. Carefully check that the stuff still works after any change in the node configuration (properties).

Resource release may be done in the node finalizer (however there is no guarantee that the finalizer will be called or probably (in some cases) in the node constructor (before new initialization check whether resources are already allocated)

Irena.
Back to top
View user's profile Send private message Send e-mail
kolban
PostPosted: Sun Mar 10, 2002 7:01 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2001
Posts: 1072
Location: Fort Worth, TX, USA

Apparently, IBM development snuck in an onDelete() method on the MbNode class. If you implement this, it will be called when the node is deleted. In this method you can release/cleanup whatever you need.
Back to top
View user's profile Send private message
Irena
PostPosted: Sun Mar 10, 2002 8:01 am    Post subject: Reply with quote

Novice

Joined: 03 Feb 2002
Posts: 11
Location: IBM

I do not see onDelete method in either MbNode or MbNodeInterface, could you please specify where is it defined ?
Thank you.
Back to top
View user's profile Send private message Send e-mail
shines
PostPosted: Thu Mar 14, 2002 5:39 am    Post subject: Reply with quote

Newbie

Joined: 13 Mar 2002
Posts: 1
Location: Florida

The onDelete method is on MbInputNodeInterface not MbNodeInterface
Back to top
View user's profile Send private message Send e-mail Visit poster's website
shcherb
PostPosted: Mon Mar 18, 2002 4:41 am    Post subject: Reply with quote

Apprentice

Joined: 12 Sep 2001
Posts: 34

Hi,

We are working with WMQI 2.1 CSD 1 on WinNT Server SP6a and failed to find this method in any Mb* class. We searched javadoc, decompile class files, etc.
Are we talking about the same product ?
Vladimir
Back to top
View user's profile Send private message Send e-mail
kolban
PostPosted: Mon Mar 18, 2002 5:54 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2001
Posts: 1072
Location: Fort Worth, TX, USA

In your MbNode() extended class, code a public void onDelete() method. It had better be called when the node ends
Back to top
View user's profile Send private message
marko
PostPosted: Thu Sep 26, 2002 12:57 pm    Post subject: Reply with quote

Apprentice

Joined: 28 Feb 2002
Posts: 27

Vladimir, I think onDelete was added in CSD 2 or 3.
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 » Java Plugin Node Initialization and Destruction problem
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.