• 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Doubt on TimerService API

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

Can we use timer service in StatefulSession bean? And for every scheduled task for timerservice , do client need to invoke the method? If yes then how will it work if scheduled time has come for particular task and client has not invoked the particular method?

Kindly explain this.
 
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Timers can only be used from SLSB or MDB's, not from SFSB. This makes sense if you think about it; both SLSB and MDB have stateless behaviour. If you would make a timer that calls back within 2 days, it will just fire up a method ready instance from the SLSB pool, it doesn't matter which one since there is no state retention anyways.

If you would be allowed to do this on a SFSB, chances are (very) high that the SFSB in questions (the instance from which you created the timer callback) has already been removed, so the state is already gone. Point is that you cannot count on the state of the given SFSB being there when the timeout has expires, therefore (and probably for other reasons as well) you cannot create a timer callback from a SFSB.

For your second part; yes, you must invoke the timer service method for each callback you want to make. You SLSB can at most have one 'timeout' method that will be called by the timer server once the timeout expires. If you register multiple timers for the same bean, the timeout method will be invoked multiple times.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic