Grails - 石英

发布于 2024-09-18 05:08:26 字数 587 浏览 8 评论 0原文

我正在尝试使用 Grails 的 Quartz 插件来安排我正在开发的 Web 应用程序中的作业。使用 RAMstore 工作正常,但我需要将作业保留在我们的 SQLServer 数据库中,这导致了问题...

我已将 QuartzConfig.groovy 中的 jdbcStore 变量更改为 true,在 job 文件,并使用 SQLServer 代码在数据库中生成所需的表,但不断获取 错误:

org.quartz.impl.jdbcjobstore.LockException:获取数据库行锁失败:第 1 行:FOR UPDATE 子句仅允许用于 DECLARE CURSOR。 [请参阅嵌套异常:com.microsoft.sqlserver.jdbc.SQLServerException:第1行:FOR UPDATE子句仅允许用于DECLARE CURSOR。]

有一个想法,这可能与未为SQLServer数据库配置quartz插件有关, 但在网上还没有找到太多关于它的信息(主要是quartz的完整java实现而不是grails), 并且尝试配置文件并没有帮助。

有谁知道如何让它工作? grails 实际使用了哪些 Quartz 配置文件?

感谢您的帮助

I am trying to use the Quartz plugin for Grails to schedule a job in a web app I am working on. Using the
RAMstore worked fine, but I need the job to persist in our SQLServer database, which has caused problems...

I have changed the jdbcStore variable in QuartzConfig.groovy to true, set def volatility = false in the
job file, and used the SQLServer code to generate the required tables in the database, but keep getting
an error:

org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: Line 1: FOR UPDATE clause allowed only for DECLARE CURSOR. [See nested exception: com.microsoft.sqlserver.jdbc.SQLServerException: Line 1: FOR UPDATE clause allowed only for DECLARE CURSOR.]

Have an idea it might be something to do with the quartz plugin not being configured for a SQLServer database,
but haven't found much on the web about it(mostly the full java implementation of quartz rather than grails),
and experimenting with config files hasn't helped.

Does anyone know how to get this working? And which of the various Quartz config files grails actually uses?

Thanks for your help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

七秒鱼° 2024-09-25 05:08:26

我在几个项目中使用quartz:1.0.2。
我不会坚持我的工作,我为每项工作分配一个唯一的名称。
然后,我使用我创建的用于跟踪工作状态的域来保留我的工作状态。

例如,我的作业的执行部分使用 jobName 查找其状态跟踪域,这是我从每个作业的属性文件中加载的唯一值。
然后,我将与该作业关联的 FileImporter 实例传递给执行该作业的所有条件状态的服务。

        FileImporter fileImporter1 = FileImporter.findByName(jobName);
        fileImporterService.importWhileEnabled(fileImporter1);

我的服务不是事务性的,因为我希望立即保留作业的状态。这样,如果我重新启动应用程序,作业的最后状态就已知,并且我可以从它停止的位置继续。
但是,我通常只是重置作业状态,使其在 Web 服务器重新启动后再次从头开始。

在我的服务中,我

static transactional = false

立即使用flush: true并保持状态

fileImporter.save(failOnError: true, flush: true);

I use quartz:1.0.2 in several projects.
I don't persist my jobs, I assign each job a unique name.
Then I persist the state of my job with a domain I make to track the state of the job.

example, the execute section of my job finds its state tracking domain using jobName, which is a unique value I load from a properties files for each of my jobs.
Then I pass the FileImporter instance associated with this job to my service that executes all the conditional states of the job.

        FileImporter fileImporter1 = FileImporter.findByName(jobName);
        fileImporterService.importWhileEnabled(fileImporter1);

My service is not transactional, because I want the state of the job to be persisted immediately. That way, if I restart my app, the last state of the job is known, and I can continue from the point it left off.
However, I usually just reset the job state to make it start from the beginning again after a restart of the web server.

In my service I use

static transactional = false

and persist the state immediately with flush: true

fileImporter.save(failOnError: true, flush: true);
锦欢 2024-09-25 05:08:26

尝试在quartz.properties文件org.quartz.jobStore.selectWithLockSQL=SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?中添加此属性。

try adding this property in the quartz.properties file org.quartz.jobStore.selectWithLockSQL=SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文