Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batched jobs cannot be put on differing queues #53415

Open
ryangurn opened this issue Nov 6, 2024 · 1 comment
Open

Batched jobs cannot be put on differing queues #53415

ryangurn opened this issue Nov 6, 2024 · 1 comment

Comments

@ryangurn
Copy link

ryangurn commented Nov 6, 2024

Laravel Version

^11.9

PHP Version

8.3.13

Database Driver & Version

MariaDB

Description

Before I get started, I am not sure if this is a bug, because it is unclear if what I am trying to do is even expected, we might end up closing this saying "batches were never meant to support that" and that is fine.

I was attempting to do some job batching, in which there are two separate queues that the jobs within the batch are placed within.

For the sake of example, the two queues were "processing" and "outbound" so I can handle prioritizing this properly. I started out using sqlite for my queue and db driver, however quickly switched to mariadb.

During this process, I realized that no matter what I do when I create a batch via a hydration job, I cannot seem to get onQueue() to place the specific job into the batch but on the specified queue. Below is some example code.

Bus::batch([ (new Job1())->onQueue('processing') ])->dispatch();

at a couple points I referred to the Laravel documentation that state, "Alternatively, you may specify the job's queue by calling the onQueue method within the job's constructor:

public function __construct()
{
        $this->onQueue('processing');
}

In my specific case Job1 would hydrate the batch, with more Job1's and Job2's (which in this specific case were supposed to be on the outbound queue).

I noticed that until I stopped batching the items, I was unable to set the queue properly on items within the batch.

Steps To Reproduce

Create a batch, use a recursive job (Job 1) to hydrate the batch with more instances of itself on one queue, meanwhile in Job 1 it will also continue to hydrate the batch with another job (Job 2) but on another queue.

@crynobone
Copy link
Member

Hey there, thanks for reporting this issue.

We'll need more info and/or code to debug this further. Can you please create a repository with the command below, commit the code that reproduces the issue as one separate commit on the main/master branch and share the repository here?

Please make sure that you have the latest version of the Laravel installer in order to run this command. Please also make sure you have both Git & the GitHub CLI tool properly set up.

laravel new bug-report --github="--public"

Do not amend and create a separate commit with your custom changes. After you've posted the repository, we'll try to reproduce the issue.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants