{"id":46509,"library":"sqs-producer","title":"sqs-producer","description":"sqs-producer is a Node.js library for enqueuing messages onto Amazon SQS queues. Current stable version is 9.0.5, requiring Node >=22. It is a peer dependency of @aws-sdk/client-sqs v3.1036+. The library provides a simple Producer class that handles batching, message formatting, and queue size retrieval. It natively supports both standard and FIFO queues, including groupId/deduplicationId for FIFO and fair queue behavior for multi-tenant scenarios. Ships TypeScript definitions, ESM-only (no CJS), and is maintained by BBC. Differentiators: minimal API surface, no native dependencies, explicit FIFO support, and fair queue integration.","status":"active","version":"9.0.5","language":"javascript","source_language":"en","source_url":"https://github.com/bbc/sqs-producer","tags":["javascript","aws-sqs","backend","message-queue","nodejs","queue-producer","serverless","sqs","typescript"],"install":[{"cmd":"npm install sqs-producer","lang":"bash","label":"npm"},{"cmd":"yarn add sqs-producer","lang":"bash","label":"yarn"},{"cmd":"pnpm add sqs-producer","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: provides the SQS client used internally by the producer.","package":"@aws-sdk/client-sqs","optional":false}],"imports":[{"note":"ESM-only package; cannot use require(). Must use named import.","wrong":"const Producer = require('sqs-producer')","symbol":"Producer","correct":"import { Producer } from 'sqs-producer'"},{"note":"No default export. The class is exported as named export Producer. In v8 and earlier, default export existed, but as of v9 it is ESM-only with named export.","wrong":"import SQSProducer from 'sqs-producer'","symbol":"SQSProducer","correct":"import { Producer } from 'sqs-producer'"},{"note":"Use static factory method create() rather than constructor; the constructor is not publicly documented.","wrong":"new Producer({ queueUrl, region })","symbol":"Producer.create","correct":"Producer.create({ queueUrl, region })"}],"quickstart":{"code":"import { Producer } from 'sqs-producer';\nimport { SQSClient } from '@aws-sdk/client-sqs';\n\nconst producer = Producer.create({\n  queueUrl: 'https://sqs.us-east-1.amazonaws.com/123456789012/my-queue',\n  region: 'us-east-1',\n});\n\n// Send a single message\nawait producer.send('Hello world');\n\n// Send multiple messages\nawait producer.send(['msg1', 'msg2']);\n\n// Send with custom id and attributes\nawait producer.send({\n  id: 'my-id',\n  body: 'Important message',\n  messageAttributes: {\n    priority: { DataType: 'String', StringValue: 'high' }\n  }\n});\n\n// Get current queue size\nconst size = await producer.queueSize();\nconsole.log(`Queue size: ${size}`);","lang":"typescript","description":"Basic producer creation and message sending with SQS, including single, batch, and attribute-enriched messages."},"warnings":[{"fix":"Switch to import syntax. If you must use require, use dynamic import or stay on v8.x.","message":"Version 9.0+ is ESM-only. require() will throw ERR_REQUIRE_ESM.","severity":"breaking","affected_versions":">=9.0.0"},{"fix":"Upgrade Node.js to v22 or later, or use an older version of sqs-producer that supports your Node version.","message":"Node.js >=22 required as of v9.0.0. Older Node versions are unsupported.","severity":"breaking","affected_versions":">=9.0.0"},{"fix":"Wrap send() calls in try/catch and implement exponential backoff/retry logic in your application.","message":"The package does not automatically retry on SQS errors. Network failures or throttling can cause send() to throw.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure that every message sent to a FIFO queue includes groupId and deduplicationId (or enable content-based deduplication on the queue).","message":"For FIFO queues, groupId and deduplicationId are required unless content-based deduplication is enabled. Missing these will cause SQS errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Replace new Producer(options) with Producer.create(options).","message":"Constructor new Producer() is not part of the public API; use Producer.create() instead.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'/client-sqs':35 '22':25 '9.0.5':22 'amazon':15 'api':89 'aw':33,103 'aws-sdk':32 'aws-sq':102 'backend':105 'batch':46 'bbc':86 'behavior':68 'cjs':81 'class':43 'current':18 'definit':76 'depend':30,93 'differenti':87 'enqueu':12 'esm':78 'esm-on':77 'explicit':94 'fair':66,98 'fifo':59,64,95 'format':48 'groupid/deduplicationid':62 'handl':45 'includ':61 'integr':100 'javascript':101 'librari':10,38 'maintain':84 'messag':13,47,107 'message-queu':106 'minim':88 'multi':71 'multi-ten':70 'nativ':54,92 'node':24 'node.js':9 'nodej':109 'onto':14 'peer':29 'produc':3,6,42,112 'provid':39 'queue':17,50,60,67,99,108,111 'queue-produc':110 'requir':23 'retriev':52 'scenario':73 'sdk':34 'serverless':113 'ship':74 'simpl':41 'size':51 'sqs':2,5,16,104,114 'sqs-produc':1,4 'stabl':19 'standard':57 'support':55,96 'surfac':90 'tenant':72 'typescript':75,115 'v3.1036':36 'version':20","created_at":"2026-06-07T13:00:16.761884+00:00","updated_at":"2026-06-07T13:00:16.761884+00:00","problems":[{"fix":"Convert to ES module (add \"type\": \"module\" in package.json) and use import { Producer } from 'sqs-producer'. Alternatively, use dynamic import: const { Producer } = await import('sqs-producer');","cause":"Using require() on a v9+ ESM-only package.","error":"ERR_REQUIRE_ESM: require() of ES Module /path/to/node_modules/sqs-producer/index.mjs not supported."},{"fix":"Use named import: import { Producer } from 'sqs-producer';","cause":"Using default import instead of named import, e.g., import Producer from 'sqs-producer'.","error":"TypeError: Producer.create is not a function"},{"fix":"Add groupId and deduplicationId to each message object. For example: { id: '1', body: 'msg', groupId: 'group1', deduplicationId: 'hash1' }.","cause":"Trying to send a message to a FIFO queue without required FIFO fields.","error":"The groupId and deduplicationId must be specified for FIFO queues"},{"fix":"Ensure each message object has a body field. For string messages, the body is the string itself. For objects, provide body: 'your message'.","cause":"Sending a message object that has no body property.","error":"ValidationError: The request must contain the parameter MessageBody"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://bbc.github.io/sqs-producer/","github":"https://github.com/bbc/sqs-producer","docs":null,"changelog":null,"pypi":null,"npm":"sqs-producer","openapi_spec":null,"status_page":null,"smithery":null,"categories":["messaging","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}