Skip to main content
Live. This area is documented as current, user-reliable behavior.

Goal

Move a Laravel app’s queue onto StackShift Queues without changing job code.

Prerequisites

  • A Laravel app
  • A queue with a Pull consumer
  • An API key that can send to the queue
  • The queue accepts text messages

Workflow

1
Install the PHP SDK with composer require stackshift/assets. Laravel discovers its queue service provider on its own.
2
Add a stackshift connection to config/queue.php.
3
Set QUEUE_CONNECTION=stackshift and STACKSHIFT_QUEUE_TOKEN in your environment.
4
Dispatch jobs as before and run php artisan queue:work stackshift.

Install

config/queue.php

  • token: an API key that can send to and pull from the queue. Without it the driver uses STACKSHIFT_QUEUE_TOKEN, then STACKSHIFT_API_KEY. A pull token (sqt_) is enough for a worker that never dispatches.
  • queue: the queue name, or its id or <project_id>:<name> when the name is in more than one project.
  • retry_after: the visibility timeout, in seconds, for each pulled job. Set it longer than your slowest job.
  • after_commit: Laravel’s usual option to dispatch only after the database transaction commits.
connections

.env

Jobs and workers

  • dispatch() sends one text message carrying Laravel’s job payload. The worker pulls one message at a time, runs the job and acks it.
  • delay() and later() send the message with that delay. release($seconds) inside a job, or a failed attempt, retries the message with that delay. The longest delay is 24 hours.
  • attempts() is the message attempts count, which includes the current delivery, so a first run shows 1.
  • Dead letters follow the queue consumer’s max retries and dead-letter queue. Keep the job’s $tries at or below max retries plus one.
  • While delivery is paused, queue:work finds no jobs and waits.
  • Run the worker as a worker service in your StackShift project, or anywhere that can reach the API.

Expected result

Jobs dispatched by the app appear on the queue, and the worker takes them off and runs them.

Common failures

  • queue:work sits idle: the queue is paused, and a paused queue gives the worker no jobs. Resume it.
  • Sends are refused with a pull token: a pull token can only pull and ack. Use an API key in apps that dispatch.
  • later() or delay() over 24 hours throws InvalidArgumentException: 24 hours is the longest delay.
  • Jobs go to the dead-letter queue before Laravel gives up, or Laravel fails them first: keep the job’s $tries at or below the consumer’s max retries plus one (max_retries 3 allows 4 tries).

Pull consumers

A worker anywhere pulls a batch over HTTP, leases the messages for a visibility timeout, then acks or retries each one by lease id.

Batching, retries and delays

How batch size and wait, retries, retry delays, concurrency and delivery guarantees work.

Limits and error codes

Sizes, rates, retention and the error codes the Queues API returns when a limit is reached.