queue icon indicating copy to clipboard operation
queue copied to clipboard

[Question] queue_job: run multi-company

Open Saran440 opened this issue 8 months ago • 3 comments

I have a multi-company setup with 5 companies, and I’m running queue_job with the root channel, configured with root=1

Current Behavior:

When each company runs a job at the same time, I observe the following:

  • queue1, company1 → started
  • queue2, company1 → pending
  • queue3, company2 → pending
  • queue4, company3 → pending
  • queue5, company4 → pending
  • queue6, company5 → pending

As a result, queue6 has to wait until all previous jobs (1–5) are completed, even though they belong to different companies.

Desired Behavior:

I want each company to be able to run one job at a time independently, like this:

  • queue1, company1 → started
  • queue2, company1 → pending
  • queue3, company2 → started
  • queue4, company3 → started
  • queue5, company4 → started
  • queue6, company5 → started

Question:

Is it possible to configure queue_job to run one concurrent job per company (instead of globally queuing everything under the root channel)? Or is there a recommended way to isolate queues by company?

Saran440 avatar Jun 04 '25 08:06 Saran440

Using the res_company_code ^1 module makes it easy to create each job with a company-specific channel, i.e.

self.with_delay(channel=self.env.company.code)._my_method()

Unfortunately, the root:1 channel configuration guarantees that only one job will ever run at a time, so that would need to be increased to root:5,codeA:1,codeB:1,codeC:1,codeD:1,codeE:1.

I have some work in progress ^2 that will simplify this configuration to root:5:subcapacity=1.

amh-mw avatar Jun 04 '25 11:06 amh-mw

@amh-mw Thank you for your answer. I will check it.

Saran440 avatar Jun 04 '25 14:06 Saran440