joblocal/laravel-sqs-sns-subscription-queue
Composer 安装命令:
composer require joblocal/laravel-sqs-sns-subscription-queue
包简介
A simple Laravel service provider which adds a new queue connector to handle SNS subscription queues.
README 文档
README
A simple extension to the Illuminate/Queue queue system used in Laravel and Lumen.
Using this connector allows SQS messages originating from a SNS subscription to be worked on with Illuminate\Queue\Jobs\SqsJob.
This is especially useful in a miroservice architecture where multiple services subscribe to a common topic with their queues.
Understand that this package will not handle publishing to SNS, please use the AWS SDK to publish an event to SNS.
Requirements
- Laravel (tested with version 5.8)
- or Lumen (tested with version 5.8)
Usage
Add the LaravelSqsSnsSubscriptionQueue ServiceProvider to your application.
Laravel
Registering Service Providers in Laravel
'providers' => [ // ... Joblocal\LaravelSqsSnsSubscriptionQueue\SqsSnsServiceProvider::class, ],
Lumen
Registering Service Providers in Lumen
$app->register(Joblocal\LaravelSqsSnsSubscriptionQueue\SqsSnsServiceProvider::class);
Configuration
You'll need to configure the queue connection in your config/queue.php
'connections' => [ 'sqs-sns' => [ 'driver' => 'sqs-sns', 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'queue' => env('SQS_QUEUE', 'your-queue-url'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 'routes' => [ // you can use the "Subject" field 'Subject' => 'App\\Jobs\\YourJob', // or the "TopicArn" of your SQS message 'TopicArn:123' => 'App\\Jobs\\YourJob', // to specify which job class should handle the job ], ], ],
Once the sqs-sns queue connector is configured you can start using it by setting queue driver to 'sqs-sns' in your .env file.
Job class example
use Illuminate\Bus\Queueable; use Illuminate\Queue\SerializesModels; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; /** * Example Job class */ class Job implements ShouldQueue { use InteractsWithQueue, Queueable, SerializesModels; /** * @param string $subject SNS Subject * @param array $payload JSON decoded 'Message' */ public function __construct(string $subject, array $payload) { } }
Message transformation
When SNS publishes to SQS queues the received message signature is as follows:
{
"Type" : "Notification",
"MessageId" : "63a3f6b6-d533-4a47-aef9-fcf5cf758c76",
"TopicArn" : "arn:aws:sns:us-west-2:123456789012:MyTopic",
"Subject" : "Testing publish to subscribed queues",
"Message" : "Hello world!",
"Timestamp" : "2017-03-29T05:12:16.901Z",
"SignatureVersion" : "1",
"Signature" : "...",
"SigningCertURL" : "...",
"UnsubscribeURL" : "..."
}
Illuminate\Queue\Jobs\SqsJob requires the following signature:
{
"job": "Illuminate\\Queue\\CallQueuedHandler@call",
"data": {
"commandName": "App\\Jobs\\YourJob",
"command": "...",
}
}
Installation
The best way to install laravel-sqs-sns-subscription is by using Composer.
To install the most recent version:
php composer.phar require joblocal/laravel-sqs-sns-subscription-queue
joblocal/laravel-sqs-sns-subscription-queue 适用场景与选型建议
joblocal/laravel-sqs-sns-subscription-queue 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 457.63k 次下载、GitHub Stars 达 48, 最近一次更新时间为 2016 年 08 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「queue」 「aws」 「laravel」 「sqs」 「SNS」 「lumen」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 joblocal/laravel-sqs-sns-subscription-queue 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 joblocal/laravel-sqs-sns-subscription-queue 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 joblocal/laravel-sqs-sns-subscription-queue 相关的其它包
同方向 / 同关键字的高下载量 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
统计信息
- 总下载量: 457.63k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 48
- 点击次数: 36
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-08-26