Class LoggingTriggerHistoryPlugin
- java.lang.Object
-
- org.quartz.plugins.history.LoggingTriggerHistoryPlugin
-
- All Implemented Interfaces:
SchedulerPlugin
,TriggerListener
public class LoggingTriggerHistoryPlugin extends java.lang.Object implements SchedulerPlugin, TriggerListener
Logs a history of all trigger firings via slf4j.The logged message is customizable by setting one of the following message properties to a String that conforms to the syntax of
java.util.MessageFormat
.TriggerFiredMessage - available message data are:
List of available data for messages. Element Data Type Description 0 String The Trigger's Name. 1 String The Trigger's Group. 2 Date The scheduled fire time. 3 Date The next scheduled fire time. 4 Date The actual fire time. 5 String The Job's name. 6 String The Job's group. 7 Integer The re-fire count from the JobExecutionContext. The default message text is "Trigger {1}.{0} fired job {6}.{5} at: {4, date, HH:mm:ss MM/dd/yyyy}"
TriggerMisfiredMessage - available message data are:
List of available data for messages. Element Data Type Description 0 String The Trigger's Name. 1 String The Trigger's Group. 2 Date The scheduled fire time. 3 Date The next scheduled fire time. 4 Date The actual fire time. (the time the misfire was detected/handled) 5 String The Job's name. 6 String The Job's group. The default message text is "Trigger {1}.{0} misfired job {6}.{5} at: {4, date, HH:mm:ss MM/dd/yyyy}. Should have fired at: {3, date, HH:mm:ss MM/dd/yyyy}"
TriggerCompleteMessage - available message data are:
List of available data for messages. Element Data Type Description 0 String The Trigger's Name. 1 String The Trigger's Group. 2 Date The scheduled fire time. 3 Date The next scheduled fire time. 4 Date The job completion time. 5 String The Job's name. 6 String The Job's group. 7 Integer The re-fire count from the JobExecutionContext. 8 Integer The trigger's resulting instruction code. 9 String A human-readable translation of the trigger's resulting instruction code. The default message text is "Trigger {1}.{0} completed firing job {6}.{5} at {4, date, HH:mm:ss MM/dd/yyyy} with resulting trigger instruction code: {9}"
- Author:
- James House
-
-
Constructor Summary
Constructors Constructor Description LoggingTriggerHistoryPlugin()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.slf4j.Logger
getLog()
java.lang.String
getName()
Get the name of theTriggerListener
.java.lang.String
getTriggerCompleteMessage()
Get the message that is printed upon the completion of a trigger's firing.java.lang.String
getTriggerFiredMessage()
Get the message that is printed upon a trigger's firing.java.lang.String
getTriggerMisfiredMessage()
Get the message that is printed upon a trigger's mis-firing.void
initialize(java.lang.String pname, Scheduler scheduler, ClassLoadHelper classLoadHelper)
Called during creation of theScheduler
in order to give theSchedulerPlugin
a chance to initialize.void
setTriggerCompleteMessage(java.lang.String triggerCompleteMessage)
Set the message that is printed upon the completion of a trigger's firing.void
setTriggerFiredMessage(java.lang.String triggerFiredMessage)
Set the message that is printed upon a trigger's firing.void
setTriggerMisfiredMessage(java.lang.String triggerMisfiredMessage)
Set the message that is printed upon a trigger's firing.void
shutdown()
Called in order to inform theSchedulerPlugin
that it should free up all of it's resources because the scheduler is shutting down.void
start()
Called when the associatedScheduler
is started, in order to let the plug-in know it can now make calls into the scheduler if it needs to.void
triggerComplete(Trigger trigger, JobExecutionContext context, Trigger.CompletedExecutionInstruction triggerInstructionCode)
void
triggerFired(Trigger trigger, JobExecutionContext context)
void
triggerMisfired(Trigger trigger)
boolean
vetoJobExecution(Trigger trigger, JobExecutionContext context)
-
-
-
Method Detail
-
getLog
protected org.slf4j.Logger getLog()
-
getTriggerCompleteMessage
public java.lang.String getTriggerCompleteMessage()
Get the message that is printed upon the completion of a trigger's firing.- Returns:
- String
-
getTriggerFiredMessage
public java.lang.String getTriggerFiredMessage()
Get the message that is printed upon a trigger's firing.- Returns:
- String
-
getTriggerMisfiredMessage
public java.lang.String getTriggerMisfiredMessage()
Get the message that is printed upon a trigger's mis-firing.- Returns:
- String
-
setTriggerCompleteMessage
public void setTriggerCompleteMessage(java.lang.String triggerCompleteMessage)
Set the message that is printed upon the completion of a trigger's firing.- Parameters:
triggerCompleteMessage
- String in java.text.MessageFormat syntax.
-
setTriggerFiredMessage
public void setTriggerFiredMessage(java.lang.String triggerFiredMessage)
Set the message that is printed upon a trigger's firing.- Parameters:
triggerFiredMessage
- String in java.text.MessageFormat syntax.
-
setTriggerMisfiredMessage
public void setTriggerMisfiredMessage(java.lang.String triggerMisfiredMessage)
Set the message that is printed upon a trigger's firing.- Parameters:
triggerMisfiredMessage
- String in java.text.MessageFormat syntax.
-
initialize
public void initialize(java.lang.String pname, Scheduler scheduler, ClassLoadHelper classLoadHelper) throws SchedulerException
Called during creation of theScheduler
in order to give theSchedulerPlugin
a chance to initialize.- Specified by:
initialize
in interfaceSchedulerPlugin
- Parameters:
pname
- The name by which the plugin is identified.scheduler
- The scheduler to which the plugin is registered.classLoadHelper
- The classLoadHelper theSchedulerFactory
is actually using- Throws:
SchedulerConfigException
- if there is an error initializing.SchedulerException
-
start
public void start()
Description copied from interface:SchedulerPlugin
Called when the associated
Scheduler
is started, in order to let the plug-in know it can now make calls into the scheduler if it needs to.- Specified by:
start
in interfaceSchedulerPlugin
-
shutdown
public void shutdown()
Called in order to inform theSchedulerPlugin
that it should free up all of it's resources because the scheduler is shutting down.- Specified by:
shutdown
in interfaceSchedulerPlugin
-
getName
public java.lang.String getName()
Description copied from interface:TriggerListener
Get the name of the
TriggerListener
.- Specified by:
getName
in interfaceTriggerListener
-
triggerFired
public void triggerFired(Trigger trigger, JobExecutionContext context)
Description copied from interface:TriggerListener
Called by the
when aScheduler
has fired, and it's associatedTrigger
is about to be executed.JobDetail
It is called before the
vetoJobExecution(..)
method of this interface.- Specified by:
triggerFired
in interfaceTriggerListener
- Parameters:
trigger
- TheTrigger
that has fired.context
- TheJobExecutionContext
that will be passed to theJob
'sexecute(xx)
method.
-
triggerMisfired
public void triggerMisfired(Trigger trigger)
Description copied from interface:TriggerListener
Called by the
when aScheduler
has misfired.Trigger
Consideration should be given to how much time is spent in this method, as it will affect all triggers that are misfiring. If you have lots of triggers misfiring at once, it could be an issue it this method does a lot.
- Specified by:
triggerMisfired
in interfaceTriggerListener
- Parameters:
trigger
- TheTrigger
that has misfired.
-
triggerComplete
public void triggerComplete(Trigger trigger, JobExecutionContext context, Trigger.CompletedExecutionInstruction triggerInstructionCode)
Description copied from interface:TriggerListener
Called by the
when aScheduler
has fired, it's associatedTrigger
has been executed, and it'sJobDetail
triggered(xx)
method has been called.- Specified by:
triggerComplete
in interfaceTriggerListener
- Parameters:
trigger
- TheTrigger
that was fired.context
- TheJobExecutionContext
that was passed to theJob
'sexecute(xx)
method.triggerInstructionCode
- the result of the call on theTrigger
'striggered(xx)
method.
-
vetoJobExecution
public boolean vetoJobExecution(Trigger trigger, JobExecutionContext context)
Description copied from interface:TriggerListener
Called by the
when aScheduler
has fired, and it's associatedTrigger
is about to be executed. If the implementation vetos the execution (via returningJobDetail
true
), the job's execute method will not be called.It is called after the
triggerFired(..)
method of this interface.- Specified by:
vetoJobExecution
in interfaceTriggerListener
- Parameters:
trigger
- TheTrigger
that has fired.context
- TheJobExecutionContext
that will be passed to theJob
'sexecute(xx)
method.
-
-