Seam 中的异步方法总是返回 null QuartzTriggerHandle ?
Seam 中异步方法返回的 QuartzTriggerHandle 对象始终为“null”, 作业已启动,但无法取消或暂停。
在 Seam 论坛中,我找到了下一个应该可以工作的示例,但它对我不起作用。
@Name("quartzObserver")
public class SCSQuartzObserver {
@In(create = true)
SCSQuartzTask quartzTask;
@SuppressWarnings("unused")
@Observer("org.jboss.seam.postInitialization")
public void observe() {
try {
Calendar cal = Calendar.getInstance();
cal.set(2040, Calendar.MAY, 10);
QuartzTriggerHandle handle = quartzTask.performTask(new Date(),
86400000l);
handle.cancel();
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Name("quartzTask")
@AutoCreate
public class SCSQuartzTask {
@Asynchronous
public QuartzTriggerHandle performTask(@Expiration java.util.Date when,
@IntervalDuration long duration) {
// do stuff
QuartzTriggerHandle handle = new QuartzTriggerHandle("SCSQuartzTask");
return handle;
}
}
谢谢帮助。
QuartzTriggerHandle object that returned by Asynchronous method in Seam always 'null',
the job starts but cann't cancelled or paused.
In, seam forum i found the next example that should be work,but it doesn't work with me.
@Name("quartzObserver")
public class SCSQuartzObserver {
@In(create = true)
SCSQuartzTask quartzTask;
@SuppressWarnings("unused")
@Observer("org.jboss.seam.postInitialization")
public void observe() {
try {
Calendar cal = Calendar.getInstance();
cal.set(2040, Calendar.MAY, 10);
QuartzTriggerHandle handle = quartzTask.performTask(new Date(),
86400000l);
handle.cancel();
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Name("quartzTask")
@AutoCreate
public class SCSQuartzTask {
@Asynchronous
public QuartzTriggerHandle performTask(@Expiration java.util.Date when,
@IntervalDuration long duration) {
// do stuff
QuartzTriggerHandle handle = new QuartzTriggerHandle("SCSQuartzTask");
return handle;
}
}
thnx for help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不应该创建 QuartzTriggerHandle。只需在performTask方法体中完成你的工作,seam运行时就会注意返回QuartzTriggerHandle对象。像这样的事情:
QuartzTriggerHandle是可序列化的,您可以将其保存在数据库表中,以便稍后可以取消任务。
You shouldn't create the QuartzTriggerHandle. Just do your work in the body of the performTask method, seam runtime will take care to return the QuartzTriggerHandle object. Something like this:
The QuartzTriggerHandle is serializable, you can keep it in a database table so you can later cancel the task.
您好,您必须在 component.xml 中添加一些内容
http://jboss.com/products/seam /async
http://jboss.com/products/seam/async-2.2.xsd"
现在它可以工作了,
您可以找到示例 Melih sakarya 网站
http://www.melihsakarya.com/2011/09/seam-de-zamanli-isler-scheduling/
Hi You must add something in component.xml
http://jboss.com/products/seam/async
http://jboss.com/products/seam/async-2.2.xsd"
now it will work
you can find example Melih sakarya web site
http://www.melihsakarya.com/2011/09/seam-de-zamanli-isler-scheduling/