aspose file tools
The moose likes EJB and other Java EE Technologies and the fly likes How to 'sleep' in an EJB? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply Bookmark "How to Watch "How to New topic
Author

How to 'sleep' in an EJB?

Max Tomlinson
Ranch Hand

Joined: Jul 17, 2001
Posts: 364
Hi all-
I have a Session facade calling a CMP entity bean and I want to implement retry logic which will wait for a certain amount of time before the retry. How can I do this using J2EE 1.3 since threads are not permitted? I've thought of doing some I/O intensive processing before the retry to force a delay but this seems like a hack.
Any ideas?
thanks!
Max Tomlinson
Howard Kushner
author
Ranch Hand

Joined: Sep 19, 2003
Posts: 361
Originally posted by Max Tomlinson:

Any ideas?


Hey Max,
My suggestion is don't do that in a session bean. Help me understand the motivation behind your desire to "tie up" a session bean that could be otherwise working more efficiently in a pool managed by its container (improving scalability), unless said bean is stateful.
IMHO, timing issues are best handled using other strategies.
With session beans you have transactional components, and that is a good thing. I guess what I'm asking is this: if you are waiting for something, what seems to be the hold-up? Database access? Something else?
Trying to be of some help...
Regards,


Howard Kushner<br />IBM Certified Enterprise Developer - WebSphere Studio Application Developer V5.0<br />IBM Certified Advanced System Administrator - WebSphere Application Server V5.0<br />IBM Certified Solution Developer - Web Services with WebSphere Studio V5.1<br /><a href="http://www.amazon.com/exec/obidos/tg/detail/-/1931182108/" target="_blank" rel="nofollow">Developing J2EE Applications with WebSphere Studio</a> my Certification Study Guide for IBM Test 287
Max Tomlinson
Ranch Hand

Joined: Jul 17, 2001
Posts: 364
Hey Howard-
Thanks for the response.
What I'm trying to do is retry if a DB item is not available. The DB items are user logon pool items (analagous to DB connections) and if one is not available (i.e. they are all tied up) then we want to retry before sending an error back to the client program. I'd like to delay for, say, 1 second and do the retry.
What other logic do you recommend?
thanks,
Max
Howard Kushner
author
Ranch Hand

Joined: Sep 19, 2003
Posts: 361
I see...
I would probably have the retry logic in the client, but the actually user need not be aware. It may cost a bit more in terms of network overhead, but that is pure speculation on my part, as I do not know who is the client to the EJB. Is it a servlet or a fat client?
Hope this helps.
Max Tomlinson
Ranch Hand

Joined: Jul 17, 2001
Posts: 364
Hi Howard-
The client is actually another EJB in the business logic layer. This user Session facade is actually a local EJB calling a Local CMP. It's really just a service that returns a host pool item to the business layer. I know what you mean about having the client do the retry but we want to encapsulate that as much as possible. We want to put the retry logic in the session bean to make it an easy-to-use service.
Max
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to 'sleep' in an EJB?
 
Similar Threads
Thin Driver for JDBC 2.0
MDB retry interval period
Apache HttpClient - Retry-After header
identifying the retry request
GZIP deflating response from server failure help!