Laravel TutorialChange default routing behaviour in Laravel 5.2.31 +CustomException class in LaravelDeploy Laravel 5 App on Shared Hosting on Linux ServerLaravel ArtisanLaravel AuthenticationLaravel AuthorizationLaravel Blade TemplatesLaravel CashierLaravel CollectionsLaravel Common Issues & Quick FixesLaravel ConstantsLaravel ControllersLaravel Cron basicsLaravel Cross Domain RequestLaravel Custom Helper functionLaravel DatabaseLaravel Database MigrationsLaravel Database SeedingLaravel Directory StructureLaravel DockerLaravel EloquentLaravel Eloquent : RelationshipLaravel Eloquent: Accessors & MutatorsLaravel Eloquent: ModelLaravel Error HandlingLaravel Events and ListenersLaravel Filesystem / Cloud StorageLaravel Form Request(s)Laravel Getting started with laravel-5.3Laravel HelpersLaravel HTML and Form BuilderLaravel InstallationLaravel Installation GuideLaravel Introduction to laravel-5.2Laravel Introduction to laravel-5.3Laravel lumen frameworkLaravel Macros in Eloquent RelationshipLaravel MailLaravel MiddlewareLaravel ObserverLaravel PackagesLaravel PaginationLaravel Permissions for storageLaravel PoliciesLaravel QueuesLaravel RequestsLaravel Route Model BindingLaravel RoutingLaravel SeedingLaravel ServicesLaravel SocialiteLaravel Task SchedulingLaravel TestingLaravel Token Mismatch Error in AJAXLaravel use fields aliases in EloquentLaravel Useful linksLaravel ValetLaravel ValidationMultiple DB Connections in LaravelNaming Files when uploading with Laravel on WindowsRemove public from URL in laravelSparkpost integration with Laravel 5.4

Laravel Queues

From WikiOD

Queues allow your application to reserve bits of work that are time consuming to be handled by a background process.

Use-cases[edit | edit source]

For example, if you are sending an email to a customer after starting a task, it's best to immediately redirect the user to the next page while queuing the email to be sent in the background. This will speed up the load time for the next page, since sending an email can sometimes take several seconds or longer.

Another example would be updating an inventory system after a customer checks out with their order. Rather than waiting for the API calls to complete, which may take several seconds, you can immediately redirect user to the checkout success page while queuing the API calls to happen in the background.

Queue Driver Configuration[edit | edit source]

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.

Out of the box, Laravel supports the following queue drivers:

sync[edit | edit source]

Sync, or synchronous, is the default queue driver which runs a queued job within your existing process. With this driver enabled, you effectively have no queue as the queued job runs immediately. This is useful for local or testing purposes, but clearly not recommended for production as it removes the performance benefit from setting up your queue.

database[edit | edit source]

This driver stores queued jobs in the database. Before enabling this driver, you will need to create database tables to store your queued and failed jobs:

php artisan queue:table
php artisan migrate

sqs[edit | edit source]

This queue driver uses Amazon's Simple Queue Service to manage queued jobs. Before enabling this job you must install the following composer package: aws/aws-sdk-php ~3.0

Also note that if you plan to use delays for queued jobs, Amazon SQS only supports a maximum delay of 15 minutes.

iron[edit | edit source]

This queue drivers uses Iron to manage queued jobs.

redis[edit | edit source]

This queue driver uses an instance of Redis to manage queued jobs. Before using this queue driver, you will need to configure a copy of Redis and install the following composer dependency: predis/predis ~1.0

beanstalkd[edit | edit source]

This queue driver uses an instance of Beanstalk to manage queued jobs. Before using this queue driver, you will need to configure a copy of Beanstalk and install the following composer dependency: pda/pheanstalk ~3.0

null[edit | edit source]

Specifying null as your queue driver will discard any queued jobs.