0

I've been running the examples that come with Quartz.Net and I noticed that the scheduler still runs jobs even if the Windows service is stopped! So what is it there for?

Also, I ran this code in a unit test...

        ISchedulerFactory schedFact = new StdSchedulerFactory();

        // get a scheduler
        IScheduler sched = schedFact.GetScheduler();
        sched.Start();

        // construct job info
        JobDetail jobDetail = new JobDetail("myJob", null, typeof (MyJob));

        Trigger trigger = TriggerUtils.MakeMinutelyTrigger(1);

        trigger.StartTimeUtc = DateTime.UtcNow;

        trigger.Name = "myTrigger";

        sched.ScheduleJob(jobDetail, trigger);

The test completed but a breakpoint in the job didn't ever fire. What process do I need to attach to in order to debug a job?

What am I missing here? Is the StdSchedulerFactory not connected to the Windows Service?

Cheers, Ian.

EDIT:

Here is the code...

NameValueCollection properties = new NameValueCollection();
        properties["quartz.scheduler.instanceName"] = "RemoteClient";

        // set thread pool info            
        properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
        properties["quartz.threadPool.threadCount"] = "5";
        properties["quartz.threadPool.threadPriority"] = "Normal";

        // set remoting expoter
        properties["quartz.scheduler.proxy"] = "true";
        properties["quartz.scheduler.proxy.address"] = "tcp://localhost:555/QuartzScheduler";

        // First we must get a reference to a scheduler

        ISchedulerFactory sf = new StdSchedulerFactory(properties);
        IScheduler sched = sf.GetScheduler();

        //sched.Start();

        // define the job and ask it to run
        JobDetail job = new JobDetail("remotelyAddedJob", "default", typeof(SimpleJob));
        JobDataMap map = new JobDataMap();
        map.Put("msg", "Your remotely added job has executed!");
        job.JobDataMap = map;
        CronTrigger trigger = new CronTrigger("remotelyAddedTrigger", "default", "remotelyAddedJob", "default", DateTime.UtcNow, null, "/5 * * ? * *");

        // schedule the job
        sched.ScheduleJob(job, trigger); 

'SimpleJob' is just an implementation of IJob that's defined in the same assembly as the above code. And yes, it can't find the dll that the job type is defined in.

Ian Warburton
  • 14,318
  • 20
  • 99
  • 173
  • Which example is it? Also, quartz.net jobs run in a separate thread, you can't expect it to "pause" the test until the job runs and finishes... – Mauricio Scheffer Nov 21 '11 at 13:50
  • Example 1. I didn't want it to pause. I *want* my unit test to return and then the job to be triggered by the service. – Ian Warburton Nov 21 '11 at 14:02
  • If you want the test to drive the service, you should connect it to the service (see for example http://stackoverflow.com/questions/1488277/remotely-connect-to-quartz-scheduler ). It seems that the test is just spinning up a new scheduler and running jobs within the test... – Mauricio Scheffer Nov 21 '11 at 14:11
  • Doesn't that example connect to a remote machine as opposed to the Windows Service? – Ian Warburton Nov 21 '11 at 14:26
  • Oh wow... I got it to connect with answer 1's code... http://stackoverflow.com/questions/1356789/quartz-net-with-asp-net It very cooly throws an exception if the service isn't started. But when the service is running and I schedule a job it throws a FileNotFound exception. Any ideas? – Ian Warburton Nov 21 '11 at 14:41
  • please post the entire test code and the entire stack traces. – Mauricio Scheffer Nov 21 '11 at 14:49
  • I don't get this exception with the NoOpJob so is it looking for the dll containing the custom type of scheduled job? If so, how do I point it to the dll? – Ian Warburton Nov 21 '11 at 14:53
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/5194/discussion-between-ian-warburton-and-mauricio-scheffer) – Ian Warburton Nov 21 '11 at 15:02
  • This post explains it I think... http://stackoverflow.com/questions/3327994/update-quartz-net-job-dll-without-service-restart – Ian Warburton Nov 21 '11 at 16:08

0 Answers0