You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am running PHP 8.0.15, Laravel 8.82. When I try to dispatch jobs it works very infrequently, mostly I get an error. Not sure why this is happening. I am using the database. Any ideas?
I created a job: art make:job SendWelcomeEmail
I added a route in web.php: Route::get('/sendWelcome', function() { \App\Jobs\SendWelcomeEmail::dispatch(); });
When I go to the URL or run tinker the job hits the failed_jobs 8 or 9 out of 10 times.
Code in App\Jobs\SendWelcomeEmail:
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use App\Parts_Master;
class SendWelcomeEmail implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
info(__LINE__. ' Hello from SendWelcomeEmail handle');
}
}
I can either have supervisorctl running or stop the queue and run it via art queue:work --max-jobs=10 or in tinker: \App\Jobs\SendWelcomeEmail::dispatch()
When I do the 10, it takes several hits before returning to the command line.
Exception:
Error: The script tried to call a method on an incomplete object. Please ensure that the class definition "App\Jobs\SendWelcomeEmail" of the
object you are trying to operate on was loaded before unserialize() gets called or provide an autoloader to load the class definition in /var/www/laravel/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php:117
Stack trace:
#0 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(117): method_exists() #1 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(70): Illuminate\Queue\CallQueuedHandler->dispatchThroughMiddleware() #2 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(98): Illuminate\Queue\CallQueuedHandler->call() #3 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(428): Illuminate\Queue\Jobs\Job->fire() #4 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(378): Illuminate\Queue\Worker->process() #5 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(172): Illuminate\Queue\Worker->runJob() #6 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(117): Illuminate\Queue\Worker->daemon() #7 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101): Illuminate\Queue\Console\WorkCommand->runWorker() #8 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\Queue\Console\WorkCommand->handle() #9 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\Container\BoundMethod::Illuminate\Container{closure}() #10 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure() #11 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod() #12 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Container/Container.php(653): Illuminate\Container\BoundMethod::call() #13 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Illuminate\Container\Container->call() #14 /var/www/laravel/vendor/symfony/console/Command/Command.php(298): Illuminate\Console\Command->execute() #15 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\Component\Console\Command\Command->run() #16 /var/www/laravel/vendor/symfony/console/Application.php(1015): Illuminate\Console\Command->run() #17 /var/www/laravel/vendor/symfony/console/Application.php(299): Symfony\Component\Console\Application->doRunCommand() #18 /var/www/laravel/vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun() #19 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Console/Application.php(94): Symfony\Component\Console\Application->run() #20 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\Console\Application->run() #21 /var/www/laravel/artisan(37): Illuminate\Foundation\Console\Kernel->handle() #22 {main}
If I set the queue to redis (and set that up) it works without any issues. I would rather just use database as I only have 5 users accessing the system and the database should be fine handling the work load.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am running PHP 8.0.15, Laravel 8.82. When I try to dispatch jobs it works very infrequently, mostly I get an error. Not sure why this is happening. I am using the database. Any ideas?
I created a job: art make:job SendWelcomeEmail
I added a route in web.php: Route::get('/sendWelcome', function() { \App\Jobs\SendWelcomeEmail::dispatch(); });
When I go to the URL or run tinker the job hits the failed_jobs 8 or 9 out of 10 times.
Code in App\Jobs\SendWelcomeEmail:
I can either have supervisorctl running or stop the queue and run it via art queue:work --max-jobs=10 or in tinker: \App\Jobs\SendWelcomeEmail::dispatch()
When I do the 10, it takes several hits before returning to the command line.
failed_jobs entry:
payload:
{"uuid":"6abe8f79-5a4a-4bcd-a97d-0faae0a52eda","displayName":"App\Jobs\SendWelcomeEmail","job":"Illuminate\Queue\CallQueuedHandler@call","maxTries":null,"maxExceptions":null,"failOnTimeout":false,"backoff":null,"timeout":null,"retryUntil":null,"data":{"commandName":"App\Jobs\SendWelcomeEmail","command":"O:25:"App\Jobs\SendWelcomeEmail":10:{s:3:"job";N;s:10:"connection";N;s:5:"queue";N;s:15:"chainConnection";N;s:10:"chainQueue";N;s:19:"chainCatchCallbacks";N;s:5:"delay";N;s:11:"afterCommit";N;s:10:"middleware";a:0:{}s:7:"chained";a:0:{}}"}}
Exception:
Error: The script tried to call a method on an incomplete object. Please ensure that the class definition "App\Jobs\SendWelcomeEmail" of the
object you are trying to operate on was loaded before unserialize() gets called or provide an autoloader to load the class definition in /var/www/laravel/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php:117
Stack trace:
#0 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(117): method_exists()
#1 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(70): Illuminate\Queue\CallQueuedHandler->dispatchThroughMiddleware()
#2 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(98): Illuminate\Queue\CallQueuedHandler->call()
#3 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(428): Illuminate\Queue\Jobs\Job->fire()
#4 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(378): Illuminate\Queue\Worker->process()
#5 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(172): Illuminate\Queue\Worker->runJob()
#6 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(117): Illuminate\Queue\Worker->daemon()
#7 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101): Illuminate\Queue\Console\WorkCommand->runWorker()
#8 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\Queue\Console\WorkCommand->handle()
#9 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\Container\BoundMethod::Illuminate\Container{closure}()
#10 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure()
#11 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod()
#12 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Container/Container.php(653): Illuminate\Container\BoundMethod::call()
#13 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Illuminate\Container\Container->call()
#14 /var/www/laravel/vendor/symfony/console/Command/Command.php(298): Illuminate\Console\Command->execute()
#15 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\Component\Console\Command\Command->run()
#16 /var/www/laravel/vendor/symfony/console/Application.php(1015): Illuminate\Console\Command->run()
#17 /var/www/laravel/vendor/symfony/console/Application.php(299): Symfony\Component\Console\Application->doRunCommand()
#18 /var/www/laravel/vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun()
#19 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Console/Application.php(94): Symfony\Component\Console\Application->run()
#20 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\Console\Application->run()
#21 /var/www/laravel/artisan(37): Illuminate\Foundation\Console\Kernel->handle()
#22 {main}
{"uuid":"6abe8f79-5a4a-4bcd-a97d-0faae0a52eda","displayName":"App\Jobs\SendWelcomeEmail","job":"Illuminate\Queue\CallQueuedHandler@call","maxTries":null,"maxExceptions":null,"failOnTimeout":false,"backoff":null,"timeout":null,"retryUntil":null,"data":{"commandName":"App\Jobs\SendWelcomeEmail","command":"O:25:"App\Jobs\SendWelcomeEmail":10:{s:3:"job";N;s:10:"connection";N;s:5:"queue";N;s:15:"chainConnection";N;s:10:"chainQueue";N;s:19:"chainCatchCallbacks";N;s:5:"delay";N;s:11:"afterCommit";N;s:10:"middleware";a:0:{}s:7:"chained";a:0:{}}"}}
If I set the queue to redis (and set that up) it works without any issues. I would rather just use database as I only have 5 users accessing the system and the database should be fine handling the work load.
Beta Was this translation helpful? Give feedback.
All reactions