2

Trying to master my Laravel queues. I've got a production Laravel site using Redis queues managed by Horizon. There's one queue called 'default' for basic jobs, and another called 'long-running-queue' with a longer timeout.

Some of my longer jobs run via the scheduler overnight on the 'long-running-queue', which works reliably.

But sometimes I need to re-run these longer jobs during the day. I've figured out how to do this for quick jobs using \Bus::dispatch() from tinker (php artisan tinker), but cannot seem to dispatch them to the long-running-queue; they always stay on the default.

It seems that something like this should work from the Tinker console:

\Bus::dispatch(new \App\Jobs\MyJob('MyArg'))->onQueue('long-running-queue')

...but it gives this:

PHP Error:  Call to a member function onQueue() on string in /home/mywebappeval()'d code on line 1

Can't seem to fine a posted solution to this problem anywhere. Any ideas? Thanks!!

1 Answer 1

5

You need to call onQueue() of the instance of the job, you are calling it on the result of the dispatch method.

$job = (new \App\Jobs\MyJob('MyArg'))->onQueue('long-running-queue');

Bus::dispatch($job);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.