[英]Configuring Quartz.NET with SQL Server AdoJobStore
I am having trouble trying to get Quartz.NET to work with an AdoJobStore. 我在尝试让Quartz.NET与AdoJobStore一起工作时遇到了麻烦。 None of the other questions here seem to be running into the problem that I am.
这里没有其他问题似乎遇到了我的问题。 I was able to get it working fine without the AdoJobStore configuration but would like to persist everything in the end, however I am getting an error when trying to
GetScheduler()
that I can't figure out. 我能够在没有AdoJobStore配置的情况下使其工作正常,但是最终会保留所有内容,但是在尝试
GetScheduler()
时我得到了一个我无法弄清楚的错误。
Here's my quartz app.config
section: 这是我的quartz
app.config
部分:
<quartz>
<add key="quartz.scheduler.instanceName" value="XxxDefaultQuartzScheduler"/>
<add key="quartz.scheduler.instanceId" value="instance_one"/>
<add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz"/>
<add key="quartz.threadPool.threadCount" value="10"/>
<add key="quartz.threadPool.threadPriority" value="1"/>
<add key="quartz.jobStore.type" value="Quartz.Impl.AdoJobStore.JobStoreTX, Quartz"/>
<add key="quartz.jobStore.misfireThreshold" value="60000"/>
<add key="quartz.jobStore.dataSource" value="default"/>
<add key="quartz.jobStore.driverDelegateType" value="Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz"/>
<add key="quartz.jobStore.lockHandler.type" value="Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz"/>
<add key="quartz.jobStore.tablePrefix" value="QRTZ_"/>
<add key="quartz.dataSource.default.connectionString" value="Server=(local);Database=Quartz;UID=XXXX;PWD=XXXX"/>
<add key="quartz.dataSource.default.provider" value="SqlServer-20"/>
<add key="quartz.dataSource.useProperties" value="true"/>
</quartz>
And here's the relevant initialization code: 这是相关的初始化代码:
var config = (NameValueCollection) ConfigurationManager.GetSection("quartz");
ISchedulerFactory factory = new StdSchedulerFactory(config);
// This is where an ArgumentOutOfRange exception occurs:
IScheduler scheduler = factory.GetScheduler();
And the error I am getting is ArgumentOutOfRangeException
: 我得到的错误是
ArgumentOutOfRangeException
:
Length cannot be less than zero.\\r\\nParameter name: length
长度不能小于零。\\ r \\ n参数名称:长度
Stepping through the code I can verify the config section gets read correctly and I double and triple checked for misspellings and wrong capitalization of the config properties. 单步执行代码,我可以验证配置部分是否正确读取,并且我检查拼写错误和配置属性的大写错误。 I have verified the database is accessible with the
connectionString
that I have. 我已经验证了可以使用我拥有的
connectionString
访问数据库。
One thing that I noticed while stepping through the code and examining the factory variable in the Immediate Window is that it always says "AllSchedulers: Count = 0" - not sure if that is because I haven't instantiated one yet or if that's part of my problem. 在通过代码并在立即窗口中检查工厂变量时我注意到的一件事是它总是说“AllSchedulers:Count = 0” - 不确定是否因为我还没有实例化一个或者如果那是我的问题。 Trying to give
GetScheduler()
the instanceName
from the configuration - 试图从配置中为
GetScheduler()
instanceName
-
factory.GetScheduler("XxxDefaultQuartzScheduler")
doesn't work either. 也不起作用。
What am I missing/doing wrong? 我错过了什么/做错了什么? Please advice.
请指教。
Ok, figured out my own problem - The property quartz. 好吧,想出了我自己的问题 - 属性石英。 dataSource .useProperties should be quartz.
dataSource .useProperties应该是quartz。 jobStore .useProperties
jobStore .useProperties
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.