# oca/queue architecture

> Architecture diagram of the GitHub repository oca/queue, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/oca/queue
- Repository: https://github.com/oca/queue

## Overview

Based on our analysis of both the file tree and the README, the project is a collection of Odoo modules focusing on asynchronous job queue management. This solution extends Odoo’s core functionality by “delaying” model methods into background jobs; it even partitions jobs into different queues or channels, supports scheduled execution (via cron), and includes features for importing/exporting data asynchronously, batch processing, and even web notifications for failures.

- Odoo Core – since all modules are Odoo addons, the core Odoo system (including its ORM, views, and controllers) should be represented.
- Asynchronous Job Queue Engine – the central component where jobs are enqueued and processed. This is primarily depicted by the “queue_job” module.
- Specific Job Modules – each module in the repository provides a distinct feature:
– base_export_async: handles delayed exports.
– base_import_async: manages asynchronous CSV import.
– queue_job_batch: offers batch processing for jobs.
– queue_job_cron and queue_job_cron_jobrunner: extend or replace cron’s scheduled actions with queued jobs.
– queue_job_subscribe: manages job subscription and notifications.
– queue_job_web_notify: provides web-based notifications for failed jobs.
- Job Runner/Worker – a component/button/actor that picks up jobs from the queue, processes them, and reports back. Some modules (e.g., “queue_job_cron_jobrunner”) allow running jobs without a dedicated runner.
- Persistence/Data Storage – the database where job states, arguments, and metadata are stored.
- External/Client Interfaces – if applicable, this includes web controllers (for example, REST controllers in queue_job/controllers) that let users interact with or monitor the job queue.

##### Relationships and data flows
- How a user action or a triggered model method leads to enqueuing a job through the job queue engine.

##### Architectural patterns/design principles
- Modularity – each feature (e.g., export, import, cron integration) is implemented as a self-contained Odoo addon. Represent these as separate blocks that plug into the main asynchronous engine.
- Extensibility – note that the project allows for additional modules (such as tests, setup configurations) that interact in standardized ways with Odoo’s framework.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "External Triggers"
        UserTrigger("User Trigger"):::trigger
    end

    subgraph "Odoo Core Layer"
        OdooCore("Odoo Core (ORM, Views, Controllers)"):::core
        ExternalInterfaces("Web Controllers"):::interface
    end

    subgraph "Asynchronous Processing Pipeline"
        QueueJobEngine("Queue Job Engine"):::engine
        JobRunner("Job Runner/Worker"):::worker
        Persistence("Data Storage (Database)"):::database
    end

    subgraph "Asynchronous Data Operations"
        DataExportAsync("Data Export Module"):::addon
        DataImportAsync("Data Import Module"):::addon
    end

    subgraph "Job Management Modules"
        BatchProcessing("Batch Processing Module"):::addon
        CronScheduler("Cron Scheduler Module"):::addon
        CronJobRunner("Cron Job Runner"):::addon
        JobSubscription("Job Subscription Module"):::addon
        WebNotification("Web Notification Module"):::addon
    end

    %% Connections
    UserTrigger -->|"trigger"| OdooCore
    OdooCore -->|"enqueue"| QueueJobEngine
    OdooCore -->|"interface"| ExternalInterfaces

    QueueJobEngine -->|"dispatch"| JobRunner
    QueueJobEngine -->|"export"| DataExportAsync
    QueueJobEngine -->|"import"| DataImportAsync
    QueueJobEngine -->|"batch"| BatchProcessing
    QueueJobEngine -->|"schedule"| CronScheduler
    QueueJobEngine -->|"run"| CronJobRunner
    QueueJobEngine -->|"subscribe"| JobSubscription
    QueueJobEngine -->|"notify"| WebNotification

    JobRunner -->|"update"| Persistence
    ExternalInterfaces -->|"log/view"| Persistence

    %% Styles
    classDef trigger fill:#f9c,stroke:#333,stroke-width:2px;
    classDef core fill:#bbf,stroke:#333,stroke-width:2px;
    classDef engine fill:#fc9,stroke:#333,stroke-width:2px;
    classDef worker fill:#cfc,stroke:#333,stroke-width:2px;
    classDef database fill:#cff,stroke:#333,stroke-width:2px;
    classDef interface fill:#ff9,stroke:#333,stroke-width:2px;
    classDef addon fill:#ffd,stroke:#333,stroke-width:2px;

    %% Click Events
    click QueueJobEngine "https://github.com/oca/queue/blob/16.0/queue_job/__init__.py"
    click DataExportAsync "https://github.com/oca/queue/blob/16.0/base_export_async/__manifest__.py"
    click DataExportAsync "https://github.com/oca/queue/blob/16.0/base_export_async/models/delay_export.py"
    click DataImportAsync "https://github.com/oca/queue/blob/16.0/base_import_async/__manifest__.py"
    click DataImportAsync "https://github.com/oca/queue/blob/16.0/base_import_async/models/base_import_import.py"
    click BatchProcessing "https://github.com/oca/queue/blob/16.0/queue_job_batch/__manifest__.py"
    click BatchProcessing "https://github.com/oca/queue/blob/16.0/queue_job_batch/models/queue_job_batch.py"
    click CronScheduler "https://github.com/oca/queue/blob/16.0/queue_job_cron/__manifest__.py"
    click CronScheduler "https://github.com/oca/queue/blob/16.0/queue_job_cron/models/ir_cron.py"
    click CronJobRunner "https://github.com/oca/queue/blob/16.0/queue_job_cron_jobrunner/__manifest__.py"
    click CronJobRunner "https://github.com/oca/queue/blob/16.0/queue_job_cron_jobrunner/models/ir_cron.py"
    click JobSubscription "https://github.com/oca/queue/blob/16.0/queue_job_subscribe/__manifest__.py"
    click JobSubscription "https://github.com/oca/queue/blob/16.0/queue_job_subscribe/models/queue_job.py"
    click WebNotification "https://github.com/oca/queue/blob/16.0/queue_job_web_notify/__manifest__.py"
    click WebNotification "https://github.com/oca/queue/blob/16.0/queue_job_web_notify/models/queue_job_function.py"
    click JobRunner "https://github.com/oca/queue/blob/16.0/queue_job/jobrunner/runner.py"
    click JobRunner "https://github.com/oca/queue/blob/16.0/queue_job/jobrunner/channels.py"
    click ExternalInterfaces "https://github.com/oca/queue/blob/16.0/queue_job/controllers/main.py"
```
