Feature/599 - Add a database Queue driver #897
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #599
Documentation
Install from this branch
First you will need to create the migration for your queue jobs:
If you want to have a table where failed jobs will be stored, you can create a migration for that table as well. If this table does not exist, any failed jobs will simply stay failed.
Change the database configuration to use the
database
driver:Or you can leave the queue driver as is and specify the driver directly with the
Queue
class:Waiting
With the database driver, you have the ability to use the
wait
keyword. To queue a job to run 10 minutes from now you can do something like:Running the worker
The database driver, like the amqp driver, requires a worker to be running. You can run the worker by using the
queue:work
command:This will start a worker that will poll the database for new jobs every 5 seconds. Once new jobs are found it will run them all and then continue waiting for new jobs. If any jobs fail they will run 3 more times. If the job still fails it will be added to the
failed_jobs
if one exists. If one does not exist it will stay failed inside thequeue_jobs
table.You can still run failed jobs by running