Author |
Message
|
digital17 |
Posted: Wed Sep 26, 2007 12:30 pm Post subject: Thread safety of a JavaComputeNode |
|
|
Newbie
Joined: 26 Sep 2007 Posts: 5
|
I have a Java compute node (extending from MbJavaComputeNode) coded the usual way by implementing the evaluate method. My question is how is the broker calling this node? Does it create a new instance of it everytime a message flows through this node? Or is it like a servlet that shouldnt have instance variables because there is only one instance of it shared across threads?
If this is like a servlet, are there methods I can implement in my own code in order to initiate initialization and cleanup of the class? I couldn't find the API documentation of MbJavaComputeNode in the toolkit or the online API javadoc.
Thanks. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Sep 26, 2007 1:03 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
It's not anything like a servlet.
JCN node lifecycle is complicated, and I don't feel like going into it right now. You can look at the InfoCenter documentation on the lifecycle of a Java User Defined Input node and make some inferences from that.
Do not assume that your node will be instantiated for every call to execute().
Do not assume that your node will only ever be instantiated once for the lifetime of a flow. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
digital17 |
Posted: Wed Sep 26, 2007 1:42 pm Post subject: |
|
|
Newbie
Joined: 26 Sep 2007 Posts: 5
|
I went to the information center to look at what you mentioned and saw the ondelete method.
Can I implement the onDelete method in my JavaComputeNode for cleanup before the node is destroyed? I need to free up resources like a socket connection. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Sep 26, 2007 1:52 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Are you trying to implement JDBC connection pooling? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
digital17 |
Posted: Wed Sep 26, 2007 2:00 pm Post subject: |
|
|
Newbie
Joined: 26 Sep 2007 Posts: 5
|
No. Just HTTP connections. Otherwise, I might have to change all of this and use jakarta's HTTPClient that does this already. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Sep 26, 2007 2:03 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
...
Why can't you use an HTTPRequest node?
Why do you need to leave an HTTP connection open across multiple invocations of a JavaCompute node? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
digital17 |
Posted: Wed Sep 26, 2007 2:10 pm Post subject: |
|
|
Newbie
Joined: 26 Sep 2007 Posts: 5
|
We are having problems with the HttpRequestNode and the headers of an old service that the HttpRequestNode doesn't handle. The vendor for that service is trying to fix that but other things need to be fixed as well. So this is an interim solution.
We want to do connection pooling for performance. This is a high volume app. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Sep 26, 2007 2:21 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Okay... That's much more reasonable than I'd feared.
I haven't tried using onDelete(). It should work, though.
You may want to rely on POJOs to handle all your connections/connection pools, though... and put the jar files for those in shared-classes.
Then you will have one pool for the entire EG, rather than one pool for each JCN instance.
I'm doing something similar with JDBC connection pooling using the Apache db-commons classes. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
digital17 |
Posted: Thu Sep 27, 2007 5:53 am Post subject: |
|
|
Newbie
Joined: 26 Sep 2007 Posts: 5
|
|
Back to top |
|
 |
|