EJB Timer when redepolyed in a cluster environemen

2019-07-19 05:22发布

问题:

I have an .ear file which is composed of multiple EJB's and one of them do use a timer service to create timer and the same ejb has the callback method too. That ear is supposed to be deployed in a clustered environment of 3 servers. The issue now is that i want to know what is the expected behavior if i redeployed/undeployed the ear in the cluster. Will the server cancel all timers and clear the persistent scheduler? Or it will preserve them? What are the work arounds?

I have read that in IBM web link: http://pic.dhe.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=%2Fcom.ibm.websphere.base.doc%2Finfo%2Faes%2Fae%2Frejb_timerservice.html

Currently i don't have the capability to create an environment to test such case and take a confident decision, i wonder if anyone faced such issue before, as this is a very critical issue for me

Thanks

回答1:

EJB timers are not removed when the application is removed. Some options:

  1. Use the WAS_HOME/bin/cancelEJBTimers command to remove them
  2. Add startup logic to your application to cancel/recreate timers as needed.
  3. Use automatic timers (@Schedule) in 8.0+. In this case, the server automatically creates the timer when the application is first started, and it will attempt to remove them when the application is uninstalled. See the InfoCenter for more information:
    • Creating timers using the EJB timer service for enterprise beans
    • removeAutomaticEJBTimers