• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Background process in EJB Architecture?

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Saloon Keeper
Posts: 28316
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?

Dave Van Even
 
He's giving us the slip! Quick! Grab this tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic