Use supervisor to monitor the jobs in the queue,
php artisan queue:listen --timeout=0
use
php artisan queue:failed-table
Failed queue records have been established, but the current situation is that failed ones are always executed repeatedly and are not written to failed_job
There is
in laravel documentationphp artisan queue:listen connection-name --tries=3
What does connection-name refer to?
php artisan queue:listen --timeout=0 --tries=3, queue execution error
exception 'Swift_TransportException' with message 'Expected response code 250 but got code "", with message ""'
How to solve these problems?
You can choose from a variety of queue services in laravel, the common ones are redis and beanstalk. Since redis is a simple db, the data is completely transparent, so it will be easier to understand if redis is used as the explanation object here.
The way to start the queue in laravel is the
queue:listen
和queue:work
, 其中queue:work
表示单独运行下一个job. 关于区别请看:queue:listen 和 queue:work --daemon 的区别 。queue:listen
内部也是一次次的调用queue:work
实现的,现在我们来看work
command.In
IlluminateQueueConsoleWorkCommand
中是不是看见了我们熟悉的fire
method? That's it. Keep chasing,Call the
runWork
方式查找job并且执行.这里有一个daemon
option to indicate whether to run as a daemon. Directly consider daemon as false (because daemon is actually a while(true)):joy:.See
runWork
其实是调用的IlluminateQueueWorker::pop
methodArrived at the final execution position of the job (deleted the blank lines and comments, because I am going to write crappy Chinese comments. (Escape):
Well, that’s pretty much it.
The
Swift_TransportException
是发送邮件程序swiftmailer
error you threwIn the connections configuration in config/queue.php, sync, beanstalkd, sqs, etc. are the connection-name.