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

Bus::batch ignores job queue, while Bus::chain respects #54286

Open
vadimonus opened this issue Jan 21, 2025 · 5 comments
Open

Bus::batch ignores job queue, while Bus::chain respects #54286

vadimonus opened this issue Jan 21, 2025 · 5 comments

Comments

@vadimonus
Copy link

vadimonus commented Jan 21, 2025

Laravel Version

11

PHP Version

any supported

Database Driver & Version

No response

Description

Having some job with filled queue with onQueue call.
When I call Bus::chain([$job1, $job2]) they are pushed to specified queue.
When I call Bus::batch([$job1, $job2]) they are pushed to queue default.
Documentation https://laravel.com/docs/11.x/queues#batch-connection-queue is not very clear about this behaviour, only mentions, that queue should be same, and it is same.
Such inconsistent behavior between Chain and Batch is very confusing.

It this behaviour a bug (in this case i will provide PR with fix in code) or it is expected (in this case i will provide PR to documentation, clarifying this behavior) ?

Steps To Reproduce

create ProcessPodcast job with onQueue (second example in) https://laravel.com/docs/11.x/queues#dispatching-to-a-particular-queue
Run Bus::chain([new ProcessPodcast]) and Bus::batch([new ProcessPodcast]) and see, that batch send job to default queue, while chain to processing 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!

@laravel laravel deleted a comment from github-actions bot Jan 22, 2025
@crynobone
Copy link
Member

I believe you should be able to follow PendingChain code by getting the first job and get $firstJob->queue from there, but at the same time this also feels incorrect as if 2nd...n job has a different queue it would still use the first job's queue.

@vadimonus
Copy link
Author

@crynobone currently the question is if such difference in behaviour between chain and batch is bug, or it is expected behaviour?
Depending on it i'll bring PR to code or to documentation.

@vadimonus
Copy link
Author

BatchJobs was introduced in #32830 by taylorotwell
@taylorotwell , please give some comments.
Do you think it's better to respect jobs connection and queue (it's possible) to make chain and batch behaviour more simular. Or better to clarify documentation?

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