This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes EJB and Thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB and Thread " Watch "EJB and Thread " New topic

EJB and Thread

Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
as we know, EJB not support Thread. But now, I need to check up the database table each 10 seconds in EJB.
in the j2se, it is easy, like this
for(; {
of course, we can use a client to activate a session bean to do this each 10 seconds. but this is not a good design. in EJB, how we can do this inside the server?
Ajith Kallambella

Joined: Mar 17, 2000
Posts: 5782
Use a Timer Service to invoke a DB-checking process.

Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1066
Originally posted by Ajith Kallambella:
Use a Timer Service to invoke a DB-checking process.

I believe Timer Service Beans are EJB2.1. Any ideas how to do this with EJB2.0. I am just curious if we can introduce a waiting time for a recurrent task inside a bean class.
Kyle Brown
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
Don't do it in the EJB server. Invoke the EJB call to check the database either from a thread either running in the Web Container, or from a chron job that starts up an external EJB client process to do it for you.

Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at for other WebSphere information.
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1066
thanks Kyle.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: EJB and Thread
It's not a secret anymore!