• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB and Thread

 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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(; {
Thread.sleep(10000);
checkupDatabase();
}
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?
Thanks.
Edward
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a Timer Service to invoke a DB-checking process.
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Kyle.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic