如何取消或删除 Persistent EJBTimers
How to cancel or remove Persistent EJBTimers
当我们使用带@schedule 和persistent=true 的persistent EJBTimer 时,将其部署到集群,然后我们更改@Schedule 中的实际调度并重新部署到集群,原始调度是否被新调度替换(删除并添加了新参数),或者两个计划都保持活动状态(记住 persistent=true 已设置)
这是我目前读到的内容 - Each scheduler instance has a unique jndi name and @schedule automatically creates a timer through application deployment so it would be better to remove the automatic created EJBTimer or cancel the original schedule to avoid trouble.
但我不知道如何以编程方式取消原始计划,或者如果原始计划和更改后的计划都需要由 websphere 管理员完成时间表保持活跃
同样来自 this document,removeAutomaticEJBTimers 命令用于从指定的调度程序中删除计时器,但这似乎也是在 websphere 管理员而不是开发人员的范围内。
开发人员如何以编程方式取消使用@Schedule 注释创建的自动 EJBTimer?
我正在使用 Java EE 6 与 Websphere 8.5 和 EJB 3.1。
查看此页面Creating timers using the EJB timer service
The application server automatically removes persistent automatic
timers from the database when you uninstall the application while the
server is running. If the application server is not running, you must
manually delete the automatic timers from the database. Additionally,
if you add, remove, or change the metadata for automatic timers while
the server is not running, you must manually delete the automatic
timers.
我有以下 class:
@Stateless
@LocalBean
public class HelloBean {
@Schedule(persistent=true, minute="*", hour="*", info="myTimer")
public void printHello() {
System.out.println("### hello");
}
}
安装到服务器后,可以找到相关的自动定时器:
C:\IBM\WebSphere\AppServer85\profiles\AppSrv02\bin>findEJBTimers.bat server1 -al l
ADMU0116I: Tool information is being logged in file C:\IBM\WebSphere\AppServer85\profiles\AppSrv02\logs\server1\EJBTimers.log
ADMU0128I: Starting tool with the AppSrv02 profile
ADMU3100I: Reading configuration for server: server1
EJB timer : 3 Expiration: 2/14/15 12:39 PM Calendar
EJB : ScheduleTestEAR, ScheduleTest.jar, HelloBean
Info : myTimer
Automatic timer with timout method: printHello
Calendar expression: [start=null, end=null, timezone=null, seconds="0",
minutes="*", hours="*", dayOfMonth="*", month="*", dayOfWeek="*", year="*"]
1 EJB timer tasks found
卸载应用后,定时器被移除:
C:\IBM\WebSphere\AppServer85\profiles\AppSrv02\bin>findEJBTimers.bat server1 -al l
ADMU0116I: Tool information is being logged in file
C:\IBM\WebSphere\AppServer85\profiles\AppSrv02\logs\server1\EJBTimers.log
ADMU0128I: Starting tool with the AppSrv02 profile
ADMU3100I: Reading configuration for server: server1
0 EJB timer tasks found
我不知道您 'redeploying' 您的申请情况如何,但看起来您的流程不正确。与正常情况一样 install/uninstall/update 进程自动计时器已正确删除。
更新
在同一页面上,您有关于 ND 环境的信息:
Automatic persistent timers are removed from their persistent store
when their containing module or application is uninstalled. Therefore,
do not update applications that use automatic persistent timers with
the Rollout Update feature. Doing so uninstalls and reinstalls the
application while the cluster is still operational, which might cause
failure in the following cases:
If a timer running in another cluster member activates after the database entry is removed and before the database entry is recreated,
then the timer fails. In this case, a
com.ibm.websphere.scheduler.TaskPending exception is written to the
First Failure Data Capture (FFDC), along with the SCHD0057W message,
indicating that the task information in the database has been changed
or canceled.
If the timer activates on a cluster member that has not been updated after the timer data in the database has been updated, then
the timer might fail or cause other failures if the new timer
information is not compatible with the old application code still
running in the cluster member.
执行以下操作以删除持久化的 EJB 计时器:
删除目录jboss-home\standalone\data\timer-service-data{yourporjectname}.{serivename}
在 JBoss/WildFly 中,如果您将 timer-service 更改为使用 "clustered-store" 而不是 "default-file-store",您将能够以编程方式取消计时器。这里有一个简短的指南,解释了如何制作它:
Mastertheboss.com: Creating clustered EJB 3 Timers
Published: 08 March 2015
http://www.mastertheboss.com/jboss-server/wildfly-8/creating-clustered-ejb-3-timers
当我们使用带@schedule 和persistent=true 的persistent EJBTimer 时,将其部署到集群,然后我们更改@Schedule 中的实际调度并重新部署到集群,原始调度是否被新调度替换(删除并添加了新参数),或者两个计划都保持活动状态(记住 persistent=true 已设置)
这是我目前读到的内容 - Each scheduler instance has a unique jndi name and @schedule automatically creates a timer through application deployment so it would be better to remove the automatic created EJBTimer or cancel the original schedule to avoid trouble.
但我不知道如何以编程方式取消原始计划,或者如果原始计划和更改后的计划都需要由 websphere 管理员完成时间表保持活跃
同样来自 this document,removeAutomaticEJBTimers 命令用于从指定的调度程序中删除计时器,但这似乎也是在 websphere 管理员而不是开发人员的范围内。
开发人员如何以编程方式取消使用@Schedule 注释创建的自动 EJBTimer?
我正在使用 Java EE 6 与 Websphere 8.5 和 EJB 3.1。
查看此页面Creating timers using the EJB timer service
The application server automatically removes persistent automatic timers from the database when you uninstall the application while the server is running. If the application server is not running, you must manually delete the automatic timers from the database. Additionally, if you add, remove, or change the metadata for automatic timers while the server is not running, you must manually delete the automatic timers.
我有以下 class:
@Stateless
@LocalBean
public class HelloBean {
@Schedule(persistent=true, minute="*", hour="*", info="myTimer")
public void printHello() {
System.out.println("### hello");
}
}
安装到服务器后,可以找到相关的自动定时器:
C:\IBM\WebSphere\AppServer85\profiles\AppSrv02\bin>findEJBTimers.bat server1 -al l
ADMU0116I: Tool information is being logged in file C:\IBM\WebSphere\AppServer85\profiles\AppSrv02\logs\server1\EJBTimers.log
ADMU0128I: Starting tool with the AppSrv02 profile
ADMU3100I: Reading configuration for server: server1
EJB timer : 3 Expiration: 2/14/15 12:39 PM Calendar
EJB : ScheduleTestEAR, ScheduleTest.jar, HelloBean
Info : myTimer
Automatic timer with timout method: printHello
Calendar expression: [start=null, end=null, timezone=null, seconds="0",
minutes="*", hours="*", dayOfMonth="*", month="*", dayOfWeek="*", year="*"]
1 EJB timer tasks found
卸载应用后,定时器被移除:
C:\IBM\WebSphere\AppServer85\profiles\AppSrv02\bin>findEJBTimers.bat server1 -al l
ADMU0116I: Tool information is being logged in file
C:\IBM\WebSphere\AppServer85\profiles\AppSrv02\logs\server1\EJBTimers.log
ADMU0128I: Starting tool with the AppSrv02 profile
ADMU3100I: Reading configuration for server: server1
0 EJB timer tasks found
我不知道您 'redeploying' 您的申请情况如何,但看起来您的流程不正确。与正常情况一样 install/uninstall/update 进程自动计时器已正确删除。
更新
在同一页面上,您有关于 ND 环境的信息:
Automatic persistent timers are removed from their persistent store when their containing module or application is uninstalled. Therefore, do not update applications that use automatic persistent timers with the Rollout Update feature. Doing so uninstalls and reinstalls the application while the cluster is still operational, which might cause failure in the following cases:
If a timer running in another cluster member activates after the database entry is removed and before the database entry is recreated, then the timer fails. In this case, a com.ibm.websphere.scheduler.TaskPending exception is written to the First Failure Data Capture (FFDC), along with the SCHD0057W message, indicating that the task information in the database has been changed or canceled.
If the timer activates on a cluster member that has not been updated after the timer data in the database has been updated, then the timer might fail or cause other failures if the new timer information is not compatible with the old application code still running in the cluster member.
执行以下操作以删除持久化的 EJB 计时器:
删除目录jboss-home\standalone\data\timer-service-data{yourporjectname}.{serivename}
在 JBoss/WildFly 中,如果您将 timer-service 更改为使用 "clustered-store" 而不是 "default-file-store",您将能够以编程方式取消计时器。这里有一个简短的指南,解释了如何制作它:
Mastertheboss.com: Creating clustered EJB 3 Timers
Published: 08 March 2015
http://www.mastertheboss.com/jboss-server/wildfly-8/creating-clustered-ejb-3-timers