wood burning stoves 2.0*
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: 1064
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 http://www.kyle-brown.com/ for other WebSphere information.
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1064
thanks Kyle.
I agree. Here's the link: http://aspose.com/file-tools
subject: EJB and Thread
Similar Threads
Running a quote in threads.
Server Time-out
Executing an EJB on a separate thread
Doubt in JTWI 1.0 Specification
Where is the Context Switch Effect in Java?