从 JSF(任何前端)触发 Quartz 作业 - 如何等待作业执行结束
我正在开发一个前端来动态触发石英作业。 我在 JSF 页面中有一个表单,其单击操作将动态触发石英作业。
该作业由以下语句调用,该作业被触发并且一切正常。
scheduler.triggerJob("Job1",Scheduler.DEFAULT_GROUP,jobDataMap);
据我了解,该作业似乎在单独的线程中运行,并且调用函数的执行不会等待作业结束。
由于我是从前端调用该作业,因此我想等到该作业结束后再导航到另一个 JSF 页面。因此,如果作业失败,我可以显示错误消息。 我还想向用户显示一条消息,“正在处理作业,请稍候..”,直到作业实际结束。
任何有关如何实现这一目标的想法将不胜感激。
谢谢 !
I am developing a front end to trigger a quartz job on the fly.
I have a form in the JSF page whose click action will dynamically trigger a quartz job.
The job is invoked by the following statement, the job is triggered and everything works fine.
scheduler.triggerJob("Job1",Scheduler.DEFAULT_GROUP,jobDataMap);
From what I understand the job seems to run in a separate thread and the execution of the calling function does not wait for the job to be over.
Since I am invoking the job from front end, I would like to wait till the job is over before I navigate to a different JSF page. So I can display an error message if the job fails.
I would also like to display a message to the user, "Processing job, please wait.." until the job is actually over.
Any ideas on how to accomplish this will be appreciated.
Thanks !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以注册一个 触发器/作业监听器,以便在 Quartz 作业发生时收到通知已完成。
我不太确定如何在 JSF 中将异步更新返回给用户。我希望一个好的解决方案取决于您的应用程序架构、JSF 的版本,甚至可能取决于您可用的库支持。不过,对我来说,这听起来确实像是您将其公开为可轮询服务并使用 AJAX 更新的组件。
You can register a Trigger/Job Listener to be notified when a Quartz job has completed.
How you would get that asynchronous update back to the user in JSF, I'm not so sure. I would expect a good solution to depend on your application architecture, the version of JSF, and maybe even the library support you have available. It does sound like the kind of thing you'd expose as a pollable service and use an AJAX-updated component to me, though.