Queen can play two separate roles in a Laravel application:
- The
queenqueue connection stores Laravel jobs in Queen instead of Redis or a database table. - The optional Queen supervisor starts, stops and balances ordinary
queue:work queenprocesses.
You can use the queue connection with your existing process manager and add the supervisor later.
Your jobs still implement Laravel’s normal ShouldQueue contract and keep their middleware, retry,
backoff and failed-job events.
Before you start
You need PHP 8.3 or newer, a Laravel application and a reachable Queen broker. If Queen is not running yet, start the local Compose stack first.
The queue driver itself does not require the process-control extensions. The Queen supervisors are
Unix-only today and add pcntl and posix requirements.
Install the queue connection
-
Install the Composer package.
composer require queen-mq/php-client -
Publish the configuration.
php artisan vendor:publish --tag=queen-configPackage discovery registers the service provider, the
Queenfacade and aqueenqueue connection. You do not need to add that connection toconfig/queue.phpunless you want to override it explicitly. -
Point Laravel at Queen.
QUEUE_CONNECTION=queen QUEEN_URL=http://127.0.0.1:6632 QUEEN_QUEUE=default QUEEN_CONSUMER_GROUP=laravel QUEEN_RETRY_AFTER=90 QUEEN_PREFETCH=1 QUEEN_ACK_BATCH=1Add
QUEEN_BEARER_TOKENwhen the broker requires authentication. Keep secrets outside source control. Give each logical application and environment a stable consumer-group name: two applications sharing one group intentionally share one cursor and split the work. -
Dispatch an existing job. Nothing changes at the call site.
use App\Jobs\GenerateInvoice; GenerateInvoice::dispatch($invoiceId); -
Run one worker.
php artisan queue:work queen --queue=default --timeout=60 --tries=3QUEEN_RETRY_AFTERis the lease duration. It must be longer than the worker timeout and the longest job runtime. Stop this first worker with the same signal you use for any Laravel worker.
At this point the integration works without either Queen supervisor. Keep your current systemd, Kubernetes, Supervisor or platform process definition if all you need is a fixed worker count.
Start with the safe delivery profile
The default prefetch=1 and ack_batch=1 preserve one synchronous acknowledgement boundary per
job. Use this profile while validating a migration and whenever every job, including safety margin,
fits inside retry_after.
Values above one reduce broker round trips, but they widen the at-least-once redelivery window. A
Laravel worker may also pause while it still owns a prefetched tail. The Queen connector therefore
rejects prefetch > 1 unless lease renewal is enabled, whether workers are started by Queen or by
another process manager.
QUEEN_PREFETCH=4
QUEEN_ACK_BATCH=1
QUEEN_LEASE_RENEWAL=trueEnable lease renewal even with prefetch=1 when the longest runtime cannot be bounded safely. Lease
renewal starts a small PHP helper beside each worker. It extends the active lease and fences the
worker if renewal can no longer finish safely. An exact-PID SIGCHLD watchdog also kills the
owning worker if that helper disappears while a lease is active. This Unix CLI path requires
PCNTL/POSIX support, and application code must not replace Queen’s signal handler. Renewal cannot
make external side effects exactly once, so jobs must remain idempotent.
What changes from another Laravel connection
| Area | What stays the same | What changes with Queen |
|---|---|---|
| Job code | ShouldQueue, dispatch(), middleware, timeout, tries and backoff |
Storage and delivery use Queen leases and consumer groups |
| Delays | Laravel delayed dispatch and positive backoff | Queen timers store the delay |
| Failures | Laravel’s failed-job commands remain the command index | Queen also retains a synchronized DLQ snapshot by default |
| Ordering | Laravel queue names | Implement QueenPartitionable when one entity needs its own FIFO lane |
| Delivery | At-least-once | A lease expiry or worker crash can redeliver a job |
| Clearing | Connection-specific | Queen does not yet provide one atomic clear across ready jobs, live leases and Laravel timers |
Choose how workers are managed
| Choice | Use it when | Master process |
|---|---|---|
| Existing process manager | You want a fixed number of queue:work processes |
Whatever you already operate |
| Queen PHP | You want Horizon-like local pools with no native artifact | Laravel remains loaded in one PHP master |
| Queen Rust | You want the smallest control plane and crash-loop circuit breaking | Rust, after one temporary Artisan configuration load |
The PHP and Rust engines read the same configuration and publish the same state protocol. Begin with Worker supervisors, then enable the Laravel dashboard only after authentication is in place.
Worker supervisors
Configure pools, autoscaling, the PHP fallback and the optimized Rust engine.
Supervisor dashboard
Enable the local panel, authorize it and understand what it deliberately does not expose.
Migrate from Horizon
Map the configuration, canary Queen, drain Redis and keep a rollback boundary.
Queen or Horizon
A direct comparison, including the places where Horizon remains the better choice.