• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to 'sleep' in an EJB?  RSS feed

 
Max Tomlinson
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Max Tomlinson
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!