Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Queue Laravel Package

enqueue/laravel-queue

Integrates Laravel’s queue system with Enqueue, providing a transport-agnostic queue driver for sending and consuming jobs through brokers such as AMQP, Redis, and others. Useful for apps already using Enqueue or needing flexible message transports.

View on GitHub
Deep Wiki
Context7

Getting Started

1. Install the bridge and a transport. The bridge alone does nothing — you must also require the Enqueue transport for the broker you actually use. Pick the DSN scheme first, then match it:

composer require enqueue/laravel-queue
composer require enqueue/amqp-lib      # amqp://  (RabbitMQ via php-amqplib)
# or: enqueue/redis, enqueue/sqs, enqueue/stomp, enqueue/kafka, enqueue/fs, enqueue/null

Check the package's composer.json for the Laravel version constraint before upgrading — releases are infrequent (last 2025-04-07), so pin your Laravel and enqueue/* versions together.

2. Publish the config. Laravel 5.5+ auto-discovers the service providers; if you're on an older setup, register Enqueue\LaravelQueue\EnqueueServiceProvider and Enqueue\LaravelQueue\EnqueueQueueServiceProvider in config/app.php.

php artisan vendor:publish --provider="Enqueue\LaravelQueue\EnqueueServiceProvider"

This writes config/enqueue.php, which holds a default transport plus a transports map keyed by DSN:

// config/enqueue.php
'default' => env('ENQUEUE_CONNECTION', 'default'),
'transports' => [
    'default' => ['dsn' => env('ENQUEUE_DSN', 'file://'.storage_path('enqueue'))],
],

3. Add a queue connection. In config/queue.php:

'enqueue' => [
    'driver'     => 'enqueue',
    'connection' => 'default',   // key into config/enqueue.php transports
    'queue'      => 'default',
],

4. Point Laravel at it with QUEUE_CONNECTION=enqueue and ENQUEUE_DSN=amqp://guest:guest@rabbitmq:5672/%2f.

First use case — move existing jobs off Redis/DB without touching job code. Anything already implementing ShouldQueue and dispatched via dispatch() now flows through Enqueue untouched. Start with the file:// DSN locally (no broker required), watch storage/enqueue fill up, then flip ENQUEUE_DSN to your broker. Run php artisan queue:work enqueue --queue=default --sleep=1 and confirm a trivially dispatched job is consumed. Inspect the broker side (RabbitMQ management UI, redis-cli LLEN, or the SQS console) — not Laravel — when nothing shows up.

Implementation Patterns

  • Keep the Laravel contract, swap the transport. dispatch(), dispatchSync(), Bus::chain(), Bus::batch(), onQueue(), onConnection(), delay() all work because the driver implements Laravel's Queue contract. The only real change is configuration and broker operations.
  • One connection per broker/cluster. Register several entries in config/enqueue.php transports and several config/queue.php connections ('rabbit', 'sqs', 'staging') each pointing at a different connection. Route per job with ->onConnection('sqs') or globally with QUEUE_CONNECTION.
  • Queue-based routing. ->onQueue('emails') maps to an Enqueue topic/queue name. On RabbitMQ this auto-declares with default options; on SQS the queue must already exist. Keep a small provisioning step (Terraform, an artisan command, or RabbitMQ policy) so workers and producers agree on names and durability.
  • Cross-language producers/consumers. Use pushRaw() to put a plain JSON payload on a queue that non-PHP services consume, and read it in Laravel via Job::getRawBody(). Conversely, if another service needs to produce work for Laravel, it must produce Laravel's serialized job payload — usually not worth it; prefer pushRaw + a thin handler that re-dispatches typed jobs.
  • Delayed dispatch uses ->delay($ttl) and maps to the transport's native delay where available. For anything more complex than a few minutes, schedule in a database/cron and dispatch immediately.
  • Batches and chains ride on Laravel's serialized payload, so they work as long as the driver returns a proper Job instance. Test a chained batch early — this is the place where thin bridges tend to leak.
  • Workers. Standard queue:work enqueue --queue=high,default --tries=3 --timeout=60 under Supervisor. Size worker count to the broker's prefetch/concurrency settings, not to PHP-FPM's.
  • Testing. Use QUEUE_CONNECTION=sync for unit tests that assert dispatch happened; use the file:// transport or a dedicated staging broker for integration tests. Don't point tests at a shared broker you don't control.
  • Advanced transport config. When the DSN isn't enough (TLS, IAM role chains for SQS, AMQP heartbeats), bind a preconfigured Interop\Queue\Context (or the package's connection factory) into the container in a service provider instead of fighting the config array.

Gotchas and Tips

  • The bridge ships no transports. The most common "it doesn't work" is composer require enqueue/laravel-queue alone — you'll get a class-not-found or "no connection factory for scheme" error. Install the matching enqueue/* transport package.
  • Horizon is not usable. Laravel Horizon is hard-wired to Illuminate\Queue\RedisQueue internals; enqueue/redis gives you a valid Redis driver but not Horizon's UI/metrics/balancing. If you need Horizon, stay on the native Redis driver.
  • pop() is pull-based. If the transport returns null immediately, queue:work without --sleep becomes a hot loop hammering the broker. Always pass --sleep=1 (or more) and set block_for-style options in the transport config where supported.
  • Delayed jobs are transport-dependent. SQS caps delay at ~15 minutes; classic AMQP queues have no native per-message delay without a plugin. Don't design a 24-hour ->delay() and assume it works everywhere — verify per transport before shipping.
  • Ack/requeue semantics diverge from Redis. $job->release() maps to a reject/requeue on the broker, and Laravel's --tries counter lives in the payload while the broker tracks its own delivery count. These two counters can disagree, producing infinite redelivery or premature dead-lettering. Tune visibility timeout / prefetch together with --timeout and --tries.
  • Failed-job tracking is the first thing to test. Confirm $job->fail() actually writes to failed_jobs and that queue:failed, queue:retry, queue:forget behave. Failures on a transport the bridge doesn't fully implement can vanish silently.
  • Payload size limits. SQS rejects >256 KB, AMQP has frame limits. A fat serialized job (models, file blobs) fails at push time. Store bulky data in the DB/S3 and pass IDs.
  • Serialization is PHP. Default Laravel payloads are PHP-serialized — other languages can't consume them. Use pushRaw + JSON when interop matters.
  • Queue names must exist on some brokers. SQS and some Kafka setups require pre-existing queues/topics; RabbitMQ will auto-declare but with defaults (often non-durable) unless you configure it explicitly in the broker or via a connection option.
  • Config caching and long-lived workers. php artisan config:cache bakes the DSN in at boot; Context/connection objects are created once per worker. After changing the broker or credentials, restart workers. Run with Supervisor --max-time to force reconnects for AMQP and SQS.
  • Debugging recipe: reproduce with a raw Enqueue client (SimpleClient or a small Context::createProducer() script) against the same DSN — that isolates "bridge config wrong" from "broker/network wrong". Then check broker metrics/logs and storage/logs/laravel.log for failed-job and exception traces.
  • Extension points to lean on: rebind the package's connection factory or Interop\Queue\Context in your own service provider for transport-specific options; register a custom queue connection driver if you need to wrap the driver; and keep the config/enqueue.php transports map small and documented per environment.
  • Pin the Enqueue ecosystem. queue-interop / enqueue/* have had breaking interop versions; an unpinned composer update that bumps a transport can break the bridge. Use composer.lock and update the bridge and transports together.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core