Im struggling to configure the queue connection in lumen 8 project, im my database.php i have 2 connections lets say A and B, A to connect to DB_A and B for DB_B.
my database.php looks like this :
// database.php
'connections' => [
'connection_A' => array(
'driver' => env('DB_A',''),
'host' => env('DB_A_HOST',''),
'port' => env('DB_A_PORT',''),
'database' => env('DB_A_DATABASE',''),
'username' => env('DB_A_USERNAME',''),
'password' => env('DB_A_PASSWORD',''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
),
'connection_B' => array(
'driver' => env('DB_B',''),
'host' => env('DB_B_HOST',''),
'port' => env('DB_B_PORT',''),
'database' => env('DB_B_DATABASE',''),
'username' => env('DB_B_USERNAME',''),
'password' => env('DB_B_PASSWORD',''),
'charset' => 'utf8',
'prefix' => '',
'schema' => env('DB_B_SCHEMA'),
),
i use the connection A to fetch some data from DB_A and run a job using database driver on DB_B so my tables jobs,failed_jobs are both in DB_B
i configured my queue.php like this
// queue.php
'connections' => [
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 90,
'connection' => 'connection_B', // not working => table jobs not found
'database' => 'connection_B', // not working => table jobs not found
],
],
'failed' => [
'driver' => 'database',
'database' => 'connection_B', // works for some reason
'table' => 'failed_jobs',
],
so my question is how to tell the the queue what database connection to use ?
i tried to force the connection before dispatching the job like this :
Config::set('database.connections.connection_B.database', env('DB_B_DATABASE'));
Config::set('database.connections.connection_B.schema', env('DB_B_SCHEMA'));
DB::purge('connection_B');
DB::reconnect('connection_B');
and i also tried to set the queue connection like this :
$connection = Queue::connection('connection_B');
$connection->pushOn('my_queue', $job);
i get an exception
No connector for []. {"exception":"[object] (InvalidArgumentException(code: 0): No connector for [].
am i missing or misunderstanding something ?
ps : in my app.php i load the queue.php and database.php.
$app->configure('app');
$app->configure('database');
$app->configure('queue');
and i dispatch my job like this :
$jobId = Queue::push((new CreatePdfJob($datas)),null,'my-queue');
Thank you for your help.