renatomaldonado/laravel-sqs-consume
Composer 安装命令:
composer require renatomaldonado/laravel-sqs-consume
包简介
Consumer of sqs message
README 文档
README
A custom SQS connector for Laravel (or Lumen) that supports many jobs e any message types based in library https://github.com/dusterio/laravel-plain-sqs.
But each job will be responsible for one queue sqs. All will be execute, if message in some queue exists it will be processed.
Dependencies
- PHP >= 7.1.3
- Laravel (or Lumen) >= 7.0
Installation via Composer
To install simply run:
composer require renatomaldonado/laravel-sqs-consume
Usage in Laravel 7
// Add in your config/app.php 'providers' => [ '...', 'Renatomaldonado\LaravelSqsConsume\Provider\LaravelSQSQueueServiceProvider', ];
Usage in Lumen 7
// Add in your bootstrap/app.php $app->register(Renatomaldonado\LaravelSqsConsume\Provider\LumenSQSQueueServiceProvider::class);
Configuration
// Generate standard config file (Laravel only) php artisan vendor:publish --provider="Renatomaldonado\LaravelSqsConsume\Provider\LaravelSQSQueueServiceProvider" // In Lumen, create it manually (see example below) and register it in bootstrap/app.php $app->configure('sqs-consumer');
Edit config/sqs-consumer.php to suit your needs. This config matches SQS queues with handler classes.
return [ /** * Queues array for execute in each job */ 'queues' => ['queue-sqs-name-example', 'queue-sqs-name-example-two'], 'handlers' => [ 'queue-sqs-name-example' => 'your-job', 'queue-sqs-name-example-two' => 'your-job-two', ], 'default-handler' => 'job-default' ];
If queue is not found in 'handlers' array, SQS payload is passed to default handler.
Add sqs-consumer connection to your config/queue.php, eg:
... 'sqs-consumer' => [ 'driver' => 'sqs-consumer', 'key' => env('AWS_KEY', ''), 'secret' => env('AWS_SECRET', ''), 'prefix' => 'https://sqs.ea-northheast-1.amazonaws.com/123456/', 'queue' => 'queue-sqs-name-example', 'region' => 'ea-northheast-1', ], ...
In your .env file, choose sqs-consumer as your new default queue connection:
QUEUE_CONNECTION=sqs-consumer
Receiving from SQS
If a third-party application is creating custom-format JSON messages or any message, just add a handler in the config file and implement a handler class as follows:
use Illuminate\Contracts\Queue\Job as LaravelJob; class ExempleJob extends Job { protected $data; /** * @param LaravelJob $job * @param $data */ public function handle(LaravelJob $job, $data) { // This is incoming JSON payload, already decoded to an array var_dump($data); // Raw JSON payload from SQS, if necessary var_dump($job->getRawBody()); } }
renatomaldonado/laravel-sqs-consume 适用场景与选型建议
renatomaldonado/laravel-sqs-consume 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.33k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 04 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「queue」 「php」 「aws」 「laravel」 「sqs」 「consumer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 renatomaldonado/laravel-sqs-consume 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 renatomaldonado/laravel-sqs-consume 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 renatomaldonado/laravel-sqs-consume 相关的其它包
同方向 / 同关键字的高下载量 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
统计信息
- 总下载量: 10.33k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-04-24