如果您想继续使用database
驱动程序,我建议设置另一个数据库,其中包含所有排队的作业和失败的作业。
虽然它不在配置中或文档中提到,但在查看代码后,看起来您应该能够添加connection
参数到您的队列配置,然后队列将与该连接指定的数据库进行交互。
所以,在你的config/database.php
,为您的队列数据库定义一个新连接:
'connections' => [
// your existing connections
'queue' => [
'driver' => 'mysql',
'database' => 'your-queue-database',
// rest of connection information (host, port, etc)
],
],
然后,在你的config/queue.php
,告诉您的数据库队列使用您的新连接:
'connections' => [
'database' => [
'driver' => 'database',
'connection' => 'queue', // connection name from database config
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 90,
],
]
另一种选择是转移到另一个队列驱动程序。设置 redis、sqs 或 beanstalk。