sumaiazaman/laravel-sqs-redrive
Composer 安装命令:
composer require sumaiazaman/laravel-sqs-redrive
包简介
Native AWS SQS dead letter queue (DLQ) support for Laravel. Automatically detects redrive policies, aligns retry counts with maxReceiveCount, and lets SQS handle failed job routing.
README 文档
README
Native AWS SQS dead letter queue (DLQ) support for Laravel.
When an SQS queue has a redrive policy configured, this package automatically:
- Detects the redrive policy from SQS and caches it per queue URL
- Aligns Laravel's retry count with SQS
maxReceiveCount - Skips message deletion on failure so SQS natively routes failed messages to the dead letter queue
The Problem
Laravel's default SQS driver deletes messages from SQS immediately after a job fails. This bypasses SQS's native dead letter queue routing entirely — failed messages never reach your DLQ.
Job fails → Laravel calls deleteMessage → Message gone → DLQ never receives it
The Solution
This package lets SQS handle the routing:
Job fails → Message stays in queue → SQS increments receive count → After maxReceiveCount, SQS moves to DLQ
Installation
composer require sumaiazaman/laravel-sqs-redrive
The package auto-discovers the service provider.
Configuration
In your config/queue.php, add a new connection using the sqs-redrive driver:
'connections' => [ 'sqs-redrive' => [ 'driver' => 'sqs-redrive', 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 'queue' => env('SQS_QUEUE', 'default'), 'suffix' => env('SQS_SUFFIX'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), ], ],
Then set your default queue connection:
QUEUE_CONNECTION=sqs-redrive
That's it. No other configuration needed — the package reads the redrive policy directly from SQS.
How It Works
1. Automatic Redrive Policy Detection
When a job is popped from the queue, the package fetches and caches the queue's redrive policy via the SQS getQueueAttributes API. The result is cached for the lifetime of the worker process.
2. Retry Count Alignment
If a redrive policy exists, maxTries() returns maxReceiveCount from the policy. This keeps Laravel's retry logic in sync with SQS — no more conflicts between Laravel's $tries and SQS's receive count.
3. Smart Deletion
- Successful jobs: Deleted from SQS normally
- Failed jobs without DLQ: Deleted from SQS normally (same as default behavior)
- Failed jobs with DLQ: Skipped deletion — SQS handles routing to DLQ
API
The SqsRedriveJob class provides additional methods:
// Check if the queue has a dead letter queue configured $job->hasDeadLetterQueue(); // bool // Get the full redrive policy $job->getRedrivePolicy(); // ['maxReceiveCount' => 3, 'deadLetterTargetArn' => '...'] // maxTries() automatically uses maxReceiveCount when DLQ is configured $job->maxTries(); // 3
Requirements
- PHP 8.2+
- Laravel 12.x or 13.x
- AWS SQS with a redrive policy configured
Testing
composer test
License
MIT
sumaiazaman/laravel-sqs-redrive 适用场景与选型建议
sumaiazaman/laravel-sqs-redrive 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「queue」 「aws」 「laravel」 「sqs」 「dlq」 「dead-letter-queue」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sumaiazaman/laravel-sqs-redrive 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sumaiazaman/laravel-sqs-redrive 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sumaiazaman/laravel-sqs-redrive 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP AMQP Binding Library
This package includes a script and fail2ban configuration that allows you to use fail2ban when utilizing AWS elastic load balancer (ELB) and an apache webserver.
A Laravel package to monitor queue jobs.
Elastic Driver for Laravel Scout
simple api library.
A replica of the AWS Elastic Beanstalk worker SQS daemon (sqsd) in PHP
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 44
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-31