title: Quartz.NET scheduler doesn't fire jobs/triggers once deployed
body: <h1>INTRODUCTION</h1>
  
  <p>I'm using <em>Quartz.Net</em> on an <em>ASP.Net</em> framework 4, webforms web site.
  Basically, the user should have the hability to fire manually a batch script that asynchronously processes thousands of records stored on a database. The user can stop or pause at any time, adjust some variables, and continue if needed with the process (remaining records).<br>
  The code is done and working locally (developer machine, win7, vs2010, sql server express 2008 R2).<br>
  It was also tested on a local server (win server 2008 R2, sql server express 2008 R2).
  It works fine on both enviroments, tested with all the code precompiled.
  The problem is that, <strong>once deployed on a remote server</strong> (win server 2008 R2), where it actually should be running on (hosting enviroment, not shared, not clustered), it doesnt completely works (se details below). <strong>Scheduler gets created, but the trigger, hence the job, doesn't fire</strong>.</p>
  
  <p>(<strong>Note:</strong> I know some of you would suggest to use Quartz as windows service, but despite the benefits of doing so, I really would like to find out why it doesn't work as an embedded solution, since it should be working just fine like does locally)</p>
  
  <h1>DETAILS</h1>
  
  <pre><code>Quartz 2.1.2  
  Common.Logging 2.1.2  
  Common.Logging.NLog 2.0.0  
  NLog 2.0.1.2
  </code></pre>
  
  <p><strong>global.asax</strong></p>
  
  <pre><code>public static ISchedulerFactory SchedulerFactory;
  public static IScheduler Scheduler;
  
  void Application_Start(object sender, EventArgs e)
  {
      SchedulerFactory = new StdSchedulerFactory();
      Scheduler = SchedulerFactory.GetScheduler();
  
      // Define a durable job instance (durable jobs can exist without triggers)
      IJobDetail job = JobBuilder.Create&lt;MyJobClass&gt;()
                                  .WithIdentity("MyJob", "MyGroup")
                                  .StoreDurably()
                                  .Build();
  
      Scheduler.AddJob(job, false);
      Scheduler.Start();
  }
  void Application_End(object sender, EventArgs e)
  {
      Scheduler.Shutdown(true);
  }
  </code></pre>
  
  <p><strong>process.aspx.cs</strong> (start button click)</p>
  
  <pre><code>// get records from DB, iterate, process, etc
  ...
  
  IJobDetail job = ASP.global_asax.Scheduler.GetJobDetail(new JobKey("MyJob", "MyGroup"));
  job.JobDataMap.Put("something1", 1);
  job.JobDataMap.Put("something2", somevar);
  
  ITrigger trigger = TriggerBuilder.Create()
                      .WithIdentity("MyTrigger", "MyGroup")
                      .StartNow()
                      .WithSimpleSchedule(x =&gt; x.WithIntervalInSeconds(5).RepeatForever())
                      .Build();
  
  var triggersSet = new Quartz.Collection.HashSet&lt;ITrigger&gt; { trigger };
  
  ASP.global_asax.Scheduler.ScheduleJob(job, triggersSet, true);
  </code></pre>
  
  <h1>LOG OUTPUT</h1>
  
  <h2>local log</h2>
  
  <pre><code>Default Quartz.NET properties loaded from embedded resource file  
  Using default implementation for object serializer  
  Using default implementation for ThreadExecutor  
  Initialized Scheduler Signaller of type: Quartz.Core.SchedulerSignalerImpl  
  Quartz Scheduler v.2.1.2.400 created.  
  RAMJobStore initialized.  
  Scheduler meta-data: Quartz Scheduler (v2.1.2.400) 'DefaultQuartzScheduler' with instanceId 'NON_CLUSTERED'   Scheduler class: 'Quartz.Core.QuartzScheduler' - running locally.   NOT STARTED.   Currently in standby mode.   Number of jobs executed: 0   Using thread pool 'Quartz.Simpl.SimpleThreadPool' - with 10 threads.   Using job-store 'Quartz.Simpl.RAMJobStore' - which does not support persistence. and is not clustered.  
  Quartz scheduler 'DefaultQuartzScheduler' initialized  
  Quartz scheduler version: 2.1.2.400  
  Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED started.  
  Batch acquisition of 0 triggers  
  Batch acquisition of 0 triggers
  </code></pre>
  
  <p>It continues logging <em>Batch acquisition of 0 triggers</em> until button click occurs:</p>
  
  <pre><code>Default Quartz.NET properties loaded from embedded resource file  
  Batch acquisition of 1 triggers  
  Producing instance of Job 'MyGroup.MyJob', class=MyJobClass  
  Batch acquisition of 0 triggers  
  Calling Execute on job MyGroup.MyJob  
  Trigger instruction : NoInstruction  
  Batch acquisition of 1 triggers  
  Producing instance of Job 'MyGroup.MyJob', class=MyJobClass  
  Batch acquisition of 0 triggers  
  Calling Execute on job MyGroup.MyJob  
  Trigger instruction : NoInstruction  
  Batch acquisition of 1 triggers
  </code></pre>
  
  <h2>deployed log</h2>
  
  <pre><code>Default Quartz.NET properties loaded from embedded resource file  
  Using default implementation for object serializer  
  Using default implementation for ThreadExecutor  
  Initialized Scheduler Signaller of type: Quartz.Core.SchedulerSignalerImpl  
  Quartz Scheduler v.2.1.2.400 created.  
  RAMJobStore initialized.  
  Scheduler meta-data: Quartz Scheduler (v2.1.2.400) 'DefaultQuartzScheduler' with instanceId 'NON_CLUSTERED' Scheduler class: 'Quartz.Core.QuartzScheduler' - running locally. NOT STARTED. Currently in standby mode. Number of jobs executed: 0 Using thread pool 'Quartz.Simpl.SimpleThreadPool' - with 10 threads. Using job-store 'Quartz.Simpl.RAMJobStore' - which does not support persistence. and is not clustered.   
  Quartz scheduler 'DefaultQuartzScheduler' initialized  
  Quartz scheduler version: 2.1.2.400  
  Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED started.
  </code></pre>
  
  <p>Here stays like this. As you see, compared to the other log, it's not trying to acquire triggers (line <em>Batch acquisition of 0 triggers</em> does not appear at all). If you click the process button anyway, the log adds one line:</p>
  
  <pre><code>Default Quartz.NET properties loaded from embedded resource file
  </code></pre>
  
  <p>But nothing else happens. The records are not processed (I know since every time a record is proccessed, is marked in the database). No errors occur, but <strong>the trigger is not fired, and the job is not executed. Also, the CPU usage run up to 50% or more on button click, and doesnt gets down unless you go to IIS, stop and restart the application pool</strong>. This cpu consumption doesn't happen locally.</p>
  
  <hr>
  
  <h2>update 1</h2>
  
  <p>Changed use of scheduler for a <strong>singleton</strong>, as suggested by LeftyX, but still get same behavior on remote server.</p>
  
  <h2>update 2</h2>
  
  <p>I also tried to use <strong>ADOJobStore</strong> (instead of <em>RAMJobStore</em> which I was using).
  Now it still works perfectly locally; but <strong>still doesn't execute the trigger (hence job) online</strong>. The only difference is that online the CPU usage doesn't run up to 50%.
  And now I can see that <strong>the job and trigger are created</strong> (I query the tables and see that those records exists), <strong>but never gets executed</strong>.</p>