使用 Quartz 插件在后台运行任务
我计划有一个显示按钮的视图,这样当单击它时,它将运行 Quartz 作业,并且页面将成功完成加载(无需等待作业完成)。根据此文档,您可以拥有自定义触发器类。你能帮我实现它吗?
我的工作:
class ReconciliationJob {
static triggers = {
custom name:'customTrigger', triggerClass:ReconciliationTrigger, targetDate:myValue
}
def execute() {
// execute task
}
}
如何实现 ReconciliationTrigger 类?另外,我还需要向作业传递一个参数。
谢谢。
I'm planning to have a view that presents a button so that when it is clicked, it will run a Quartz job and the page will finish loading successfully (no need to wait for the job to finish). Based on this documentation, you can have a custom trigger class. Can you help me implementing it?
My job:
class ReconciliationJob {
static triggers = {
custom name:'customTrigger', triggerClass:ReconciliationTrigger, targetDate:myValue
}
def execute() {
// execute task
}
}
How can I implement ReconciliationTrigger class? Also, I need to pass a parameter to the job too.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你混淆了工作和队列。
Quartz 作业是在基于时间的触发器上运行的后台任务,并非设计为由用户驱动的事件启动。
队列(例如 JMS)允许您以您所描述的方式发送异步“消息”(方法调用)。查看 Grails JMS 插件,它可能就是您正在寻找的东西。
I think you've mixed up jobs and queues.
Quartz jobs are background tasks which run on a time-based trigger and are not designed to be kicked off by user-driven events.
Queues, such as JMS, allow you to send an asynchronous 'message' (method call) in the manner you describe. Take a look at the Grails JMS plugin and it might be what you're looking for.