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!!
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);