4

Queue driver is set to use Redis

QUEUE_DRIVER=redis

With

php /opt/artisan queue:work --tries=1 --queue="data-ingestion-default" --daemon

The error, we receive is

[2016-09-14 08:32:40] lumen.ERROR: InvalidArgumentException: Database 
[mysql] not 
configured. in /opt/vendor/illuminate/database/DatabaseManager.php:239
Stack trace:
#0 /opt/vendor/illuminate/database/DatabaseManager.php(158):     
Illuminate\Database\DatabaseManager->getConfig('mysql')
#1 /opt/vendor/illuminate/database/DatabaseManager.php(68):   
Illuminate\Database\DatabaseManager->makeConnection('mysql')
#2 /opt/vendor/illuminate/queue/Failed/DatabaseFailedJobProvider.php(110): 
Illuminate\Database\DatabaseManager->connection('mysql')
#3 /opt/vendor/illuminate/queue/Failed/DatabaseFailedJobProvider.php(58):    
Illuminate\Queue\Failed\DatabaseFailedJobProvider->getTable()
#4 /opt/vendor/illuminate/queue/Worker.php(313): 
Illuminate\Queue\Failed\DatabaseFailedJobProvider->log('redis', 'data-ingestion-...',    
'{"job":"Illumin...')
#5 /opt/vendor/illuminate/queue/Worker.php(204): Illuminate\Queue\Worker-
>logFailedJob('redis', Object(Illuminate\Queue\Jobs\RedisJob))
#6 /opt/vendor/illuminate/queue/Worker.php(156): Illuminate\Queue\Worker->process('redis',   
Object(Illuminate\Queue\Jobs\RedisJob), '1', 0)
#7 /opt/vendor/illuminate/queue/Worker.php(111): Illuminate\Queue\Worker->pop(NULL, 'data-   
ingestion-...', 0, 3, '1')
#8 /opt/vendor/illuminate/queue/Worker.php(85): Illuminate\Queue\Worker-
>runNextJobForDaemon(NULL, 'data-ingestion-...', 0, 3, '1')
#9 /opt/vendor/illuminate/queue/Console/WorkCommand.php(119): Illuminate\Queue\Worker-
>daemon(NULL, 'data-ingestion-...', 0, 128, 3, '1')
#10 /opt/vendor/illuminate/queue/Console/WorkCommand.php(78): 
Illuminate\Queue\Console\WorkCommand->runWorker(NULL, 'data-ingestion-...', 0, 128, true)

It appears that the error is due to the Worker attempting to log the failed job to a mysql database.

However, we are not using MySQL in this instance, and if we were in config/database.php there is no 'mysql' in connection, and the default db is called 'development'.

Cristik
  • 30,989
  • 25
  • 91
  • 127
64k
  • 239
  • 4
  • 12

2 Answers2

5

In config/queue.php take a look at failed config the default is:

'failed' => [
        'database' => env('DB_CONNECTION', 'mysql'),
        'table'    => 'failed_jobs',
    ],

change it to use redis

you can see the whole config file in the github reop laravel/config/queue.php

edit: anyone reading this, this answer is not correct sorry, I cant delete accepted answer

Amir Bar
  • 3,007
  • 2
  • 29
  • 47
  • Please could you provide the content of the whole file, as config/queue.php does not exist on lumen. With the above no jobs are ran at all. Thank you – 64k Sep 14 '16 at 11:26
  • 1
    resolved, after adding the full queue.php, an example of which can be found here https://github.com/GetStream/stream-laravel-5-example/blob/master/config/queue.php – 64k Sep 15 '16 at 16:07
  • 3
    There is only database failed job provider with laravel queue package. All this answer does is log the failed jobs onto mysql failed jobs table. This answer is not a solution to logging your failed jobs onto redis. I dont know why this is the accepted answer. Good luck sorting it out! – f_i Aug 02 '18 at 12:28
  • 1
    @FaizKhan Agreed, this is not an answer. I have marked this down, and I have no idea how it got so many upvotes in the first place. – Inigo Nov 16 '18 at 12:28
  • this is not an answer to this question its the same config file that exists in laravel – Salar Bahador Mar 05 '19 at 14:25
4

you can not do it with redis driver. However, if you use Laravel Horizon, Horizon will automatically save your failed jobs in Redis

Michael Nguyen
  • 1,691
  • 2
  • 18
  • 33
  • Why not with Redis? – rhand Mar 28 '19 at 08:39
  • 1
    laravel does not support that feature – Michael Nguyen Mar 28 '19 at 17:00
  • Laravel prefers failed jobs table in a RDMS database it seems yes - https://laravel.com/docs/5.6/queues#dealing-with-failed-jobs . And perhaps because Redis is more ephemeral than let's say MySQL. However, Redis does do data retention as well https://redis.io/topics/persistence . As I am not a Redis Pro and only know MySQL/MariaDB reasonably well I will go with the built in option as well. – rhand Mar 29 '19 at 01:09