create-dead-letter-queue

为 PHP 8.4 生成死信队列组件。实现失败消息捕获、指数退避重试策略和失败分类的处理逻辑,并附带对应的单元测试。

仓库最近推送
GitHub Stars
109
Forks
26
Issues / PRs
1

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "create-dead-letter-queue":https://skillpi.com/zh/skills/deepskill-5b61121031e546c0060dc6acbed7f217c94f2e444ec81f460cf492cb402232d1。安装前核对上游来源和版本:https://github.com/dykyi-roman/awesome-claude-code。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

为 PHP 8.4 生成死信队列组件。实现失败消息捕获、指数退避重试策略和失败分类的处理逻辑,并附带对应的单元测试。

0 下载

介绍来源: third_party · dykyi-roman · 0.0.1 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
适合谁
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: create-dead-letter-queue
description: Generates Dead Letter Queue components for PHP 8.4. Creates failed message capture, retry strategy with exponential backoff, failure classification, and unit tests.

Dead Letter Queue Generator

Creates Dead Letter Queue pattern infrastructure for capturing and retrying failed messages.

When to Use

Scenario Example
Poison messages Messages that always cause handler failures
Processing failures Temporary infrastructure issues (DB down, timeout)
Audit trail Track all failed message processing attempts
Retry mechanism Automatic retry with exponential backoff
Monitoring Alert on DLQ threshold exceeded

Component Characteristics

DeadLetterMessage

  • Entity capturing failed message details
  • Original message body, headers, routing key
  • Error message and stack trace
  • Attempt count and timestamps
  • Failure classification (Transient, Permanent, Unknown)

DeadLetterStoreInterface

  • Application layer port
  • store(DeadLetterMessage): void
  • findRetryable(int limit): array — find messages eligible for retry
  • markRetried(string id): void — increment attempt count
  • markResolved(string id): void — mark as successfully reprocessed
  • purge(DateTimeImmutable before): int — remove old entries

DeadLetterHandler

  • Catches exceptions from message handlers
  • Classifies failure type (transient vs permanent)
  • Stores to DLQ with full context
  • Logs failure details

RetryStrategy

  • Configurable max attempts
  • Exponential backoff with jitter
  • Failure type classification
  • Skip permanent failures

FailureClassifier

  • Classifies exceptions as Transient or Permanent
  • Configurable exception mapping
  • Default: ConnectionException=Transient, ValidationException=Permanent

DlqProcessor

  • Processes retryable messages from DLQ
  • Applies RetryStrategy for backoff
  • Removes successfully processed messages
  • Re-stores still-failing messages

Generation Process

Step 1: Analyze Request

Determine:

  • Storage backend (Database)
  • Max retry attempts (default: 5)
  • Backoff strategy (exponential with jitter)

Step 2: Generate Core Components

  1. Domain Layer (src/Domain/Shared/DeadLetter/)

    • FailureType.php — Enum (Transient, Permanent, Unknown)
    • DeadLetterMessage.php — Message entity
  2. Application Layer (src/Application/Shared/DeadLetter/)

    • DeadLetterStoreInterface.php — Storage port
    • DeadLetterHandler.php — Exception handler
    • RetryStrategy.php — Retry configuration and backoff calculation
    • FailureClassifier.php — Exception classification
    • DlqProcessor.php — Retry processor
  3. Infrastructure Layer (src/Infrastructure/DeadLetter/)

    • DatabaseDeadLetterStore.php — PDO implementation
    • Database migration
  4. Tests

    • DeadLetterMessageTest.php
    • RetryStrategyTest.php
    • FailureClassifierTest.php
    • DlqProcessorTest.php

File Placement

Layer Path
Domain Types src/Domain/Shared/DeadLetter/
Application src/Application/Shared/DeadLetter/
Infrastructure src/Infrastructure/DeadLetter/
Unit Tests tests/Unit/{Layer}/{Path}/

Key Principles

Failure Classification

  1. Transient: Connection errors, timeouts, rate limits — eligible for retry
  2. Permanent: Validation errors, business rule violations — never retry
  3. Unknown: Unclassified exceptions — retry with caution

Retry Strategy

  1. Max attempts configurable (default: 5)
  2. Exponential backoff: delay = baseDelay * 2^attempt
  3. Jitter: random ±25% to prevent thundering herd
  4. Skip messages exceeding max attempts

Message Lifecycle

Message → Handler fails → DeadLetterHandler → Store to DLQ
                                                    ↓
                                          DlqProcessor retries
                                                    ↓
                                          Success → Remove from DLQ
                                          Failure → Re-store with incremented attempts
                                          Max exceeded → Mark as permanently failed

Naming Conventions

Component Pattern Example
Failure Enum FailureType FailureType
Message Entity DeadLetterMessage DeadLetterMessage
Store Interface DeadLetterStoreInterface DeadLetterStoreInterface
Handler DeadLetterHandler DeadLetterHandler
Strategy RetryStrategy RetryStrategy
Classifier FailureClassifier FailureClassifier
Processor DlqProcessor DlqProcessor
Test {ClassName}Test RetryStrategyTest

Quick Template Reference

DeadLetterMessage

final class DeadLetterMessage
{
    public function __construct(
        public readonly string $id,
        public readonly string $originalBody,
        public readonly string $originalRoutingKey,
        public readonly array $originalHeaders,
        public readonly string $errorMessage,
        public readonly string $errorTrace,
        public readonly FailureType $failureType,
        public readonly int $attemptCount,
        public readonly \DateTimeImmutable $failedAt,
        public readonly ?\DateTimeImmutable $nextRetryAt,
        public readonly ?\DateTimeImmutable $resolvedAt = null,
    ) {}

    public function isRetryable(int $maxAttempts): bool;
    public function withIncrementedAttempt(\DateTimeImmutable $nextRetryAt): self;
}

DeadLetterStoreInterface

interface DeadLetterStoreInterface
{
    public function store(DeadLetterMessage $message): void;
    /** @return array<DeadLetterMessage> */
    public function findRetryable(int $limit = 100): array;
    public function markRetried(string $id, \DateTimeImmutable $nextRetryAt): void;
    public function markResolved(string $id): void;
    public function purge(\DateTimeImmutable $before): int;
    public function countByType(FailureType $type): int;
}

Database Schema

CREATE TABLE dead_letter_messages (
    id VARCHAR(255) PRIMARY KEY,
    original_body TEXT NOT NULL,
    original_routing_key VARCHAR(255) NOT NULL,
    original_headers JSONB NOT NULL DEFAULT '{}',
    error_message TEXT NOT NULL,
    error_trace TEXT,
    failure_type VARCHAR(50) NOT NULL,
    attempt_count INTEGER NOT NULL DEFAULT 1,
    failed_at TIMESTAMP(6) NOT NULL,
    next_retry_at TIMESTAMP(6),
    resolved_at TIMESTAMP(6)
);

CREATE INDEX idx_dlq_retryable ON dead_letter_messages (failure_type, next_retry_at)
    WHERE resolved_at IS NULL AND failure_type != 'permanent';
CREATE INDEX idx_dlq_failed_at ON dead_letter_messages (failed_at);

References

For complete PHP templates and test examples, see:

  • references/templates.md — All component templates
  • references/examples.md — Message broker integration example and unit tests

当前收录版本

0.0.1

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值85/100

亮点

  • 提供 PHP 8.4 死信队列组件生成,解决消息处理失败、重试策略、失败分类等实际工程痛点
  • 适用于毒消息、处理失败、审计跟踪、重试机制和监控等多种场景,实用性强
触发精准95/100

亮点

  • description 明确描述功能,触发词完整,边界清晰,覆盖多种变体
结构规范95/100

亮点

  • 文档结构清晰,包含完整章节,步骤划分明确,有端到端示例和模板代码,frontmatter 完整
执行可靠90/100

亮点

  • 组件设计完整,涵盖领域层、应用层、基础设施层及测试,参数配置合理,覆盖主要异常,数据库 schema 和索引设计合理
证据可验 (前四项均值)91/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。