Interceptors
Interception Points
cbq announces the following interception points:
onCBQJobAdded
onCBQJobAddedThis is called when a Job is dispatched to a Queue.
onCBQJobMarshalled
onCBQJobMarshalledThis is called when a Job is pulled off the Queue to work.
onCBQJobComplete
onCBQJobComplete This is called when a Job successfully finishes executing.
onCBQJobException
onCBQJobException This is called when encountering an exception when handling a Job.
onCBQJobFailed
onCBQJobFailed This is called when a Job is considered failed, after exhausting its maxAttempts.
JobPattern Annotation
To use the jobPattern annotation, you must have enabled the registerJobInterceptorRestrictionAspect setting in your module settings.
Interceptors listening on the cbq interception points listed above can optionally restrict execution to certain Jobs using a jobPattern annotation (similar to the eventPattern annotation in ColdBox).
component {
function onCBQJobMarshalled( event, data ) jobPattern="SendWelcomeEmailJob" {
// check if we've hit the email send limits for the month
}
}This annotation accepts a regex string to check against the Job full name:
component {
function onCBQJobMarshalled( event, data ) jobPattern="^.*Email.*$" {
// check if we've hit the email send limits for the month
}
}