@defra-fish/sqs-receiver-service

中文文档
1.77.1发布于 2026/11/12SEE LICENSE IN LICENSEES Module构建来源已验证近 30 天下载 3118

SQS Receiver service

原始使用文档
文档目录4 节
  1. To control via pm2
  2. Debug
  3. Failures
  4. A development environment can be set up as follows

sqs-receiver-service

This service is configured to poll a set of SQS queues and on receipt of a message from the queue it will notify a subscribing service.

If the response from the subscriber is successful the message will be removed from the queue. If not the message will become visible again after the visibility timeout and maybe reprocessed subject to the SQS re-drive policy.

Environment variables

namedescriptionrequireddefaultvalidnotes
NODE_ENVNode environmentnodevelopment, fsh-{env}
AWS_REGIONThe AWS region to useyesSee AWS Regions
AWS_SQS_ENDPOINTCustom SQS EndpointnoRegion specificUsed to override the SQS service endpoint for local development
RECEIVER_PREFIXPrefix for reading environment variables specific to a receiver instanceyesThe prefix to use to retrieve further settings via the environment (see below)
<RECEIVER_PREFIX>_URLThe SQS queue URLyes
<RECEIVER_PREFIX>_WAIT_TIME_MSThe amount of time to block while long polling a queue for messagesno20000 (20 seconds)
<RECEIVER_PREFIX>_VISIBILITY_TIMEOUT_MSThe length of time the message is made invisible to other processesyes
<RECEIVER_PREFIX>_MAX_POLLING_INTERVAL_MSThe maximum amount of time to wait between subsequent read requestsno300000 (5 minutes)For each read request returning no messages, an exponential delay is calculated before reading again. This limits that delay.
<RECEIVER_PREFIX>_ATTEMPTS_WITH_NO_DELAYNumber of receive requests with no messages before imposing a delayno10Receive message requests may return no messages even if there are messages waiting. Allow this many requests before delaying.
<RECEIVER_PREFIX>_SUBSCRIBERThe location of the subscriber.yes
<RECEIVER_PREFIX>_SUBSCRIBER_TIMEOUT_MSPrefix for reading environment variables specific to a receiver instanceno180000 (3m)
DEBUGEnable debug outputnosqs:*, sqs:receiver, sqs:read-queue, sqs:process-message, sqs:delete-messages, sqs:queue-statsEnables debug output for the given category, accepts wildcards
AIRBRAKE_HOSTURL of airbrake hostno
AIRBRAKE_PROJECT_KEYProject key for airbrake loggingno

To control via pm2

pm2 [start|restart|stop|delete] ecosystem.config.js

The ecosystem.config.js file contains the set of receiver services to run. An example entry is shown:

   - script: ./index.js
     name: 'Sales Queue'
     env:
       RECEIVER_PREFIX: SALES_QUEUE
     output: ./logs/sales-queue.out
     error: ./logs/sales-queue.err
     autorestart: false

Debug

The service uses the debug package see the DEBUG environment variable guidance

Failures

The service will fail early where a general error reading an SQS queue is encountered such as ECONNREFUSED

In the case of all http errors reading SQS queues the service will log the error continue. See: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/CommonErrors.html

In the case of all errors encountered in the subscriber process queues the service will log the error continue

Only in the cases where the subscriber return an http success status will the message be removed from the SQS queue

A development environment can be set up as follows

AWS_REGION=eu-west-2
AWS_ACCESS_KEY_ID=local
AWS_SECRET_ACCESS_KEY=local
AWS_SQS_ENDPOINT=http://0.0.0.0:9324

DEBUG=sqs:*

TRANSACTION_QUEUE_URL=http://0.0.0.0:9324/queue/TransactionsQueue.fifo
TRANSACTION_QUEUE_MAX_POLLING_INTERVAL_MS=30000
TRANSACTION_QUEUE_VISIBILITY_TIMEOUT_MS=300000
TRANSACTION_QUEUE_SUBSCRIBER=http://0.0.0.0:4000/process-queue/transactions

TRANSACTION_DLQ_URL=http://0.0.0.0:9324/queue/TransactionsDlq.fifo
TRANSACTION_DLQ_MAX_POLLING_INTERVAL_MS=180000
TRANSACTION_DLQ_VISIBILITY_TIMEOUT_MS=300000
TRANSACTION_DLQ_SUBSCRIBER=http://0.0.0.0:4000/process-dlq/transactions

版本与发布记录

@defra-fish/sqs-receiver-service 共发布 1,045 个版本,首次发布于 2020/03/24;过去 12 个月发布了 138 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.77.1latest2026/11/12今天
1.78.0-rc.1rc2026/11/11今天
1.78.0-rc.02026/11/111 天前
1.77.02026/11/093 天前
1.77.0-rc.182026/11/066 天前
1.77.0-rc.172026/11/0210 天前

其他发布通道:beta → 0.0.1-beta.53,multibuy-rc → 1.28.0-multibuy-rc.0,rc → 1.78.0-rc.1。

关于 @defra-fish/sqs-receiver-service 的常见问题

@defra-fish/sqs-receiver-service 是什么?

SQS Receiver service

如何安装 @defra-fish/sqs-receiver-service?

在项目目录运行 npm install @defra-fish/sqs-receiver-service,或使用 pnpm add / yarn add / bun add。

@defra-fish/sqs-receiver-service 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/defra-fish__sqs-receiver-service 是否存在。

@defra-fish/sqs-receiver-service 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@defra-fish/sqs-receiver-service 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@defra-fish/sqs-receiver-service 可以商用吗?

@defra-fish/sqs-receiver-service 使用 SEE LICENSE IN LICENSE 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@defra-fish/sqs-receiver-service 的下载量有多少?

根据 npm 官方下载统计,@defra-fish/sqs-receiver-service 在 2026/10/12 – 2026/11/10 这 30 天内被下载 3,118 次,日均约 104 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@defra-fish/sqs-receiver-service 还在维护吗?

最新版本 1.77.1 发布于 2026/11/12(今天);至今共发布 1045 个版本,其中过去 12 个月发布了 138 个;首次发布于 2020/03/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。