Author |
Message
|
Irena |
Posted: Tue Feb 26, 2002 1:32 am Post subject: |
|
|
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 |
|
 |
mpuetz |
Posted: Wed Feb 27, 2002 5:45 am Post subject: |
|
|
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 |
|
 |
Irena |
Posted: Wed Feb 27, 2002 10:49 pm Post subject: |
|
|
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 |
|
 |
kolban |
Posted: Thu Feb 28, 2002 4:45 pm Post subject: |
|
|
 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 |
|
 |
Irena |
Posted: Fri Mar 01, 2002 6:21 am Post subject: |
|
|
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 |
|
 |
marko |
Posted: Fri Mar 01, 2002 8:30 am Post subject: |
|
|
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 |
|
 |
kolban |
Posted: Fri Mar 01, 2002 9:06 am Post subject: |
|
|
 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 |
|
 |
Irena |
Posted: Sun Mar 10, 2002 12:15 am Post subject: |
|
|
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 |
|
 |
kolban |
Posted: Sun Mar 10, 2002 7:01 am Post subject: |
|
|
 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 |
|
 |
Irena |
Posted: Sun Mar 10, 2002 8:01 am Post subject: |
|
|
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 |
|
 |
shines |
Posted: Thu Mar 14, 2002 5:39 am Post subject: |
|
|
Newbie
Joined: 13 Mar 2002 Posts: 1 Location: Florida
|
The onDelete method is on MbInputNodeInterface not MbNodeInterface |
|
Back to top |
|
 |
shcherb |
Posted: Mon Mar 18, 2002 4:41 am Post subject: |
|
|
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 |
|
 |
kolban |
Posted: Mon Mar 18, 2002 5:54 am Post subject: |
|
|
 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 |
|
 |
marko |
Posted: Thu Sep 26, 2002 12:57 pm Post subject: |
|
|
Apprentice
Joined: 28 Feb 2002 Posts: 27
|
Vladimir, I think onDelete was added in CSD 2 or 3. |
|
Back to top |
|
 |
|