无法保存任何东西到Quartz.net结结实实店 [英] Unable to save anything to the Quartz.net ado store

查看:132
本文介绍了无法保存任何东西到Quartz.net结结实实店的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是Quartz.Net开始了。所以,请不要介意的菜鸟问题。

Just starting out with Quartz.Net. So please dont mind the rookie question.

我已搜查SO但显然,我不能找人面临同样的问题。我使用MySQL我Quartz.Net ADO店
。我能够成功运行服务,也使用调度火的工作。但没有获得登录到数据库。我检查,如果DB是越来越被使用虚假密码拿起和计划程序服务将无法启动。所以店里正在由服务选取但不被记录其被解雇的就业机会。我不知道为什么。

I have searched SO but apparently, I couldn't find someone facing the same problem. I am using MySQL for my Quartz.Net ADO store. I am able to run the service successfully and also fire jobs using the scheduler. But nothing gets logs into the Database. I checked if the DB is getting picked up by using a false password and the Scheduler service fails to start. So the Store is being picked by the service but the jobs which are fired are not being logged. I am not sure why.

这是我的计划程序服务的属性。

These are the properties of my Scheduler Service.

  <quartz >
    <add key="quartz.scheduler.instanceName" value="AbACScheduler"/>
    <add key="quartz.scheduler.instanceId" value="instance_one"/>
    <add key="quartz.threadPool.threadCount" value="10"/>
    <add key="quartz.threadPool.threadPriority" value="Normal"/>

    <add key="quartz.jobStore.driverDelegateType" value="Quartz.Impl.AdoJobStore.MySQLDelegate, Quartz"/>
    <add key="quartz.jobStore.dataSource" value="default"/>
    <add key="quartz.jobStore.type" value="Quartz.Impl.AdoJobStore.JobStoreTX, Quartz"/>
    <add key="quartz.dataSource.default.connectionString" value="Server=localhost;Database=quartz;Uid=xxx;Pwd=xxx;"/>
    <add key="quartz.jobStore.tablePrefix" value="qrtz_"/>
    <add key="quartz.dataSource.default.provider" value="MySql-50"/>
    <add key="quartz.jobStore.useProperties" value="true"/>
  </quartz>



表前缀也是正确的,我现在用的是5.0的MySQL连接器。

The table prefix is also correct and I am using the 5.0 MySQL connector.

这是测试服务我的小试控制台代码。

This is my Small test Console code for testing the service.

 private static void Main(string[] args)
    {
        try
        {
            Common.Logging.LogManager.Adapter = new Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter { Level = Common.Logging.LogLevel.Info };

            // Grab the Scheduler instance from the Factory 
            IScheduler scheduler = GetScheduler();

            // and start it off
            scheduler.Start();

            // define the job and tie it to our HelloJob class
            IJobDetail job = JobBuilder.Create<HelloJob>()
                .WithIdentity("job1", "group1")
                .Build();

            // Trigger the job to run now, and then repeat every 10 seconds
            ITrigger trigger = TriggerBuilder.Create()
                .WithIdentity("trigger1", "group1")
                .StartNow()
                .WithSimpleSchedule(x => x
                    .WithIntervalInSeconds(10)
                    .RepeatForever())
                .Build();

            // Tell quartz to schedule the job using our trigger
            scheduler.ScheduleJob(job, trigger);

            // some sleep to show what's happening
            Thread.Sleep(TimeSpan.FromSeconds(60));

            // and last shut down the scheduler when you are ready to close your program
            scheduler.Shutdown();
        }
        catch (SchedulerException se)
        {
            Console.WriteLine(se);
        }

        Console.WriteLine("Press any key to close the application");
        Console.ReadKey();
    }
    private static IScheduler GetScheduler()
    {
        try
        {
            var properties = new NameValueCollection();
            properties["quartz.scheduler.instanceName"] = "AbACScheduler";
            properties["quartz.dataSource.default.provider"] ="MySql-50";
            properties["quartz.scheduler.proxy.address"] = string.Format(@"tcp://{0}:{1}/{2}", "localhost", "555",
                                                                         "AbACScheduler");

            // Get a reference to the scheduler
            var sf = new StdSchedulerFactory(properties);

            return sf.GetScheduler();

        }
        catch (Exception ex)
        {
            Console.WriteLine("Scheduler not available: '{0}'", ex.Message);
            throw;
        }
    }

这是我的HelloJob(从quartz.Net拍摄)

This is my HelloJob (taken from quartz.Net)

public class HelloJob : IJob
    {
        public void Execute(IJobExecutionContext context)
        {
            Console.WriteLine("Greetings from HelloJob!");
        }
    }



我把DB脚本为MySQL创建ADOStore,它与Quartz.Net源文件走过来。

I took the DB script for creating ADOStore for MySQL, which came along with the Quartz.Net Source files.

这有什么,我做错了什么?请指引我。

IS there anything which I am doing wrong? Please guide me.

谢谢!

推荐答案

相比我的工作AdoJobStore (但与SQL Server)........到你,我看到了以下项目缺少

Comparing my working AdoJobStore (but with sql server)........to yours, I see the following items missing.

<add key="quartz.scheduler.instanceName" value="ExampleDefaultQuartzSchedulerInstanceName"/>
<add key="quartz.scheduler.instanceId" value="instance_one"/>
<add key="quartz.threadPool.threadCount" value="10"/>
<add key="quartz.threadPool.threadPriority" value="Normal"/>

现在我有这样的:

<add key="quartz.jobStore.driverDelegateType" value="Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz"/>

和你有:

有一个MySQL特定的一个?

Is there a MySql specific one?

下面是我的全部设置,使用SQL Server,但也许你可以开始。这和插件在mysql值

Here is my full setup, with sql server, but maybe you can start with this and plug in the mysql values.

<add key="quartz.scheduler.instanceName" value="ExampleDefaultQuartzSchedulerFromConfigFileSqlServer"/>
<add key="quartz.scheduler.instanceId" value="instance_one"/>
<add key="quartz.threadPool.threadCount" value="10"/>
<add key="quartz.threadPool.threadPriority" value="Normal"/>

<!-- 
org.quartz.scheduler.idleWaitTime
Is the amount of time in milliseconds that the scheduler will wait before re-queries for available triggers when the scheduler is otherwise idle. Normally you should not have to 'tune' this parameter, unless you're using XA transactions, and are having problems with delayed firings of triggers that should fire immediately.
It defaults to every 30 seconds until it finds a trigger. Once it finds any triggers, it gets the time of the next trigger to fire and stops checking until then, unless a trigger changes.   -->
<add key="quartz.scheduler.idleWaitTime" value ="5000"/>

<!-- Misfire : see http://nurkiewicz.blogspot.com/2012/04/quartz-scheduler-misfire-instructions.html  -->
<add key="quartz.jobStore.misfireThreshold" value="60000"/>
<add key="quartz.jobStore.type" value="Quartz.Impl.AdoJobStore.JobStoreTX, Quartz"/>
<add key="quartz.jobStore.tablePrefix" value="QRTZ_"/>
<add key="quartz.jobStore.clustered" value="false"/>
<add key="quartz.jobStore.driverDelegateType" value="Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz"/>


<add key="quartz.jobStore.dataSource" value="MySqlServerFullVersion"/>
<add key="quartz.jobStore.useProperties" value="false"/>

<add key="quartz.dataSource.MySqlServerFullVersion.connectionString" value="SuperSecret!!"/>
<add key="quartz.dataSource.MySqlServerFullVersion.provider" value="SqlServer-20"/>



修改

下面是我完整的代码......作为一个供参考。

Here is my full code......as an FYI.

            NameValueCollection config = (NameValueCollection)ConfigurationManager.GetSection("quartz");
            ISchedulerFactory factory = new StdSchedulerFactory(config);
            IScheduler sched = factory.GetScheduler();

            try
            {

                sched.Clear();

                /* schedule some jobs through code */

                sched.Start();

                Thread.Sleep(TimeSpan.FromSeconds(1));

                Console.WriteLine(string.Empty);
                Console.WriteLine("Press ENTER to Continue to Shut Down");
                Console.WriteLine(string.Empty);
                Console.ReadLine();

            }
            finally
            {
                sched.Shutdown(false);
            }


            Console.Write("");

        }
        catch (Exception ex)
        {

            Exception exc = ex;
            while (null != exc)
            {
                Console.WriteLine(exc.Message);
                exc = exc.InnerException;
            }
        }
        finally
        {
            Console.WriteLine(string.Empty);
            Console.WriteLine(string.Empty);
            Console.WriteLine("Press ENTER to Exit");
            Console.ReadLine();
        }



我只是检查。在[QRTZ_FIRED_TRIGGERS]后自己清理。它不保留完整的历史。

I just checked. The [QRTZ_FIRED_TRIGGERS] "cleans up after itself". It does NOT keep a full history.

我已经在我的开发环境中运行数以千计的就业机会,但该表中有一排。

I've run thousands of jobs on my dev environment, but that table has one row in it.

Note this code in StdAdoConstants.cs


        public static readonly string SqlDeleteFiredTrigger =
            string.Format(CultureInfo.InvariantCulture, "DELETE FROM {0}{1} WHERE {2} = {3} AND {4} = @triggerEntryId", 
            TablePrefixSubst, TableFiredTriggers,ColumnSchedulerName, SchedulerNameSubst, ColumnEntryId);

        public static readonly string SqlDeleteFiredTriggers =
            string.Format(CultureInfo.InvariantCulture, "DELETE FROM {0}{1} WHERE {2} = {3}", TablePrefixSubst, TableFiredTriggers, ColumnSchedulerName, SchedulerNameSubst);

        public static readonly string SqlDeleteInstancesFiredTriggers =
            string.Format(CultureInfo.InvariantCulture, "DELETE FROM {0}{1} WHERE {2} = {3} AND {4} = @instanceName", TablePrefixSubst, TableFiredTriggers, ColumnSchedulerName, SchedulerNameSubst,
                          ColumnInstanceName);

这篇关于无法保存任何东西到Quartz.net结结实实店的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆