Deploy with Redis and SQS
Use the Redis SQS lane for Redis or Valkey storage and native SQS workers and Lambda handlers.
Use redisSqsLane() when Redis or Valkey stores your runs and SQS should wake Lambda functions or long-running consumers. Redis holds run state and the outbox; an SQS message carries only a wakeup.
Prepare storage and queues
Use Node.js 22.18 or later, a Redis primary deployment, and an existing SQS queue. Redis supports standalone, Sentinel, and Cluster; each namespace uses one primary. Configure noeviction and review startup checks, durability, and deployment requirements.
Set REDIS_URL, RUNLANE_SQS_QUEUE_URL, and the AWS region and credentials before loading the runtime. Give the producer permission to send messages and the consumer permission to receive, renew visibility, and delete them. For Lambda, bind the physical SQS queue to the function's event source.
Install the packages
npm install @aws-sdk/client-sqs @runlane/core @runlane/lane-redis-sqs @runlane/transport-sqs zodCreate one runtime module
Reuse the task module as src/tasks/count-items.ts. The lane keeps Redis and SQS settings in their own provider envelopes and preserves the native SQS Lambda handler type.
import { SQSClient } from '@aws-sdk/client-sqs'
import { createRunlane, RunRetention, queue } from '@runlane/core'
import { redisSqsLane } from '@runlane/lane-redis-sqs'
import { sqsQueue } from '@runlane/transport-sqs'
import * as z from 'zod'
import { countItems } from './tasks/count-items.js'
const env = z.object({ REDIS_URL: z.url(), RUNLANE_SQS_QUEUE_URL: z.url() }).parse(process.env)
export const jobs = queue({ name: 'jobs', default: true })
export const sqsClient = new SQSClient({})
export const runlane = createRunlane({
retention: {
succeeded: RunRetention.deleteAfter('7d'),
cancelled: RunRetention.deleteAfter('7d'),
failed: RunRetention.deleteAfter('30d'),
expired: RunRetention.deleteAfter('7d'),
},
lane: redisSqsLane({
redis: { url: env.REDIS_URL, namespace: 'billing-jobs' },
sqs: {
client: sqsClient,
queues: [sqsQueue(jobs, { queueUrl: env.RUNLANE_SQS_QUEUE_URL })],
},
runHints: false,
}),
queues: [jobs],
tasks: { countItems },
})redis accepts the same standalone, Sentinel, Cluster, or borrowed-client options as Redis storage. sqs accepts the SQS provider's options, including queue bindings and polling settings. Providers validate their own settings. See Redis SQS lane options.
runHints defaults to contractDefaults.realtime.runHints, as on the Postgres SQS lane. The example disables it for Lambda. Leave it enabled on long-running processes that need prompt run-progress updates. Readers keep polling when hints are disabled or missed. SQS delivers work, so the lane forces storage workHints: false and rejects that option at the top level or inside redis.
The lane owns its storage driver and transport lifecycle. The application owns sqsClient; destroy it after closing the runtime when a long-running process exits. Keep warm Lambda clients open between invocations.
Custom combinations can still use createLane() from @runlane/contracts with the raw storage and transport providers.
Handle Lambda deliveries
import { runlane } from '../runlane.js'
export const handler = runlane.createDeliveryHandler()The returned handler accepts SQS Lambda events and returns the native partial-batch response. Set the event source to report batch item failures. Keep the runtime outside the handler so warm invocations reuse it.
For a long-running consumer, use the Redis worker entry point, then destroy sqsClient after runtime shutdown. Worker concurrency limits local parallel deliveries; queue concurrency remains a shared storage limit.
Run maintenance
import { runlane } from '../runlane.js'
export const handler = runlane.createMaintenanceHandler()Invoke this handler on a recurring schedule. Keep outbox publishing and delivery recovery enabled, along with schedules and waits. A long-running consumer may run maintenance with start({ maintenance: true }) instead.
Due times mark eligibility, not a guaranteed handler start. Redis checks due-ness using its sampled server time. Standard SQS rounds future message delays up to whole seconds; FIFO publication waits until due. Delivery, maintenance, queue admission, and worker capacity can add latency. See SQS delayed-run timing for the shared transport behavior.
Storage startup manages its format marker; there is no Redis migration CLI. SQS queue creation and Lambda event-source bindings belong to your deployment.
Receipt renewal runs every third of the visibility duration, measured from request send times so reply latency does not move the retry cadence. A connection error is recorded and retried without immediately aborting delivery. The local safety deadline is the last confirmed acquisition or renewal’s monotonic send time, plus visibility duration, minus one renewal interval. Proven ownership loss stops delivery immediately; continued failures stop it after that deadline. A renewal sent by the deadline can confirm ownership when its reply arrives later. It must confirm before the hard bound: the last confirmed send plus the full visibility duration. At that bound, Runlane gives up even if the request is still in flight. A late success cannot restore ownership.
Check the deployment
Trigger countItems with two items and confirm stored output 2. Test a duplicate SQS delivery, an interrupted worker, and an outbox publish failure. Confirm later maintenance restores progress.
Use the SQS capacity guidance for broker and Lambda controls, sizing Redis capacity in place of PostgreSQL connections. See run maintenance and make side effects safe to repeat.
SQS Lambda consumers use the same recursive loop policy and maintenance cadence as Postgres/SQS.