{"id":29029326,"url":"https://github.com/upstash/queue","last_synced_at":"2026-02-25T08:33:11.463Z","repository":{"id":223920576,"uuid":"736896477","full_name":"upstash/queue","owner":"upstash","description":"SQS like stream based queue on top of Redis","archived":false,"fork":false,"pushed_at":"2025-01-11T07:38:43.000Z","size":297,"stargazers_count":85,"open_issues_count":2,"forks_count":4,"subscribers_count":8,"default_branch":"master","last_synced_at":"2026-01-29T20:15:58.429Z","etag":null,"topics":["queue","upstash","upstash-redis","upstash-sdk"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/upstash.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-29T07:30:01.000Z","updated_at":"2026-01-29T17:07:38.000Z","dependencies_parsed_at":"2024-03-06T11:31:08.029Z","dependency_job_id":"31261921-57e4-48a4-b59d-7d799092cfdf","html_url":"https://github.com/upstash/queue","commit_stats":null,"previous_names":["upstash/sqs","upstash/queue"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/upstash/queue","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upstash%2Fqueue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upstash%2Fqueue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upstash%2Fqueue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upstash%2Fqueue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/upstash","download_url":"https://codeload.github.com/upstash/queue/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upstash%2Fqueue/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29815022,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T05:36:42.804Z","status":"ssl_error","status_checked_at":"2026-02-25T05:36:31.934Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["queue","upstash","upstash-redis","upstash-sdk"],"created_at":"2025-06-26T08:06:48.123Z","updated_at":"2026-02-25T08:33:11.445Z","avatar_url":"https://github.com/upstash.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Upstash Queue \n\u0026middot; ![license](https://img.shields.io/npm/l/%40upstash%2Fqueue) [![Tests](https://github.com/upstash/queue/actions/workflows/tests.yaml/badge.svg)](https://github.com/upstash/queue/actions/workflows/tests.yaml) ![npm (scoped)](https://img.shields.io/npm/v/@upstash/queue) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@upstash/queue) ![npm weekly download](https://img.shields.io/npm/dw/%40upstash%2Fqueue)\n\n\n\u003e [!NOTE]  \n\u003e **This project is a Community Project.**\n\u003e\n\u003e The project is maintained and supported by the community. Upstash may contribute but does not officially support or assume responsibility for it.\n\n\n\nA simple, fast, robust, stream-based message queue for Node.js, backed by Upstash Redis, inspired by AWS SQS.\n\n- Simple: ~350 LOC, and single dependency.\n- Lightweight: Under ~5kb zipped.\n- Fast: Maximizes throughput by minimizing Redis and network overhead. Benchmarks well.\n- Robust: Designed with concurrency and failure in mind; full code coverage.\n\n```ts\nimport { Redis } from \"@upstash/redis\";\nimport { Queue } from \"@upstash/queue\";\n\nconst queue = new Queue({ redis: new Redis() });\n\nawait queue.sendMessage({ hello: \"world1\" });\n\nconst message1 = await queue.receiveMessage\u003c{ hello: \"world1\" }\u003e();\nexpect(message1?.body).toEqual({ hello: \"world1\" });\n```\n\n## Introduction\n\n`@upstash/queue` is a Node.js library that provides a simple and efficient way to implement a message queue system using Redis streams. It offers features such as message sending, receiving, automatic message verification, and concurrency control. This library is particularly useful for building distributed systems and background job processing.\n\n## Why Upstash Queue?\n\nUpstash Queue brings the simplicity and performance of Redis streams to Node.js developers, making it easy to integrate a robust message queue system into their applications. Whether you're working on distributed systems, background job processing, or other asynchronous workflows, Upstash Queue provides essential features such as message sending, receiving, automatic verification, and concurrency control.\n\n**Key Features:**\n\n- **Efficiency:** Leverages the speed and reliability of Redis streams for message handling.\n- **Simplicity:** Dead simple implementation of distributed systems and background job processing with a clean and intuitive API.\n- **Concurrency Control:** Easily manages concurrent message processing to optimize system performance.\n- **Automatic Verification:** Benefits from built-in message verification mechanisms for reliable and secure communication.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Getting Started](#getting-started)\n  - [Sending a Message](#sending-a-message)\n  - [Receiving a Message](#receiving-a-message)\n  - [Verifying a Message](#verifying-a-message)\n  - [Configuration Options](#configuration-options)\n- [Examples](#examples)\n  - [FIFO Example](#fifo-example)\n  - [Sending Message with Delay then Poll](#sending-message-with-delay-then-poll)\n  - [Manual Verification](#manual-verification)\n  - [Concurrent Message Processing/Consuming](#concurrent-message-processingconsuming)\n\n## Installation\n\nTo start using Upstash Queue, install the library via npm:\n\n```sh\nnpm install @upstash/queue\n```\n\n## Getting Started\n\n```typescript\nimport Redis from \"@upstash/redis\";\nimport { Queue } from \"@upstash/queue\";\n\nconst redis = new Redis();\nconst queue = new Queue({ redis });\n```\n\n### Sending a Message\n\n```typescript\nconst payload = { key: \"value\" };\nconst delayInSeconds = 0; // Set to 0 for immediate delivery.\nconst streamId = await queue.sendMessage(payload, delayInSeconds);\n```\n\n### Receiving a Message\n\n```typescript\nconst pollingForNewMessages = 1000; // Set to 0 for non-blocking, otherwise, it will try to get a message then fail if none is available.\nconst receivedMessage = await queue.receiveMessage(pollingForNewMessages);\nconsole.log(\"Received Message:\", receivedMessage);\n```\n\n### Verifying a Message\n\n```typescript\nconst streamId = \"some_stream_id\";\nconst verificationStatus = await queue.verifyMessage(streamId);\nconsole.log(\"Verification Status:\", verificationStatus);\n```\n\n### Configuration Options\n\nWhen initializing the Queue instance, you can provide various configuration options:\n\n- redis: Redis client instance (required).\n- queueName: Name of the Redis stream (default: \"UpstashMQ:Queue\").\n- concurrencyLimit: Maximum concurrent message processing allowed (default: 1).\n- autoVerify: Auto-verify received messages (default: true).\n- consumerGroupName: Group that holds consumers when automatically created (default: \"Messages\").\n- visibilityTimeout: Time until recently sent messages become visible to other consumers (default: 30 seconds).\n\n#### Verifying a Message\n\n```typescript\nconst queueConfig = {\n  redis: new Redis(),\n  queueName: \"MyCustomQueue\",\n  concurrencyLimit: 2,\n  autoVerify: false,\n  consumerGroupName: \"MyConsumers\",\n  visibilityTimeout: 60000, // 1 minute.\n};\n\nconst customQueue = new Queue(queueConfig);\n```\n\n## Examples\n\n### FIFO Example\n\n```typescript\nconst queue = new Queue({ redis });\nawait queue.sendMessage({ hello: \"world1\" });\nawait delay(100);\nawait queue.sendMessage({ hello: \"world2\" });\nawait delay(100);\nawait queue.sendMessage({ hello: \"world3\" });\n\nconst message1 = await queue.receiveMessage\u003c{ hello: \"world1\" }\u003e(); // Logs out { hello: \"world1\" }.\n\nconst message2 = await queue.receiveMessage\u003c{ hello: \"world2\" }\u003e(); // Logs out { hello: \"world2\" }.\n\nconst message3 = await queue.receiveMessage\u003c{ hello: \"world3\" }\u003e(); // Logs out { hello: \"world3\" }.\n```\n\n### Sending Message with Delay then Poll\n\n```typescript\nconst fakeValue = randomValue();\nconst queueName = \"app-logs\";\n\nconst producer = new Queue({ redis, queueName });\nconst consumer = new Queue({\n  redis: new Redis(),\n  queueName,\n});\nawait producer.sendMessage(\n  {\n    dev: fakeValue,\n  },\n  2000\n);\n\nconst receiveMessageRes = await consumer.receiveMessage\u003c{\n  dev: string;\n}\u003e(5000);\n```\n\n### Manual Verification\n\n```typescript\nconst queue = new Queue({ redis, autoVerify: false });\nawait queue.sendMessage({ hello: \"world\" });\n\nconst message = await queue.receiveMessage\u003c{ hello: \"world\" }\u003e(); // Logs out { hello: \"world\" }.\nif (message) {\n  await queue.verifyMessage(message.streamId); //Logs out \"VERIFIED\" or \"NOT VERIFIED\".\n}\n```\n\n### Concurrent Message Processing/Consuming\n\nIf `concurrencyLimit` is not set, one of the `receiveMessage()` will throw. You need to explicitly set the concurrencyLimit. Default is 1.\n\n```typescript\nconst queue = new Queue({\n  redis: new Redis(),\n  queueName: randomValue(),\n  concurrencyLimit: 2,\n});\n\nawait queue.sendMessage({\n  dev: randomValue(),\n});\n\nawait queue.sendMessage({\n  dev: randomValue(),\n});\n\nawait Promise.all([queue.receiveMessage(), queue.receiveMessage()]);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fupstash%2Fqueue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fupstash%2Fqueue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fupstash%2Fqueue/lists"}