amqplib
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "amqplib" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-fc40f8d44275e522172036d90aba07e1582fa448521c7ca6a638361b251743d0. Verify the upstream source and version against https://github.com/TerminalSkills/skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Be an amqplib expert. amqplib is a Node.js client for RabbitMQ and the AMQP 0-9-1 protocol. Help developers implement reliable messaging patterns—work queues, publish/subscribe (fanout exchanges), topic routing, RPC patterns, dead-letter queues, and message acknowledgements—to build decoupled microservices communicating asynchronously via RabbitMQ.
Introduction source: third_party · TerminalSkills · 1.0.0 Reference
SkillPi interpretation
- Testing
- Not tested
Browse files
Frontmatter
name: amqplib
description: >-
You are an expert in amqplib, the Node.js client for RabbitMQ and AMQP
0-9-1 protocol. You help developers implement reliable message queuing with
work queues, pub/sub fanout, topic routing, RPC patterns, dead letter
queues, and message acknowledgment — building decoupled microservices that
communicate asynchronously through RabbitMQ.
license: Apache-2.0
compatibility: ''
metadata:
author: terminal-skills
version: 1.0.0
category: Backend Development
tags:
- rabbitmq
- amqp
- messaging
- queue
- microservices
- asyncamqplib — RabbitMQ Client for Node.js
You are an expert in amqplib, the Node.js client for RabbitMQ and AMQP 0-9-1 protocol. You help developers implement reliable message queuing with work queues, pub/sub fanout, topic routing, RPC patterns, dead letter queues, and message acknowledgment — building decoupled microservices that communicate asynchronously through RabbitMQ.
Core Capabilities
Producer and Consumer
import amqp from "amqplib";
// Producer — send messages to queue
async function sendToQueue(queue: string, message: any) {
const connection = await amqp.connect(process.env.RABBITMQ_URL!);
const channel = await connection.createChannel();
await channel.assertQueue(queue, {
durable: true, // Survive broker restart
arguments: {
"x-dead-letter-exchange": "dlx", // Failed messages go to DLX
"x-message-ttl": 86400000, // 24h TTL
},
});
channel.sendToQueue(queue, Buffer.from(JSON.stringify(message)), {
persistent: true, // Survive broker restart
contentType: "application/json",
messageId: crypto.randomUUID(),
timestamp: Date.now(),
});
await channel.close();
await connection.close();
}
// Consumer — process messages reliably
async function startConsumer(queue: string, handler: (msg: any) => Promise<void>) {
const connection = await amqp.connect(process.env.RABBITMQ_URL!);
const channel = await connection.createChannel();
await channel.assertQueue(queue, { durable: true });
await channel.prefetch(10); // Process 10 at a time
channel.consume(queue, async (msg) => {
if (!msg) return;
try {
const data = JSON.parse(msg.content.toString());
await handler(data);
channel.ack(msg); // Success — remove from queue
} catch (error) {
console.error("Processing failed:", error);
channel.nack(msg, false, false); // Failed — send to DLX (no requeue)
}
});
}
// Usage
await sendToQueue("orders", { orderId: "ORD-123", total: 99.99 });
await startConsumer("orders", async (order) => {
await processOrder(order);
await sendEmail(order);
});
Pub/Sub with Exchanges
// Topic exchange — route messages by pattern
async function setupTopicExchange() {
const connection = await amqp.connect(process.env.RABBITMQ_URL!);
const channel = await connection.createChannel();
await channel.assertExchange("events", "topic", { durable: true });
// Publish events
channel.publish("events", "order.created", Buffer.from(JSON.stringify({
orderId: "ORD-456", items: 3,
})));
channel.publish("events", "order.shipped", Buffer.from(JSON.stringify({
orderId: "ORD-456", trackingId: "TRACK-789",
})));
channel.publish("events", "user.signup", Buffer.from(JSON.stringify({
userId: "usr-99", email: "new@user.com",
})));
}
// Subscribe to patterns
async function subscribeToPattern(pattern: string, handler: (data: any, key: string) => void) {
const connection = await amqp.connect(process.env.RABBITMQ_URL!);
const channel = await connection.createChannel();
await channel.assertExchange("events", "topic", { durable: true });
const { queue } = await channel.assertQueue("", { exclusive: true });
await channel.bindQueue(queue, "events", pattern);
channel.consume(queue, (msg) => {
if (!msg) return;
handler(JSON.parse(msg.content.toString()), msg.fields.routingKey);
channel.ack(msg);
});
}
// Subscribe to all order events
await subscribeToPattern("order.*", (data, key) => {
console.log(`Order event [${key}]:`, data);
});
// Subscribe to everything
await subscribeToPattern("#", (data, key) => {
console.log(`[${key}]:`, data);
});
Installation
npm install amqplib
npm install -D @types/amqplib
# RabbitMQ server
docker run -d -p 5672:5672 -p 15672:15672 rabbitmq:management
Best Practices
- Durable queues + persistent messages — Both needed to survive broker restarts; set both always
- Manual ack — Never use
noAck: truein production; explicitly ack after successful processing - Dead letter exchanges — Configure DLX for failed messages; analyze and retry later
- Prefetch — Set
channel.prefetch(N)to limit concurrent processing; prevents consumer overload - Connection pooling — Reuse connections, create channels per operation; connections are expensive
- Topic exchanges — Use
order.*patterns for flexible routing; decouple publishers from consumers - Message TTL — Set
x-message-ttlto prevent queue buildup; stale messages expire automatically - Idempotent consumers — Use
messageIdto deduplicate; messages may be delivered more than once
Current listing version
1.0.0
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供 amqplib 的完整开发指南,涵盖生产者/消费者、Pub/Sub、死信队列等核心模式
- 附带 TypeScript 代码示例和 8 项最佳实践,对 Node.js 微服务开发者具有明确实用价值
Highlights
- description 精准描述 amqplib 专家角色及核心能力,触发词覆盖工作队列、发布/订阅、RPC、死信队列等关键场景
Areas to improve
-
description 内容重复 Reported severity: Minor
frontmatter 和 skill_body 开头均包含相同 description 内容
Recommendation: 建议移除 skill_body 开头的重复 description,保持 frontmatter 唯一性
-
缺少 When to Use 显式章节 Reported severity: Minor
文档未设置显式的 When to Use 章节说明适用场景
Recommendation: 建议在 Installation 前添加 When to Use 章节,明确说明适用开发场景
Highlights
- 文档结构清晰,分 Core Capabilities、Installation、Best Practices 等逻辑章节
- frontmatter 完整,包含 name、description、license、compatibility、metadata 等必要字段
Highlights
- 代码示例参数配置正确(durable queues、persistent messages、prefetch、DLX)
- 覆盖异常处理机制(try-catch + nack),实现可靠的消息确认流程
- 提供明确的安装命令和 RabbitMQ Docker 启动指令,工具来源清晰
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Install or fetch external dependencies
Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.
Mentioned in main document · lines 142, 143
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.