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

Goal

Run your own worker process that takes messages off a queue.

Prerequisites

  • A queue with a Pull consumer
  • A pull token for the queue, or an API key

Workflow

1
Set the queue’s consumer to Pull.
2
On the queue page, open Tokens and create a pull token. It is shown once; store it as a secret.
3
Run a loop that pulls a batch, works on each message, and acks or retries it.
4
Ack before the visibility timeout ends, or the message becomes visible again for another worker.

Pull tokens

  • A pull token starts with sqt_ and can only pull and ack messages on its own queue. Use it as the API key in any SDK or as a Bearer token.
  • Create, list and delete tokens on the queue page or with GET, POST /queues/{queue}/tokens and DELETE /queues/{queue}/tokens/{id}. POST returns the token once.

Pull and ack over HTTP

  • batch_size is up to 100. visibility_timeout_ms is up to 43,200,000 (12 hours).
  • Each pulled message carries a lease_id. Ack or retry by lease id, not message id.
  • An ack that arrives after the visibility timeout is still accepted.
  • Pull returns at once, with an empty list when nothing is ready. Wait a moment before pulling again.
  • stackshift queues tail QUEUE prints messages as they arrive and only reads: it never leases a message or changes its attempts. With —ack it consumes instead, pulling and acking what it prints.
Pull, then ack

Worker loop

Workers in a StackShift project

Run the loop as a worker service in the same project and give it the pull token as an environment variable. It scales like any other worker; more replicas pull more batches in parallel.

Expected result

Your worker drains the queue; the queue page shows the out rate and the last time each token was used.

Common failures

  • 409 queue_delivery_paused: delivery is paused. Wait and pull again, or resume the queue.
  • Messages are handled twice: the work took longer than the visibility timeout. Raise visibility_timeout_ms (up to 12 hours) or use smaller batches.
  • A pull token is refused on another queue: pull tokens only work on the queue they were made for.

Batching, retries and delays

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

Laravel queue driver

Use StackShift Queues as a Laravel queue connection. dispatch() and php artisan queue:work keep working as they are.

Limits and error codes

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