Hi All,
When calling another bean from a bean how to implement a timeout? Suppose
Bean A is calling a method on Bean B. But Bean B is taking too much time to process the request, so I want to timeout the method. (I am using Weblogic5.1) .
( I have tried to use container managed transaction. And when I have set the value of trans-timeout-seconds in weblogic-ejb-jar.xml - I have got a message that transaction has been rolled backed because of timeout - but my control hasn't returned to Bean A. After the Bean B 's method is completed then only I have got the control back. But I want control to be returned to me immediately after timeout).
Waiting for your reply...
Thanks
Srijeeb.
-
How to implement a timeout ? (6 messages)
- Posted by: Srijeeb Roy
- Posted on: December 17 2001 21:35 EST
Threaded Messages (6)
- How to implement a timeout ? by Srijeeb Roy on December 17 2001 21:39 EST
- How to implement a timeout ? by David Hanna on December 17 2001 23:04 EST
- How to implement a timeout ? by Srijeeb Roy on December 18 2001 11:11 EST
- How to implement a timeout ? by David Hanna on December 17 2001 23:04 EST
- How to implement a timeout ? by Pranab Ghosh on December 18 2001 15:46 EST
- How to implement a timeout ? by Srijeeb Roy on December 18 2001 16:39 EST
- How to implement a timeout ? by Pranab Ghosh on December 19 2001 04:48 EST
- How to implement a timeout ? by Srijeeb Roy on December 18 2001 16:39 EST
-
How to implement a timeout ?[ Go to top ]
- Posted by: Srijeeb Roy
- Posted on: December 17 2001 21:39 EST
- in response to Srijeeb Roy
FYI
Bean A and Bean B both are stateless session Bean.
-Thanks
Srijeeb. -
How to implement a timeout ?[ Go to top ]
- Posted by: David Hanna
- Posted on: December 17 2001 23:04 EST
- in response to Srijeeb Roy
One solution I did a while ago was to implement a helper class, called by Bean A, that spawns a thread to implement the second call. The helper class can then wait the specified timeout period. This was implemented on WL 4.51. -
How to implement a timeout ?[ Go to top ]
- Posted by: Srijeeb Roy
- Posted on: December 18 2001 11:11 EST
- in response to David Hanna
Hi David,
Thanks for your sol.I have also thought about that solution. But Weblogic recommends (basically J2EE spec ) not to spawn external threads from Beans. If I use Helper class - then also the Thread (external thread created by programmer)will be spawned from the same process.
-Thanks
Srijeeb. -
How to implement a timeout ?[ Go to top ]
- Posted by: Pranab Ghosh
- Posted on: December 18 2001 15:46 EST
- in response to Srijeeb Roy
If your bussiness logic allows it, you could set the transaction attribute of bean B to "requires new". That way, only the transaction for bean B will be rolled back when timeout happens and the control will return to the calling bean A which is outside the transaction scope of bean B.
Pranab -
How to implement a timeout ?[ Go to top ]
- Posted by: Srijeeb Roy
- Posted on: December 18 2001 16:39 EST
- in response to Pranab Ghosh
Hi Pranab,
My Bean A is not in any transaction. Currently the transaction attribute of the method of Bean B is set to "Required".So, if I set the transaction attribute of the method of Bean B as "RequiresNew" , I think the effect will be same. Because if the Client is not in Transaction the effect of "Required" and "RequiresNew" are same. Do I need to put the caller method (of Bean A) also in Transaction? But my Caller method (of Bean A) doesn't need any transaction according to Business needs.
Thanks
Srijeeb. -
How to implement a timeout ?[ Go to top ]
- Posted by: Pranab Ghosh
- Posted on: December 19 2001 16:48 EST
- in response to Srijeeb Roy
Srijeeb,
You are right. However, it seems like your bean A method is spawning a transaction. What is transaction attribute of your bean A method set to any way? If it's not set to anything, by default the container might be starting a tranaction. I am not sure what the ejb spec says about the default transaction behaviour.
Pranab