arame3333
arame3333

Reputation: 10193

.Net Quartz Scheduler 2.3 does not work on the remote server

I am working on a windows service that works on my development machine, but when I deploy to a test server I find that the Quartz Scheduler I have set up does not work. There are no exceptions thrown or any clues as to why this is. Here is my code;

protected override void OnStart(string[] args)
        {
            try
            {
                this.SetDailySchedule();
            }
            catch (SchedulerException ex)
            {
                this.eventLog.WriteEntry("WMS FM Loader: Schedule Error - " + ex.Message);
                throw ex;
            }
            catch (Exception ex)
            {
                this.eventLog.WriteEntry("WMS FM Loader: Unexpected Error - " + ex.Message);
                throw ex;
            }
        }

   private void SetDailySchedule()
    {
        this.eventLog.WriteEntry("On Start".Log());
        var schedule = this.GetSchedule();

        try
        {
            this.schedFact = new StdSchedulerFactory();
            this.sched = this.schedFact.GetScheduler();
        }
        catch (Exception ex)
        {
            this.eventLog.WriteEntry(ex.Message.Log());
            throw;
        }

        this.eventLog.WriteEntry(string.Format("Got a scheduler: {0}", schedule).Log());

        try
        {
            ScheduleTheLoad(schedule);
        }
        catch (Exception ex)
        {
            this.eventLog.WriteEntry(ex.Message.Log());
            throw;
        }

        this.eventLog.WriteEntry("WMS FM Loader: Scheduler ready");
    }

    private void ScheduleTheLoad(string schedule)
    {
        var job = JobBuilder.Create<LoadWorksOrders>().WithIdentity("LoadWorksOrdersJob").Build();

        // Trigger the job to run now, and then every day
        var trigger =
            TriggerBuilder.Create()
                .ForJob(job)
                .WithIdentity("LoadWorksOrdersTrigger")
                .StartNow()
                .WithCronSchedule(schedule)
                .Build();

        this.sched.ScheduleJob(job, trigger);
        this.sched.Start();
    }

I manually start the service and the event log shows that the scheduler is ready, but LoadWorksOrdersJob doe snot get run. How should I fix this?

Upvotes: 2

Views: 662

Answers (2)

Remotec
Remotec

Reputation: 10758

I also had this problem. It took me a day to work it out.

For me it was that my assembly had dots/periods in its name. e.g.

Project.UpdateService

When I changed it to...

ProjectUpdateService

... it worked fine. It always worked on the development machine. It just would not work on the remote machine.

UPDATE: It may have been the length of the service that has caused this issue. By removing the dots I shortened the service name. It looks like the maximum length is 25 characters.

Upvotes: 0

user2613228
user2613228

Reputation: 234

Are you running the two methods in the windows service OnStart? Are you using a service account? Any exceptions in the event viewer/ have you started /stopped the service from services.msc?

Upvotes: 3

Related Questions