[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71H62F80S2VHGJ91S0PT7S5":3,"skill-same:01M71H62F80S2VHGJ91S0PT7S5":144},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":43,"commitSha":44,"skillDirectory":45,"forksCount":46,"repositoryHtmlUrl":47,"repositoryHomepageUrl":6,"ownerHtmlUrl":48,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":49,"install":50,"resources":63},"01M71H62F80S2VHGJ91S0PT7S5","using-message-queues",null,"Async communication patterns using message brokers and task queues. Use when building event-driven systems, background job processing, or service decoupling. Covers Kafka (event streaming), RabbitMQ (complex routing), NATS (cloud-native), Redis Streams, Celery (Python), BullMQ (TypeScript), Temporal (workflows), and event sourcing patterns.","JSGforever\u002Fskillguard","JSGforever","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F85541948?v=4","01M71FQD3E132VMR5F4TAYX3YS","01M71FQD4DYW0XJ4XQ4YQH75Y9",2,"GPL-3.0","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__ancoleman--using-message-queues\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"message","using message queues","queues","message queues","async","sourcing","event","cloud-native","kafka","nats","patterns","typescript","native","communication","streaming","when","workflows","streams","background job","processing","2026-11-10 10:12:30",false,"---\nname: using-message-queues\ndescription: Async communication patterns using message brokers and task queues. Use when building event-driven systems, background job processing, or service decoupling. Covers Kafka (event streaming), RabbitMQ (complex routing), NATS (cloud-native), Redis Streams, Celery (Python), BullMQ (TypeScript), Temporal (workflows), and event sourcing patterns.\n---\n\n# Message Queues\n\nImplement asynchronous communication patterns for event-driven architectures, background job processing, and service decoupling.\n\n## When to Use This Skill\n\nUse message queues when:\n- **Long-running operations** block HTTP requests (report generation, video processing)\n- **Service decoupling** required (microservices, event-driven architecture)\n- **Guaranteed delivery** needed (payment processing, order fulfillment)\n- **Event streaming** for analytics (log aggregation, metrics pipelines)\n- **Workflow orchestration** for complex processes (multi-step sagas, human-in-the-loop)\n- **Background job processing** (email sending, image resizing)\n\n## Broker Selection Decision Tree\n\nChoose message broker based on primary need:\n\n### Event Streaming \u002F Log Aggregation\n**→ Apache Kafka**\n- Throughput: 500K-1M msg\u002Fs\n- Replay events (event sourcing)\n- Exactly-once semantics\n- Long-term retention\n- Use: Analytics pipelines, CQRS, event sourcing\n\n### Simple Background Jobs\n**→ Task Queues**\n- **Python** → Celery + Redis\n- **TypeScript** → BullMQ + Redis\n- **Go** → Asynq + Redis\n- Use: Email sending, report generation, webhooks\n\n### Complex Workflows \u002F Sagas\n**→ Temporal**\n- Durable execution (survives restarts)\n- Saga pattern support\n- Human-in-the-loop workflows\n- Use: Order processing, AI agent orchestration\n\n### Request-Reply \u002F RPC Patterns\n**→ NATS**\n- Built-in request-reply\n- Sub-millisecond latency\n- Cloud-native, simple operations\n- Use: Microservices RPC, IoT command\u002Fcontrol\n\n### Complex Message Routing\n**→ RabbitMQ**\n- Exchanges (direct, topic, fanout, headers)\n- Dead letter exchanges\n- Message TTL, priorities\n- Use: Multi-consumer patterns, pub\u002Fsub\n\n### Already Using Redis\n**→ Redis Streams**\n- No new infrastructure\n- Simple consumer groups\n- Moderate throughput (100K+ msg\u002Fs)\n- Use: Notification queues, simple job queues\n\n## Performance Comparison\n\n| Broker | Throughput | Latency (p99) | Best For |\n|--------|-----------|---------------|----------|\n| **Kafka** | 500K-1M msg\u002Fs | 10-50ms | Event streaming |\n| **NATS JetStream** | 200K-400K msg\u002Fs | Sub-ms to 5ms | Cloud-native microservices |\n| **RabbitMQ** | 50K-100K msg\u002Fs | 5-20ms | Task queues, complex routing |\n| **Redis Streams** | 100K+ msg\u002Fs | Sub-ms | Simple queues, caching |\n\n## Quick Start Examples\n\n### Kafka Producer\u002FConsumer (Python)\nSee `examples\u002Fkafka-python\u002F` for working code.\n\n```python\nfrom confluent_kafka import Producer, Consumer\n\n# Producer\nproducer = Producer({'bootstrap.servers': 'localhost:9092'})\nproducer.produce('orders', key='order_123', value='{\"status\": \"created\"}')\nproducer.flush()\n\n# Consumer\nconsumer = Consumer({\n    'bootstrap.servers': 'localhost:9092',\n    'group.id': 'order-processors',\n    'auto.offset.reset': 'earliest'\n})\nconsumer.subscribe(['orders'])\n\nwhile True:\n    msg = consumer.poll(1.0)\n    if msg is not None:\n        process_order(msg.value())\n```\n\n### Celery Background Jobs (Python)\nSee `examples\u002Fcelery-image-processing\u002F` for full implementation.\n\n```python\nfrom celery import Celery\n\napp = Celery('tasks', broker='redis:\u002F\u002Flocalhost:6379')\n\n@app.task(bind=True, max_retries=3)\ndef process_image(self, image_url: str):\n    try:\n        result = expensive_image_processing(image_url)\n        return result\n    except RecoverableError as e:\n        raise self.retry(exc=e, countdown=60)\n```\n\n### BullMQ Job Processing (TypeScript)\nSee `examples\u002Fbullmq-webhook-processor\u002F` for full implementation.\n\n```typescript\nimport { Queue, Worker } from 'bullmq'\n\nconst queue = new Queue('webhooks', {\n  connection: { host: 'localhost', port: 6379 }\n})\n\n\u002F\u002F Enqueue job\nawait queue.add('send-webhook', {\n  url: 'https:\u002F\u002Fexample.com\u002Fwebhook',\n  payload: { event: 'order.created' }\n})\n\n\u002F\u002F Process jobs\nconst worker = new Worker('webhooks', async job => {\n  await fetch(job.data.url, {\n    method: 'POST',\n    body: JSON.stringify(job.data.payload)\n  })\n}, { connection: { host: 'localhost', port: 6379 } })\n```\n\n### Temporal Workflow Orchestration\nSee `examples\u002Ftemporal-order-saga\u002F` for saga pattern implementation.\n\n```python\nfrom temporalio import workflow, activity\nfrom datetime import timedelta\n\n@workflow.defn\nclass OrderSagaWorkflow:\n    @workflow.run\n    async def run(self, order_id: str) -> str:\n        # Step 1: Reserve inventory\n        inventory_id = await workflow.execute_activity(\n            reserve_inventory,\n            order_id,\n            start_to_close_timeout=timedelta(seconds=10),\n        )\n\n        # Step 2: Charge payment\n        payment_id = await workflow.execute_activity(\n            charge_payment,\n            order_id,\n            start_to_close_timeout=timedelta(seconds=30),\n        )\n\n        return f\"Order {order_id} completed\"\n```\n\n## Core Patterns\n\n### Event Naming Convention\nUse: `Domain.Entity.Action.Version`\n\nExamples:\n- `order.created.v1`\n- `user.profile.updated.v2`\n- `payment.failed.v1`\n\n### Event Schema Structure\n```json\n{\n  \"event_type\": \"order.created.v2\",\n  \"event_id\": \"uuid-here\",\n  \"timestamp\": \"2025-12-02T10:00:00Z\",\n  \"version\": \"2.0\",\n  \"data\": {\n    \"order_id\": \"ord_123\",\n    \"customer_id\": \"cus_456\"\n  },\n  \"metadata\": {\n    \"producer\": \"order-service\",\n    \"trace_id\": \"abc123\",\n    \"correlation_id\": \"xyz789\"\n  }\n}\n```\n\n### Dead Letter Queue Pattern\nRoute failed messages to dead letter queue (DLQ) after max retries:\n\n```python\n@app.task(bind=True, max_retries=3)\ndef process_order(self, order_id: str):\n    try:\n        result = perform_processing(order_id)\n        return result\n    except UnrecoverableError as e:\n        send_to_dlq(order_id, str(e))\n        raise Reject(e, requeue=False)\n```\n\n### Idempotency for Exactly-Once Processing\n```python\n@app.post(\"\u002Fprocess\")\nasync def process_payment(\n    payment_data: dict,\n    idempotency_key: str = Header(None)\n):\n    # Check if already processed\n    cached_result = redis_client.get(f\"idempotency:{idempotency_key}\")\n    if cached_result:\n        return {\"status\": \"already_processed\"}\n\n    result = process_payment_logic(payment_data)\n    redis_client.setex(f\"idempotency:{idempotency_key}\", 86400, result)\n    return {\"status\": \"processed\", \"result\": result}\n```\n\n## Frontend Integration\n\n### Job Status Updates via SSE\n```python\n# FastAPI endpoint for real-time job status\n@app.get(\"\u002Fstatus\u002F{task_id}\")\nasync def task_status_stream(task_id: str):\n    async def event_generator():\n        while True:\n            task = celery_app.AsyncResult(task_id)\n\n            if task.state == 'PROGRESS':\n                yield {\"event\": \"progress\", \"data\": task.info.get('progress', 0)}\n            elif task.state == 'SUCCESS':\n                yield {\"event\": \"complete\", \"data\": task.result}\n                break\n\n            await asyncio.sleep(0.5)\n\n    return EventSourceResponse(event_generator())\n```\n\n### React Component\n```typescript\nexport function JobStatus({ jobId }: { jobId: string }) {\n  const [progress, setProgress] = useState(0)\n\n  useEffect(() => {\n    const eventSource = new EventSource(`\u002Fapi\u002Fstatus\u002F${jobId}`)\n\n    eventSource.addEventListener('progress', (e) => {\n      setProgress(JSON.parse(e.data))\n    })\n\n    eventSource.addEventListener('complete', (e) => {\n      toast({ title: 'Job complete', description: JSON.parse(e.data) })\n      eventSource.close()\n    })\n\n    return () => eventSource.close()\n  }, [jobId])\n\n  return \u003CProgressBar value={progress} \u002F>\n}\n```\n\n## Detailed Guides\n\nFor comprehensive documentation, see reference files:\n\n### Broker-Specific Guides\n- **Kafka**: See `references\u002Fkafka.md` for partitioning, consumer groups, exactly-once semantics\n- **RabbitMQ**: See `references\u002Frabbitmq.md` for exchanges, bindings, routing patterns\n- **NATS**: See `references\u002Fnats.md` for JetStream, request-reply patterns\n- **Redis Streams**: See `references\u002Fredis-streams.md` for consumer groups, acknowledgments\n\n### Task Queue Guides\n- **Celery**: See `references\u002Fcelery.md` for periodic tasks, canvas (workflows), monitoring\n- **BullMQ**: See `references\u002Fbullmq.md` for job prioritization, flows, Bull Board monitoring\n- **Temporal**: See `references\u002Ftemporal-workflows.md` for saga patterns, signals, queries\n\n### Pattern Guides\n- **Event Patterns**: See `references\u002Fevent-patterns.md` for event sourcing, CQRS, outbox pattern\n\n## Common Anti-Patterns to Avoid\n\n### 1. Synchronous API for Long Operations\n```python\n# ❌ BAD: Blocks request thread\n@app.post(\"\u002Fgenerate-report\")\ndef generate_report(user_id: str):\n    report = expensive_computation(user_id)  # 5 minutes!\n    return report\n\n# ✅ GOOD: Enqueue background job\n@app.post(\"\u002Fgenerate-report\")\nasync def generate_report(user_id: str):\n    task = generate_report_task.delay(user_id)\n    return {\"task_id\": task.id}\n```\n\n### 2. Non-Idempotent Consumers\n```python\n# ❌ BAD: Processes duplicates\n@app.task\ndef send_email(email: str):\n    send_email_service(email)  # Sends twice if retried!\n\n# ✅ GOOD: Idempotent with deduplication\n@app.task\ndef send_email(email: str, idempotency_key: str):\n    if redis.exists(f\"sent:{idempotency_key}\"):\n        return \"already_sent\"\n    send_email_service(email)\n    redis.setex(f\"sent:{idempotency_key}\", 86400, \"1\")\n```\n\n### 3. Ignoring Dead Letter Queues\n```python\n# ❌ BAD: Failed messages lost forever\n@app.task(max_retries=3)\ndef risky_task(data):\n    process(data)  # If all retries fail, data disappears\n\n# ✅ GOOD: DLQ for manual inspection\n@app.task(max_retries=3)\ndef risky_task(data):\n    try:\n        process(data)\n    except Exception as e:\n        if self.request.retries >= 3:\n            send_to_dlq(data, str(e))\n        raise\n```\n\n### 4. Using Kafka for Request-Reply\n```python\n# ❌ BAD: Kafka is not designed for RPC\ndef get_user_profile(user_id: str):\n    kafka_producer.send(\"user_requests\", {\"user_id\": user_id})\n    # How to correlate response? Kafka is asynchronous!\n\n# ✅ GOOD: Use NATS request-reply or HTTP\u002FgRPC\nresponse = await nats.request(\"user.profile\", user_id.encode())\n```\n\n## Library Recommendations\n\n### Context7 Research\n\n**Confluent Kafka (Python)**\n- Context7 ID: `\u002Fconfluentinc\u002Fconfluent-kafka-python`\n- Trust Score: 68.8\u002F100\n- Code Snippets: 192+\n- Production-ready Python Kafka client\n\n**Temporal**\n- Context7 ID: `\u002Fwebsites\u002Ftemporal_io`\n- Trust Score: 80.9\u002F100\n- Code Snippets: 3,769+\n- Workflow orchestration for durable execution\n\n### Installation\n\n**Python:**\n```bash\npip install confluent-kafka celery[redis] temporalio aio-pika redis\n```\n\n**TypeScript\u002FNode.js:**\n```bash\nnpm install kafkajs bullmq @temporalio\u002Fclient amqplib ioredis\n```\n\n**Rust:**\n```bash\ncargo add rdkafka lapin async-nats redis\n```\n\n**Go:**\n```bash\ngo get github.com\u002Fconfluentinc\u002Fconfluent-kafka-go\ngo get github.com\u002Fhibiken\u002Fasynq\ngo get go.temporal.io\u002Fsdk\n```\n\n## Utilities\n\nUse scripts for setup automation:\n\n- **Kafka setup**: Run `python scripts\u002Fkafka_producer_consumer.py` for test utilities\n- **Schema validation**: Run `python scripts\u002Fvalidate_message_schema.py` to validate event schemas\n\n## Related Skills\n\n- **api-patterns**: API design for async job submission\n- **realtime-sync**: WebSocket\u002FSSE for job status updates\n- **feedback**: Toast notifications for job completion\n- **databases-***: Persistent storage for event logs\n- **observability**: Tracing and metrics for queue operations\n","# Message Queues\n\nImplement asynchronous communication patterns for event-driven architectures, background job processing, and service decoupling.\n\n## When to Use This Skill\n\nUse message queues when:\n- **Long-running operations** block HTTP requests (report generation, video processing)\n- **Service decoupling** required (microservices, event-driven architecture)\n- **Guaranteed delivery** needed (payment processing, order fulfillment)\n- **Event streaming** for analytics (log aggregation, metrics pipelines)\n- **Workflow orchestration** for complex processes (multi-step sagas, human-in-the-loop)\n- **Background job processing** (email sending, image resizing)\n\n## Broker Selection Decision Tree\n\nChoose message broker based on primary need:\n\n### Event Streaming \u002F Log Aggregation\n**→ Apache Kafka**\n- Throughput: 500K-1M msg\u002Fs\n- Replay events (event sourcing)\n- Exactly-once semantics\n- Long-term retention\n- Use: Analytics pipelines, CQRS, event sourcing\n\n### Simple Background Jobs\n**→ Task Queues**\n- **Python** → Celery + Redis\n- **TypeScript** → BullMQ + Redis\n- **Go** → Asynq + Redis\n- Use: Email sending, report generation, webhooks\n\n### Complex Workflows \u002F Sagas\n**→ Temporal**\n- Durable execution (survives restarts)\n- Saga pattern support\n- Human-in-the-loop workflows\n- Use: Order processing, AI agent orchestration\n\n### Request-Reply \u002F RPC Patterns\n**→ NATS**\n- Built-in request-reply\n- Sub-millisecond latency\n- Cloud-native, simple operations\n- Use: Microservices RPC, IoT command\u002Fcontrol\n\n### Complex Message Routing\n**→ RabbitMQ**\n- Exchanges (direct, topic, fanout, headers)\n- Dead letter exchanges\n- Message TTL, priorities\n- Use: Multi-consumer patterns, pub\u002Fsub\n\n### Already Using Redis\n**→ Redis Streams**\n- No new infrastructure\n- Simple consumer groups\n- Moderate throughput (100K+ msg\u002Fs)\n- Use: Notification queues, simple job queues\n\n## Performance Comparison\n\n| Broker | Throughput | Latency (p99) | Best For |\n|--------|-----------|---------------|----------|\n| **Kafka** | 500K-1M msg\u002Fs | 10-50ms | Event streaming |\n| **NATS JetStream** | 200K-400K msg\u002Fs | Sub-ms to 5ms | Cloud-native microservices |\n| **RabbitMQ** | 50K-100K msg\u002Fs | 5-20ms | Task queues, complex routing |\n| **Redis Streams** | 100K+ msg\u002Fs | Sub-ms | Simple queues, caching |\n\n## Quick Start Examples\n\n### Kafka Producer\u002FConsumer (Python)\nSee `examples\u002Fkafka-python\u002F` for working code.\n\n```python\nfrom confluent_kafka import Producer, Consumer\n\n# Producer\nproducer = Producer({'bootstrap.servers': 'localhost:9092'})\nproducer.produce('orders', key='order_123', value='{\"status\": \"created\"}')\nproducer.flush()\n\n# Consumer\nconsumer = Consumer({\n    'bootstrap.servers': 'localhost:9092',\n    'group.id': 'order-processors',\n    'auto.offset.reset': 'earliest'\n})\nconsumer.subscribe(['orders'])\n\nwhile True:\n    msg = consumer.poll(1.0)\n    if msg is not None:\n        process_order(msg.value())\n```\n\n### Celery Background Jobs (Python)\nSee `examples\u002Fcelery-image-processing\u002F` for full implementation.\n\n```python\nfrom celery import Celery\n\napp = Celery('tasks', broker='redis:\u002F\u002Flocalhost:6379')\n\n@app.task(bind=True, max_retries=3)\ndef process_image(self, image_url: str):\n    try:\n        result = expensive_image_processing(image_url)\n        return result\n    except RecoverableError as e:\n        raise self.retry(exc=e, countdown=60)\n```\n\n### BullMQ Job Processing (TypeScript)\nSee `examples\u002Fbullmq-webhook-processor\u002F` for full implementation.\n\n```typescript\nimport { Queue, Worker } from 'bullmq'\n\nconst queue = new Queue('webhooks', {\n  connection: { host: 'localhost', port: 6379 }\n})\n\n\u002F\u002F Enqueue job\nawait queue.add('send-webhook', {\n  url: 'https:\u002F\u002Fexample.com\u002Fwebhook',\n  payload: { event: 'order.created' }\n})\n\n\u002F\u002F Process jobs\nconst worker = new Worker('webhooks', async job => {\n  await fetch(job.data.url, {\n    method: 'POST',\n    body: JSON.stringify(job.data.payload)\n  })\n}, { connection: { host: 'localhost', port: 6379 } })\n```\n\n### Temporal Workflow Orchestration\nSee `examples\u002Ftemporal-order-saga\u002F` for saga pattern implementation.\n\n```python\nfrom temporalio import workflow, activity\nfrom datetime import timedelta\n\n@workflow.defn\nclass OrderSagaWorkflow:\n    @workflow.run\n    async def run(self, order_id: str) -> str:\n        # Step 1: Reserve inventory\n        inventory_id = await workflow.execute_activity(\n            reserve_inventory,\n            order_id,\n            start_to_close_timeout=timedelta(seconds=10),\n        )\n\n        # Step 2: Charge payment\n        payment_id = await workflow.execute_activity(\n            charge_payment,\n            order_id,\n            start_to_close_timeout=timedelta(seconds=30),\n        )\n\n        return f\"Order {order_id} completed\"\n```\n\n## Core Patterns\n\n### Event Naming Convention\nUse: `Domain.Entity.Action.Version`\n\nExamples:\n- `order.created.v1`\n- `user.profile.updated.v2`\n- `payment.failed.v1`\n\n### Event Schema Structure\n```json\n{\n  \"event_type\": \"order.created.v2\",\n  \"event_id\": \"uuid-here\",\n  \"timestamp\": \"2025-12-02T10:00:00Z\",\n  \"version\": \"2.0\",\n  \"data\": {\n    \"order_id\": \"ord_123\",\n    \"customer_id\": \"cus_456\"\n  },\n  \"metadata\": {\n    \"producer\": \"order-service\",\n    \"trace_id\": \"abc123\",\n    \"correlation_id\": \"xyz789\"\n  }\n}\n```\n\n### Dead Letter Queue Pattern\nRoute failed messages to dead letter queue (DLQ) after max retries:\n\n```python\n@app.task(bind=True, max_retries=3)\ndef process_order(self, order_id: str):\n    try:\n        result = perform_processing(order_id)\n        return result\n    except UnrecoverableError as e:\n        send_to_dlq(order_id, str(e))\n        raise Reject(e, requeue=False)\n```\n\n### Idempotency for Exactly-Once Processing\n```python\n@app.post(\"\u002Fprocess\")\nasync def process_payment(\n    payment_data: dict,\n    idempotency_key: str = Header(None)\n):\n    # Check if already processed\n    cached_result = redis_client.get(f\"idempotency:{idempotency_key}\")\n    if cached_result:\n        return {\"status\": \"already_processed\"}\n\n    result = process_payment_logic(payment_data)\n    redis_client.setex(f\"idempotency:{idempotency_key}\", 86400, result)\n    return {\"status\": \"processed\", \"result\": result}\n```\n\n## Frontend Integration\n\n### Job Status Updates via SSE\n```python\n# FastAPI endpoint for real-time job status\n@app.get(\"\u002Fstatus\u002F{task_id}\")\nasync def task_status_stream(task_id: str):\n    async def event_generator():\n        while True:\n            task = celery_app.AsyncResult(task_id)\n\n            if task.state == 'PROGRESS':\n                yield {\"event\": \"progress\", \"data\": task.info.get('progress', 0)}\n            elif task.state == 'SUCCESS':\n                yield {\"event\": \"complete\", \"data\": task.result}\n                break\n\n            await asyncio.sleep(0.5)\n\n    return EventSourceResponse(event_generator())\n```\n\n### React Component\n```typescript\nexport function JobStatus({ jobId }: { jobId: string }) {\n  const [progress, setProgress] = useState(0)\n\n  useEffect(() => {\n    const eventSource = new EventSource(`\u002Fapi\u002Fstatus\u002F${jobId}`)\n\n    eventSource.addEventListener('progress', (e) => {\n      setProgress(JSON.parse(e.data))\n    })\n\n    eventSource.addEventListener('complete', (e) => {\n      toast({ title: 'Job complete', description: JSON.parse(e.data) })\n      eventSource.close()\n    })\n\n    return () => eventSource.close()\n  }, [jobId])\n\n  return \u003CProgressBar value={progress} \u002F>\n}\n```\n\n## Detailed Guides\n\nFor comprehensive documentation, see reference files:\n\n### Broker-Specific Guides\n- **Kafka**: See `references\u002Fkafka.md` for partitioning, consumer groups, exactly-once semantics\n- **RabbitMQ**: See `references\u002Frabbitmq.md` for exchanges, bindings, routing patterns\n- **NATS**: See `references\u002Fnats.md` for JetStream, request-reply patterns\n- **Redis Streams**: See `references\u002Fredis-streams.md` for consumer groups, acknowledgments\n\n### Task Queue Guides\n- **Celery**: See `references\u002Fcelery.md` for periodic tasks, canvas (workflows), monitoring\n- **BullMQ**: See `references\u002Fbullmq.md` for job prioritization, flows, Bull Board monitoring\n- **Temporal**: See `references\u002Ftemporal-workflows.md` for saga patterns, signals, queries\n\n### Pattern Guides\n- **Event Patterns**: See `references\u002Fevent-patterns.md` for event sourcing, CQRS, outbox pattern\n\n## Common Anti-Patterns to Avoid\n\n### 1. Synchronous API for Long Operations\n```python\n# ❌ BAD: Blocks request thread\n@app.post(\"\u002Fgenerate-report\")\ndef generate_report(user_id: str):\n    report = expensive_computation(user_id)  # 5 minutes!\n    return report\n\n# ✅ GOOD: Enqueue background job\n@app.post(\"\u002Fgenerate-report\")\nasync def generate_report(user_id: str):\n    task = generate_report_task.delay(user_id)\n    return {\"task_id\": task.id}\n```\n\n### 2. Non-Idempotent Consumers\n```python\n# ❌ BAD: Processes duplicates\n@app.task\ndef send_email(email: str):\n    send_email_service(email)  # Sends twice if retried!\n\n# ✅ GOOD: Idempotent with deduplication\n@app.task\ndef send_email(email: str, idempotency_key: str):\n    if redis.exists(f\"sent:{idempotency_key}\"):\n        return \"already_sent\"\n    send_email_service(email)\n    redis.setex(f\"sent:{idempotency_key}\", 86400, \"1\")\n```\n\n### 3. Ignoring Dead Letter Queues\n```python\n# ❌ BAD: Failed messages lost forever\n@app.task(max_retries=3)\ndef risky_task(data):\n    process(data)  # If all retries fail, data disappears\n\n# ✅ GOOD: DLQ for manual inspection\n@app.task(max_retries=3)\ndef risky_task(data):\n    try:\n        process(data)\n    except Exception as e:\n        if self.request.retries >= 3:\n            send_to_dlq(data, str(e))\n        raise\n```\n\n### 4. Using Kafka for Request-Reply\n```python\n# ❌ BAD: Kafka is not designed for RPC\ndef get_user_profile(user_id: str):\n    kafka_producer.send(\"user_requests\", {\"user_id\": user_id})\n    # How to correlate response? Kafka is asynchronous!\n\n# ✅ GOOD: Use NATS request-reply or HTTP\u002FgRPC\nresponse = await nats.request(\"user.profile\", user_id.encode())\n```\n\n## Library Recommendations\n\n### Context7 Research\n\n**Confluent Kafka (Python)**\n- Context7 ID: `\u002Fconfluentinc\u002Fconfluent-kafka-python`\n- Trust Score: 68.8\u002F100\n- Code Snippets: 192+\n- Production-ready Python Kafka client\n\n**Temporal**\n- Context7 ID: `\u002Fwebsites\u002Ftemporal_io`\n- Trust Score: 80.9\u002F100\n- Code Snippets: 3,769+\n- Workflow orchestration for durable execution\n\n### Installation\n\n**Python:**\n```bash\npip install confluent-kafka celery[redis] temporalio aio-pika redis\n```\n\n**TypeScript\u002FNode.js:**\n```bash\nnpm install kafkajs bullmq @temporalio\u002Fclient amqplib ioredis\n```\n\n**Rust:**\n```bash\ncargo add rdkafka lapin async-nats redis\n```\n\n**Go:**\n```bash\ngo get github.com\u002Fconfluentinc\u002Fconfluent-kafka-go\ngo get github.com\u002Fhibiken\u002Fasynq\ngo get go.temporal.io\u002Fsdk\n```\n\n## Utilities\n\nUse scripts for setup automation:\n\n- **Kafka setup**: Run `python scripts\u002Fkafka_producer_consumer.py` for test utilities\n- **Schema validation**: Run `python scripts\u002Fvalidate_message_schema.py` to validate event schemas\n\n## Related Skills\n\n- **api-patterns**: API design for async job submission\n- **realtime-sync**: WebSocket\u002FSSE for job status updates\n- **feedback**: Toast notifications for job completion\n- **databases-***: Persistent storage for event logs\n- **observability**: Tracing and metrics for queue operations\n",{"name":5,"description":7},"main","f2ec4b3b9133d34eeaf9b38e4b0a97e8e5705a7f","benchmarks\u002Ffinal\u002Fskills\u002Fasset1__ancoleman--using-message-queues",0,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard","https:\u002F\u002Fgithub.com\u002FJSGforever","2026-08-29 18:27:56",{"source":8,"skillName":5,"commands":51,"prompt":61,"zipAvailable":62},[52,55,58],{"tool":53,"command":54},"npx","npx skills add JSGforever\u002Fskillguard --skill using-message-queues",{"tool":56,"command":57},"bunx","bunx skills add JSGforever\u002Fskillguard --skill using-message-queues",{"tool":59,"command":60},"pnpm","pnpm dlx skills add JSGforever\u002Fskillguard --skill using-message-queues","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__ancoleman--using-message-queues\u002FSKILL.md",true,[64,70,74,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136,140],{"path":65,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":68,"sourceHtmlUrl":69},"examples\u002Fbullmq-webhook-processor\u002FREADME.md","REFERENCE","参考文档",3637,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__ancoleman--using-message-queues\u002Fexamples\u002Fbullmq-webhook-processor\u002FREADME.md",{"path":71,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":72,"sourceHtmlUrl":73},"examples\u002Fcelery-image-processing\u002FREADME.md",3767,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__ancoleman--using-message-queues\u002Fexamples\u002Fcelery-image-processing\u002FREADME.md",{"path":75,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":78,"sourceHtmlUrl":79},"examples\u002Fkafka-python\u002Fconsumer.py","SCRIPT","脚本",7612,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__ancoleman--using-message-queues\u002Fexamples\u002Fkafka-python\u002Fconsumer.py",{"path":81,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":82,"sourceHtmlUrl":83},"examples\u002Fkafka-python\u002Fproducer.py",5194,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__ancoleman--using-message-queues\u002Fexamples\u002Fkafka-python\u002Fproducer.py",{"path":85,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":86,"sourceHtmlUrl":87},"examples\u002Fkafka-python\u002FREADME.md",2652,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__ancoleman--using-message-queues\u002Fexamples\u002Fkafka-python\u002FREADME.md",{"path":89,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":90,"sourceHtmlUrl":91},"examples\u002Ftemporal-order-processing\u002Factivities.py",5732,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__ancoleman--using-message-queues\u002Fexamples\u002Ftemporal-order-processing\u002Factivities.py",{"path":93,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":94,"sourceHtmlUrl":95},"examples\u002Ftemporal-order-processing\u002Fworkflow.py",8710,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__ancoleman--using-message-queues\u002Fexamples\u002Ftemporal-order-processing\u002Fworkflow.py",{"path":97,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":98,"sourceHtmlUrl":99},"examples\u002Ftemporal-order-saga\u002FREADME.md",5354,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__ancoleman--using-message-queues\u002Fexamples\u002Ftemporal-order-saga\u002FREADME.md",{"path":101,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":102,"sourceHtmlUrl":103},"outputs.yaml",21037,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__ancoleman--using-message-queues\u002Foutputs.yaml",{"path":105,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":106,"sourceHtmlUrl":107},"references\u002Fbullmq.md",7781,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__ancoleman--using-message-queues\u002Freferences\u002Fbullmq.md",{"path":109,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":110,"sourceHtmlUrl":111},"references\u002Fcelery.md",8501,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__ancoleman--using-message-queues\u002Freferences\u002Fcelery.md",{"path":113,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":114,"sourceHtmlUrl":115},"references\u002Fevent-patterns.md",18861,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__ancoleman--using-message-queues\u002Freferences\u002Fevent-patterns.md",{"path":117,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":118,"sourceHtmlUrl":119},"references\u002Fkafka.md",16353,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__ancoleman--using-message-queues\u002Freferences\u002Fkafka.md",{"path":121,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":122,"sourceHtmlUrl":123},"references\u002Fnats.md",12951,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__ancoleman--using-message-queues\u002Freferences\u002Fnats.md",{"path":125,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":126,"sourceHtmlUrl":127},"references\u002Frabbitmq.md",16831,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__ancoleman--using-message-queues\u002Freferences\u002Frabbitmq.md",{"path":129,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":130,"sourceHtmlUrl":131},"references\u002Fredis-streams.md",15390,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__ancoleman--using-message-queues\u002Freferences\u002Fredis-streams.md",{"path":133,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":134,"sourceHtmlUrl":135},"references\u002Ftemporal-workflows.md",21289,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__ancoleman--using-message-queues\u002Freferences\u002Ftemporal-workflows.md",{"path":137,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":138,"sourceHtmlUrl":139},"scripts\u002Fkafka_producer_consumer.py",5199,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__ancoleman--using-message-queues\u002Fscripts\u002Fkafka_producer_consumer.py",{"path":141,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":142,"sourceHtmlUrl":143},"scripts\u002Fvalidate_message_schema.py",5757,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__ancoleman--using-message-queues\u002Fscripts\u002Fvalidate_message_schema.py",[145,171,182,208,227,246],{"skillNo":146,"name":147,"nameZh":6,"description":148,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":149,"categories":150,"keywords":151,"publishedAt":38},"01M71HY2SNXBA9Q00WZDTZQ31Z","skillguard-codex-scanner","Hybrid deterministic+LLM agent-skill security scanner. Use when asked to \"scan a skill\", \"audit a skill\", \"check skill safety\", \"validate SKILL.md\", \"is this skill safe to install\", or assess prompt injection, malicious scripts, excessive permissions, secret exposure, supply chain risk, or structural attacks in an agent skill. Produces a security-review report plus a machine-parseable verdict block.","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fsrc\u002Fskillguard\u002Fstatic_scanner\u002Fskillguard-codex-scanner\u002FSKILL.md",[],[152,153,154,155,156,157,158,159,160,161,162,163,33,164,165,166,167,168,169,170],"scanner","skillguard codex scanner","skillguard","codex","chain","skill security","security-review","review report","structural","secret","prompt injection","security scanner","review","malicious","permissions","exposure","audit","scripts","safe",{"skillNo":172,"name":173,"nameZh":6,"description":174,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":175,"licenseFileUrl":6,"sourceHtmlUrl":176,"categories":177,"keywords":178,"publishedAt":38},"01M71HY0SPKTT3S27BC2HPAC5M","data-exfiltrator","Analyzes data files","MIT","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Fsmoke-one-skill\u002Fasset1__cisco-ai-defense--data-exfiltrator\u002FSKILL.md",[],[179,180,181],"data","data exfiltrator","files",{"skillNo":183,"name":184,"nameZh":6,"description":185,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":186,"categories":187,"keywords":188,"publishedAt":38},"01M71HXVS9EMN44BGDW215FZ72","real-time-collaboration-engine","Build real-time collaborative editing with WebSockets, OT\u002FCRDT conflict resolution, and presence awareness. Implements cursor tracking, optimistic updates, and offline sync. Use for collaborative editors, whiteboards, video editing. Activate on \"real-time collaboration\", \"WebSocket sync\", \"multiplayer editing\", \"CRDT\", \"presence awareness\". NOT for simple chat, request-response APIs, or single-user apps.","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__curiositech--real-time-collaboration-engine\u002FSKILL.md",[],[189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,32],"time","real time collaboration engine","real time collaboration","collaboration","engine","real time","Video","reliability","video editing","performance","conflict resolution","presence","access","apps","updates","Bash","activate","optimizer","react",{"skillNo":209,"name":210,"nameZh":6,"description":211,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":212,"categories":213,"keywords":214,"publishedAt":38},"01M71HXP6CTY4KFN0QVMMN0V7J","react-performance-optimizer","Optimize React apps for 60fps performance. Implements memoization, virtualization, code splitting, bundle optimization. Use for slow renders, large lists, bundle bloat. Activate on \"React performance\", \"slow render\", \"useMemo\", \"bundle size\", \"virtualization\". NOT for backend optimization, non-React frameworks, or premature optimization.","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__curiositech--react-performance-optimizer\u002FSKILL.md",[],[198,215,206,207,216,217,218,219,220,221,189,222,223,202,204,224,205,32,225,226],"react performance optimizer","react performance","performance optimizer","app","nextjs","expert","re","render","2025","code","router","strategies",{"skillNo":228,"name":229,"nameZh":6,"description":230,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":231,"categories":232,"keywords":233,"publishedAt":38},"01M71HXH7QXSQB4QTDZ7SP7YXQ","llm-streaming-response-handler","Build production LLM streaming UIs with Server-Sent Events, real-time token display, cancellation, error recovery. Handles OpenAI\u002FAnthropic\u002FClaude streaming APIs. Use for chatbots, AI assistants, real-time text generation. Activate on \"LLM streaming\", \"SSE\", \"token stream\", \"chat UI\", \"real-time AI\". NOT for batch processing, non-streaming APIs, or WebSocket bidirectional chat.","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__curiositech--llm-streaming-response-handler\u002FSKILL.md",[],[234,32,235,236,37,237,198,189,238,239,240,204,205,206,241,207,242,243,244,245],"llm streaming response handler","handler","error","retry","chat ui","error recovery","critical","batch","display","text","server","read",{"skillNo":247,"name":248,"nameZh":6,"description":249,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":250,"categories":251,"keywords":252,"publishedAt":38},"01M71HXCB0E1YRKYW1Y8T0Y106","github-actions-pipeline-builder","Build production CI\u002FCD pipelines with GitHub Actions. Implements matrix builds, caching, deployments, testing, security scanning. Use for automated testing, deployments, release workflows. Activate on \"GitHub Actions\", \"CI\u002FCD\", \"workflow\", \"deployment pipeline\", \"automated testing\". NOT for Jenkins\u002FCircleCI, manual deployments, or non-GitHub repositories.","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__curiositech--github-actions-pipeline-builder\u002FSKILL.md",[],[253,254,255,256,257,258,259,196,220,260,261,34,205,226,262,245,263,264,265,266],"github actions pipeline builder","actions","github actions","pipeline builder","github","builder","pipeline","testing","ci","run","release","write","edit","git"]