Laravel queue with multiple databases

I have a Laravel 5 project. This is a project with several tenants, so I have one project with several databases.

When I use it php artisan queue:listen, it only works with the current database setup. I use the queue driver database, so each tenant has their own notification table. How to configure a queue listener to check all database jobs?

+4
source share
1 answer

If you want to continue using the driver database, I would suggest setting up another database containing all your jobs in the queue and failed jobs.

, , , , 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.

+4

Source: https://habr.com/ru/post/1664809/


All Articles