Docs Menu
Docs Home
/ / /
Laravel MongoDB

Queues

If you want to use MongoDB as your database backend for Laravel Queue, change the driver in config/queue.php:

'connections' => [
'database' => [
'driver' => 'mongodb',
// You can also specify your jobs specific database created on config/database.php
'connection' => 'mongodb',
'collection' => 'jobs',
'queue' => 'default',
'retry_after' => 60,
],
],
Setting
Description
driver
Required. Specifies the queue driver to use. Must be mongodb.
connection
The database connection used to store jobs. It must be a mongodb connection. The driver uses the default connection if a connection is not specified.
collection
Required. Name of the MongoDB collection to store jobs to process.
queue
Required. Name of the queue.
retry_after
Specifies how many seconds the queue connection should wait before retrying a job that is being processed. Defaults to 60.

If you want to use MongoDB to handle failed jobs, change the database in config/queue.php:

'failed' => [
'driver' => 'mongodb',
'database' => 'mongodb',
'collection' => 'failed_jobs',
],
Setting
Description
driver
Required. Specifies the queue driver to use. Must be mongodb.
connection
The database connection used to store jobs. It must be a mongodb connection. The driver uses the default connection if a connection is not specified.
collection
Name of the MongoDB collection to store failed jobs. Defaults to failed_jobs.

Add the service provider in config/app.php:

MongoDB\Laravel\MongoDBQueueServiceProvider::class,

Job batching is a Laravel feature to execute a batch of jobs and subsequent actions before, after, and during the execution of the jobs from the queue.

With MongoDB, you don't have to create any collection before using job batching. The job_batches collection is created automatically to store meta information about your job batches, such as their completion percentage.

'batching' => [
'driver' => 'mongodb',
'database' => 'mongodb',
'collection' => 'job_batches',
],
Setting
Description
driver
Required. Specifies the queue driver to use. Must be mongodb.
connection
The database connection used to store jobs. It must be a mongodb connection. The driver uses the default connection if a connection is not specified.
collection
Name of the MongoDB collection to store job batches. Defaults to job_batches.

Add the service provider in config/app.php:

MongoDB\Laravel\MongoDBBusServiceProvider::class,
← Cache and Locks