将 oracle 数据库配置为 Quartz.net 调度程序时出错

error in configure oracle db to Quartz.net scheduler

我是论坛的新手,也在学习构建 Quartz.Net 以满足其中一项业务需求。要求是将 Quartz 运行 作为 windows 服务,并通过与 Asp.Net 网站交互的 WCF 服务进行调度。 Jobs 相关活动的所有内务管理都将通过调用 quartz windows 服务的 WCF 服务来处理。我所取得的成就是,当我使用 RAMJobStore 时,该模型工作得非常好,但是当我将 AdoJobStore 用于 Oracle DB 时,我没有看到相关表使用 JOb 详细信息和触发器进行更新。我已经下载了 Quartz.net 服务器并将其安装为 windows 服务,没有对其代码进行任何更改。

我已经按照建议更改了实现,但现在我收到如下错误:

无法从数据源获取数据库连接'QuartzDB':System.ArgumentException:'"Data Source'是一个无效的连接字符串属性

[已编辑]: 修改后的quartz server Config如下:

quartz.scheduler.instanceName = ServerScheduler
    quartz.scheduler.instanceId = "AUTO

    # configure thread pool info
    quartz.threadPool.type = Quartz.Simpl.SimpleThreadPool, Quartz
    quartz.threadPool.threadCount = 10
    quartz.threadPool.threadPriority = Normal

    quartz.jobStore.misfireThreshold = 60000
    quartz.jobStore.type = Quartz.Impl.AdoJobStore.JobStoreTX, Quartz
    quartz.jobStore.tablePrefix = QRTZ_
    quartz.jobStore.clustered = true
    quartz.jobStore.driverDelegateType = Quartz.Impl.AdoJobStore.OracleDelegate, Quartz
    quartz.jobStore.dataSource = QuartzDB
    quartz.jobStore.useProperties = true
    quartz.dataSource.QuartzDB.connectionString = "Data Source=quartzdb;User Id=XXXX;Password=YYYY";
    quartz.dataSource.QuartzDB.provider = OracleODP-20

    # export this server to remoting context
    quartz.scheduler.exporter.type = Quartz.Simpl.RemotingSchedulerExporter, Quartz
    quartz.scheduler.exporter.port = 555
    quartz.scheduler.exporter.bindName = QuartzScheduler
    quartz.scheduler.exporter.channelType = tcp
    quartz.scheduler.exporter.channelName = httpQuartz

下面是 WCF 服务级别的 [已编辑] GetScheduler 实现:

私有静态 IScheduler GetScheduler() { 尝试 { var properties = new NameValueCollection();

         properties["quartz.scheduler.instanceName"] = "RemoteClient"; 
         properties["quartz.threadPool.threadCount"] = "0"; 
         properties["quartz.scheduler.proxy"] = "true";
         properties["quartz.scheduler.proxy.address"] = string.Format("tcp://{0}:{1}/{2}", "localhost", "555",
                                                                             "QuartzScheduler");
                // Get a reference to the scheduler
                var sf = new StdSchedulerFactory(properties);

                return sf.GetScheduler();

}

WCF 服务中定义的 CreateJob 和 Trigger 如下:

public string ScheduleJob<T>(string jobName, string jobGroup, string triggerName, string triggerGroup) where T : IJob
        {
            try
            {
                var scheduler = GetScheduler();
                if (scheduler != null)
                {
                    var jobKey = new JobKey(jobName, jobGroup);
                    var job = JobBuilder.Create<T>()
                        .WithIdentity(jobKey)
                        //.StoreDurably()
                        //.RequestRecovery(true)
                        .Build();

                    ICronTrigger triggerObject = CreateCronTrigger(triggerName, triggerGroup);
                    if (triggerObject != null)
                    {
                        // Validate that the job doesn't already exists
                        //if (scheduler.CheckExists(new JobKey(jobKey)))
                        //{
                        //    scheduler.ScheduleJob(job, triggerObject);
                        //}
                        scheduler.ScheduleJob(job, triggerObject);
                        //scheduler.Start();

                        return "SUCCESS";
                    }
                    _log.FatalFormat("{0}Trigger could not be instantiated", Environment.NewLine);
                    return "FAILURE";
                }
                _log.FatalFormat("{0}Scheduler could not be instantiated", Environment.NewLine);
                return "FAILURE";
            }

            catch (Exception ex)
            {
                _log.FatalFormat("{0}Job could not be scheduled", Environment.NewLine);
                return "FAILURE";
            }
        }

        public ICronTrigger CreateCronTrigger(string triggerName, string triggerGroup)
        {
            try
            {
                var trigger = (ICronTrigger)TriggerBuilder.Create()
                    .WithIdentity(triggerName, triggerGroup)
                    .WithCronSchedule("0 0/1 * 1/1 * ? *") // Queues the job every minute
                    .StartAt(DateTime.UtcNow)
                    .WithPriority(1)
                    .Build();

                return trigger;
            }

            catch (Exception ex)
            {
                _log.FatalFormat("{0}Cron trigger could not be created", Environment.NewLine);
                return null;
            }
        }

我无法连接到 Oracle 的任何想法。当我通过 sqlplus 连接时,相同的凭据工作正常。

请帮忙!

您真正需要在 WCF 服务上设置的是以下属性:

properties["quartz.scheduler.instanceName"] = "RemoteClient"; 
properties["quartz.scheduler.proxy"] = "true"; 
properties["quartz.threadPool.threadCount"] = "0"; 
properties["quartz.scheduler.proxy.address"] = address;

从 "client" 中删除所有其他的。