Configuring Quartz.NET with SQL Server AdoJobStore

只愿长相守 提交于 2019-12-07 03:07:43

问题


I am having trouble trying to get Quartz.NET to work with an 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.

Here's my quartz app.config section:

<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:

Length cannot be less than zero.\r\nParameter name: length

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.

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. Trying to give GetScheduler() the instanceName from the configuration -

factory.GetScheduler("XxxDefaultQuartzScheduler")

doesn't work either.

What am I missing/doing wrong? Please advice.


回答1:


Ok, figured out my own problem - The property quartz.dataSource.useProperties should be quartz.jobStore.useProperties



来源:https://stackoverflow.com/questions/17473408/configuring-quartz-net-with-sql-server-adojobstore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!