Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you set up the database Queue driver for Laravel 5?

I am building an application with Laravel that receives notifications and then fires events to handle those notifications. I want these events to be Queued so that only one event is handled at a time.

I've been trying to use the "database" Queue driver that the documentation says is available. I've changed the default driver in config/queue.php so it is set to use "database" and I ran php artisan queue:table to create the jobs migration but when I send a notification to the app I do not see any sign of queues being used in the jobs table or anywhere else. What could be going wrong?

(My EventHandler class is using ShouldBeQueued as well)

like image 242
erichie Avatar asked May 14 '15 19:05

erichie


People also ask

How do I know if my Laravel queue is working?

Show activity on this post. This is lower level but in the same vein you could run a command such as ps -aux | grep queue to literally view the running queue processes on whatever server your application/queue workers are running on.

What is queue driver in Laravel?

Laravel Queues Queue Driver Configuration A queue driver is the handler for managing how to run a queued job, identifying whether the jobs succeeded or failed, and trying the job again if configured to do so.

How does queue work in Laravel?

Laravel queues provide a unified API across a variety of different queue backends, such as Beanstalk, Amazon SQS, Redis, or even a relational database. Queues allow you to defer the processing of a time consuming task, such as sending an email, until a later time.

Which of the following can be used to drive Laravel queue?

Laravel allows the facility to configure queues with several drivers like database, Beanstalkd, Redis, Amazon, IronMQ, etc. Drives are used to store the list of tasks. The selection of the drives is based on the weight of your task list.

How to configure queue driver in Laravel?

Each of Laravel's queue drivers are configured from the config/queue.php file. A queue driver is the handler for managing how to run a queued job, identifying whether the jobs succeeded or failed, and trying the job again if configured to do so.

How do I configure Laravel to support multiple databases?

Currently, Laravel provides first-party support for five databases: The configuration for Laravel's database services is located in your application's config/database.php configuration file. In this file, you may define all of your database connections, as well as specify which connection should be used by default.

What is database_url in Laravel?

For convenience, Laravel supports these URLs as an alternative to configuring your database with multiple configuration options. If the url (or corresponding DATABASE_URL environment variable) configuration option is present, it will be used to extract the database connection and credential information.

What is queuing in Laravel?

The main idea of queuing long-running tasks is to be able to execute them in some background process so your main application thread won't block and you can serve your client requests more quickly. For further information on different drivers and help please visit Laravel docs


1 Answers

In your .env file, you have to add this.

QUEUE_DRIVER=database
like image 69
Hrishikesh Mishra Avatar answered Oct 19 '22 18:10

Hrishikesh Mishra