# Interceptors

## Interception Points

cbq announces the following interception points:

### `onCBQJobAdded`

This is called when a Job is dispatched to a Queue.

### `onCBQJobMarshalled`

This is called when a Job is pulled off the Queue to work.

### `onCBQJobComplete`&#x20;

This is called when a Job successfully finishes executing.

### `onCBQJobException`&#x20;

This is called when encountering an exception when handling a Job.

### `onCBQJobFailed`&#x20;

This is called when a Job is considered failed, after exhausting its `maxAttempts`.

## JobPattern Annotation

{% hint style="warning" %}
To use the `jobPattern` annotation, you must have enabled the `registerJobInterceptorRestrictionAspect` setting in your [module settings](/2.1.0/configuration/module-settings.md).
{% endhint %}

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](https://coldbox.ortusbooks.com/the-basics/interceptors/restricting-execution)).

```cfscript
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:

```cfscript
component {

    function onCBQJobMarshalled( event, data ) jobPattern="^.*Email.*$" {
        // check if we've hit the email send limits for the month
    }

}
```

{% hint style="info" %}
Jobs that do not match the interception point will send a notice to the `debug` log, if that is turned on for `JobInterceptorRestriction`.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cbq.ortusbooks.com/2.1.0/interceptors.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
