2012-09-26 30 views
3

我正在使用quartz.net作为Microsoft Azure Web角色中的调度程序。如果我使用RamDataStore,我可以让Quartz.net工作得很好。但是,我想将其分解为两个组件:第一个将允许通过Web界面安排作业,第二个将通过辅助角色执行作业。要进行这种分布式处理,我需要使用ADOJobStore。如何配置Quartz.net以使用Azure SQL数据库来存储ADOJobStore详细信息

一切工作正常与RamDataStore但它打破了,当我尝试切换到ADOJobStore。所以这让我相信我的物业里有一些东西我失踪了。我使用的是Azure SQL数据库,虽然这与SQL Server类似,但有些问题有时会导致问题。

我在VS2010中使用Quartz.net 2.0(来自nuGet),数据库是Azure SQL。

当我打电话.GetScheduler(),我得到以下异常:

{ “作业存储类型 'Quartz.Impl.AdoJobStore.JobStoreTX' 道具无法 配置”}

与细节:

{“无法解析属性‘default.connectionString’为正确的 数据类型:没有可写的属性“Default.co nnectionString”发现“}

我的连接代码(包括编程设置属性):

 NameValueCollection properties = new NameValueCollection(); 
     properties["quartz.scheduler.instanceName"] = "SchedulingServer"; 
     properties["quartz.threadPool.type"] = "Quartz.Simpl.ZeroSizeThreadPool, Quartz"; 

     properties["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz"; 
     properties["quartz.jobStore.tablePrefix"] = "QRTZ_"; 
     properties["quartz.jobStore.clustered"] = "false"; 
     properties["quartz.jobStore.driverDelegateType"] = "Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz"; 

     properties["quartz.jobStore.dataSource"] = "default"; 
     properties["quartz.jobStore.default.connectionString"] = "Server=tcp:serverName.database.windows.net;Database=scheduler;User [email protected];Password=***;Trusted_Connection=False;Encrypt=True;"; 
     properties["quartz.jobStore.default.provider"] = "SqlServer-20"; 
     properties["quartz.jobStore.useProperties"] = "true"; 

     ISchedulerFactory sf = new StdSchedulerFactory(properties); 
     _scheduler = sf.GetScheduler(); 

任何帮助或建议,将不胜感激。

回答

7

您的数据源,属性命名小,但微妙的错误,应改为:

properties["quartz.dataSource.default.connectionString"] = "Server=tcp:serverName.database.windows.net;Database=scheduler;User [email protected];Password=***;Trusted_Connection=False;Encrypt=True;"; 

也有一个属性的connectionStringName,如果你想使用的配置文件的连接字符串部分。

+0

hot-diggity-dog,工作! – yamspog

相关问题