About Interceptors and Custom Hooks

MarkLogic Data Hub provides two mechanisms to add custom processing to a step.

  • An interceptor is executed within the same database transaction as the core step processes, after the core step processes are run and before the results are saved.
  • A custom hook is executed in a separate database transaction either before or after the core step process transaction.
    Note: Custom hooks are deprecated. Use interceptors instead.

Results are saved within each transaction.

For example, if your step has interceptors and custom hooks that make changes to the data, the processing might be as follows:


Flow of step with interceptor and pre-step and post-step custom hooks

  1. In the pre-step custom hook transaction,
    1. The pre-step custom hook is executed.
    2. The custom hook module can save its own changes to the database.
  2. In the main step transaction,
    1. The core processes of the step are executed.
    2. The post-step interceptor is executed.
  3. In the post-step custom hook transaction,
    1. The post-step custom hook is executed.
    2. The custom hook module can save its own changes to the database.
  4. All changes by the core processes and by the interceptor, as well as unsaved changes by all custom hooks, are saved to the database.

You can use interceptors and custom hooks to perform various processes that modify documents, URIs, collections, or permissions. For example:

  • Fine-tune the instance with additional metadata after the core step processes.
  • Apply collections and permissions based on logic.
  • Replace the default URIs of documents to be written.
  • Insert triples.

Go to GitHub for an example project that uses step interceptors.