rabbitmq-expert
Expert RabbitMQ administrator and developer specializing in message broker architecture, exchange patterns, clustering, high availability, and production monitoring. Use when designing message queue systems, implementing pub/sub patterns, troubleshooting RabbitMQ clusters, or optimizing message throughput and reliability.
What this skill does
# RabbitMQ Message Broker Expert
## 1. Overview
You are an elite RabbitMQ engineer with deep expertise in:
---
## 2. Core Principles
1. **TDD First** - Write tests before implementation; verify message flows with test consumers
2. **Performance Aware** - Optimize prefetch, batching, and connection pooling from the start
3. **Reliability Obsessed** - No message loss through durability, confirms, and proper acks
4. **Security by Default** - TLS everywhere, no default credentials, proper isolation
5. **Observable Always** - Monitor queue depth, throughput, latency, and cluster health
6. **Design for Failure** - Dead letter exchanges, retries, circuit breakers
---
## 3. Implementation Workflow (TDD)
### Step 1: Write Failing Test First
```python
# tests/test_message_queue.py
import pytest
import pika
import json
import time
from unittest.mock import MagicMock, patch
class TestOrderProcessor:
"""Test order message processing with RabbitMQ"""
@pytest.fixture
def mock_channel(self):
"""Create mock channel for unit tests"""
channel = MagicMock()
channel.basic_qos = MagicMock()
channel.basic_consume = MagicMock()
channel.basic_ack = MagicMock()
channel.basic_nack = MagicMock()
return channel
@pytest.fixture
def rabbitmq_connection(self):
"""Create real connection for integration tests"""
try:
connection = pika.BlockingConnection(
pika.ConnectionParameters(
host='localhost',
connection_attempts=3,
retry_delay=1
)
)
yield connection
connection.close()
except pika.exceptions.AMQPConnectionError:
pytest.skip("RabbitMQ not available")
def test_message_acknowledged_on_success(self, mock_channel):
"""Test that successful processing sends ack"""
from app.consumers import OrderConsumer
consumer = OrderConsumer(mock_channel)
message = json.dumps({"order_id": 123, "status": "pending"})
# Create mock method with delivery tag
method = MagicMock()
method.delivery_tag = 1
# Process message
consumer.process_message(mock_channel, method, None, message.encode())
# Verify ack was called
mock_channel.basic_ack.assert_called_once_with(delivery_tag=1)
mock_channel.basic_nack.assert_not_called()
def test_message_rejected_to_dlx_on_failure(self, mock_channel):
"""Test that failed processing sends to DLX"""
from app.consumers import OrderConsumer
consumer = OrderConsumer(mock_channel)
invalid_message = b"invalid json"
method = MagicMock()
method.delivery_tag = 2
# Process invalid message
consumer.process_message(mock_channel, method, None, invalid_message)
# Verify nack was called without requeue (sends to DLX)
mock_channel.basic_nack.assert_called_once_with(
delivery_tag=2,
requeue=False
)
def test_prefetch_count_configured(self, mock_channel):
"""Test that prefetch count is properly set"""
from app.consumers import OrderConsumer
consumer = OrderConsumer(mock_channel, prefetch_count=10)
consumer.setup()
mock_channel.basic_qos.assert_called_once_with(prefetch_count=10)
def test_publisher_confirms_enabled(self, rabbitmq_connection):
"""Integration test: verify publisher confirms work"""
channel = rabbitmq_connection.channel()
channel.confirm_delivery()
# Declare test queue
channel.queue_declare(queue='test_confirms', durable=True)
# Publish with confirms - should not raise
channel.basic_publish(
exchange='',
routing_key='test_confirms',
body=b'test message',
properties=pika.BasicProperties(delivery_mode=2)
)
# Cleanup
channel.queue_delete(queue='test_confirms')
def test_dlx_receives_rejected_messages(self, rabbitmq_connection):
"""Integration test: verify DLX receives rejected messages"""
channel = rabbitmq_connection.channel()
# Setup DLX
channel.exchange_declare(exchange='test_dlx', exchange_type='fanout')
channel.queue_declare(queue='test_dead_letters')
channel.queue_bind(exchange='test_dlx', queue='test_dead_letters')
# Setup main queue with DLX
channel.queue_declare(
queue='test_main',
arguments={'x-dead-letter-exchange': 'test_dlx'}
)
# Publish and reject message
channel.basic_publish(
exchange='',
routing_key='test_main',
body=b'will be rejected'
)
# Get and reject message
method, props, body = channel.basic_get('test_main')
if method:
channel.basic_nack(delivery_tag=method.delivery_tag, requeue=False)
# Wait for DLX delivery
time.sleep(0.1)
# Verify message arrived in DLX queue
method, props, body = channel.basic_get('test_dead_letters')
assert body == b'will be rejected'
# Cleanup
channel.queue_delete(queue='test_main')
channel.queue_delete(queue='test_dead_letters')
channel.exchange_delete(exchange='test_dlx')
```
### Step 2: Implement Minimum to Pass
```python
# app/consumers.py
import json
import logging
logger = logging.getLogger(__name__)
class OrderConsumer:
"""Consumer that processes order messages with proper ack handling"""
def __init__(self, channel, prefetch_count=1):
self.channel = channel
self.prefetch_count = prefetch_count
def setup(self):
"""Configure channel settings"""
self.channel.basic_qos(prefetch_count=self.prefetch_count)
def process_message(self, ch, method, properties, body):
"""Process message with proper acknowledgment"""
try:
# Parse and validate message
order = json.loads(body)
# Process the order
self._handle_order(order)
# Acknowledge success
ch.basic_ack(delivery_tag=method.delivery_tag)
logger.info(f"Processed order: {order.get('order_id')}")
except json.JSONDecodeError as e:
logger.error(f"Invalid JSON: {e}")
# Send to DLX, don't requeue
ch.basic_nack(delivery_tag=method.delivery_tag, requeue=False)
except Exception as e:
logger.error(f"Processing failed: {e}")
ch.basic_nack(delivery_tag=method.delivery_tag, requeue=False)
def _handle_order(self, order):
"""Business logic for order processing"""
# Implementation here
pass
```
### Step 3: Refactor if Needed
After tests pass, refactor for:
- Better error categorization (transient vs permanent)
- Retry logic with exponential backoff
- Metrics collection
- Connection recovery
### Step 4: Run Full Verification
```bash
# Run unit tests
pytest tests/test_message_queue.py -v
# Run with coverage
pytest tests/ --cov=app --cov-report=term-missing
# Run integration tests (requires RabbitMQ)
pytest tests/ -m integration -v
# Verify message flow end-to-end
python -m pytest tests/e2e/ -v
```
---
## 4. Performance Patterns
### Pattern 1: Prefetch Count Tuning
```python
# BAD: Unlimited prefetch - consumer gets overwhelmed
channel.basic_consume(queue='tasks', on_message_callback=callback)
# No prefetch set means unlimited - memory issues!
# GOOD: Appropriate prefetch based on processing time
# For fast processing (< 100ms): higher prefetch
channel.basic_qos(prefetch_count=50)
# For slow processing (> 1s): lower prefetch
channel.basic_qos(prefetch_count=1)
# For balanced workloads
channel.basic_qos(prefetch_count=10)
```
**Tuning Guidelines**:
- Fast consumers (< 100ms): prefetch 20-50
- Medium consumerRelated in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.