Odoo
Cyllo

# Job Queue

This Odoo addon introduces a comprehensive Job Queue system, enabling deferred execution of method calls in an asynchronous manner. With this feature, users can manage and execute tasks efficiently, enhancing the overall performance and scalability of their Odoo applications.

This addon adds an integrated Job Queue to Odoo. It allows to postpone method calls executed asynchronously. Jobs are executed in the background by a Jobrunner, in their own transaction.

Example:

                                        from odoo import models, fields, api

                                        class MyModel(models.Model):
                                           _name = 'my.model'

                                           def my_method(self, a, k=None):
                                               _logger.info('executed with a: %s and k: %s', a, k)

                                        class MyOtherModel(models.Model):
                                            _name = 'my.other.model'

                                            def button_do_stuff(self):
                                                self.env['my.model'].with_delay().my_method('a', k=2)

In the snippet of code above, when we call button_do_stuff, a job capturing the method and arguments will be postponed. It will be executed as soon as the Jobrunner has a free bucket, which can be instantaneous if no other job is running.

#### Key Features

- Views for jobs, jobs are stored in PostgreSQL
- Jobrunner: execute the jobs, highly efficient thanks to PostgreSQL’s NOTIFY
- Channels: give a capacity for the root channel and its sub-channels and segregate jobs in them. Allow for instance to restrict heavy jobs to be executed one at a time while little ones are executed 4 at a times.
- Retries: Ability to retry jobs by raising a type of exception
- Retry Pattern: the 3 first tries, retry after 10 seconds, the 5 next tries, retry after 1 minutes, …
- Job properties: priorities, estimated time of arrival (ETA), custom description, number of retries
- Related Actions: link an action on the job view, such as open the record concerned by the job

##### Views for Jobs

Implement user interface views for managing and monitoring jobs, allowing users to view job details, statuses, and perform actions related to jobs.

##### Jobrunner

component responsible for executing jobs efficiently, leveraging PostgreSQL's NOTIFY feature to handle job execution and notifications

##### Queued jobs

##### Form view for Job Queue

##### Jobs to done wizard

##### Jobs cancel wizard

Disabled tab content

##

This Odoo addon introduces a comprehensive Job Queue system, enabling deferred execution of method calls in an asynchronous manner. With this feature, users can manage and execute tasks efficiently, enhancing the overall performance and scalability of their Odoo applications

##

Using the Odoo configuration file

                            [options]
                            (...)
                            workers = 6
                            server_wide_modules = web,queue_job

                            (...)
                            [queue_job]
                            channels = root:2