Reputation: 315
I have properly created and scheduled a Job (I don't write the Job and Trigger creation here, just to be brief). Scheduler is created and started as follows:
_scheduler = New StdSchedulerFactory().GetScheduler
_scheduler.Start()
Jobs are executed at the scheduled time.
Then I created a very simple (and empty, at the moment) a JobListener:
Imports Quartz
Public Class JobListener
Implements IJobListener
#Region "Public properties"
Public ReadOnly Property Name As String Implements Quartz.IJobListener.Name
Get
Return "JOB_LISTENER"
End Get
End Property
#End Region
#Region "Methods"
Public Sub JobExecutionVetoed(context As Quartz.IJobExecutionContext) Implements Quartz.IJobListener.JobExecutionVetoed
Throw New NotImplementedException
End Sub
Public Sub JobToBeExecuted(context As Quartz.IJobExecutionContext) Implements Quartz.IJobListener.JobToBeExecuted
Throw New NotImplementedException
End Sub
Public Sub JobWasExecuted(context As Quartz.IJobExecutionContext, jobException As Quartz.JobExecutionException) Implements Quartz.IJobListener.JobWasExecuted
End Sub
#End Region
End Class
and add it to the scheduler:
_scheduler = New StdSchedulerFactory().GetScheduler
_scheduler.Start()
_jobListener = New JobListener()
_scheduler.ListenerManager.AddJobListener(_jobListener, GroupMatcher(Of JobKey).AnyGroup())
and now the Jobs are not executed anymore. Any hint why it happens?
Same result if I add the JobListener before starting the Scheduler:
_jobListener = New JobListener()
_scheduler = New StdSchedulerFactory().GetScheduler
_scheduler.ListenerManager.AddJobListener(_jobListener, GroupMatcher(Of JobKey).AnyGroup())
_scheduler.Start()
Upvotes: 2
Views: 1286
Reputation: 315
I figured out which was the problem.
First of all, an advice: always configure a log before starting to debug with Quartz .net.
When the Job is ready to be executed, the JobListener is notified and then the method JobToBeExecuted is called. As you can see in my JobListener's implementation I throw an exception in the method JobToBeExecuted and that exception prevents the Job to be executed.
I didn't investigate why an error in the JobListener should prevent the Job to be executed. I guess there's a chain of calls broken by the exception. Anyway, this is the answer to my question.
Upvotes: 3