Hi, I'd like to run a background process in my company's ejb architecture to update entity beans periodically. For example, I'd like to update an entity bean with any new database table rows once every 10 minutes. I've read that bean-managed threads are not supported in EJB, so how can I do this? Thanks, Andy
Write a client application to touch the EJBs. One way to do that is to write a "null" servlet - one that does all its work in the init() method instead of doGet/doPost. Let init() spawn a thread that wakes up every 5 minutes, reads the rows of interest, and then updates the EJBs. CAUTION: If the EJBs are being updated by other sources as well, you'll have to work out a conflict resolution scheme. Otherwise you'll end up undoing changes!
Customer surveys are for companies who didn't pay proper attention to begin with.
Dave Van Even
Joined: Jul 19, 2001
Here's an article ( http://www.theserverside.com/resources/article.jsp?l=MonsonHaefel-Column1 ) about the first public draft of the Enterprise JavaBeans 2.1 specification and look what we've got there Timer Service -------------------------- The Time Service is a scheduling system that is built into the EJB container. A stateless session or entity bean can register itself with the Timer Service, and request notification at a particular point in time or when a specified period of time has elapsed. The Timer Service uses a fairly simple programming model. The stateless or entity bean must implement the TimedObject interface.
When the bean's timer goes off, the container will call its ejbTimeout() method. You can put any kind of business logic you like in ejbTimeout(). For example, an entity bean that represents an invoice might have a timer that activates after 45 days. When the timer goes off, the container calls the ejbTimeout() method. The Invoice entity bean might then send a JMS message to alert an accounts-receivable application that payment is overdue, or send the customer an e-mail requesting payment. Dunno how long it will take till we can actually use this ? Anyone ?