承接 maxgaurav/laravel-sns-sqs-queue 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

maxgaurav/laravel-sns-sqs-queue

Composer 安装命令:

composer require maxgaurav/laravel-sns-sqs-queue

包简介

Sns Messages as queues using extended laravel sqs driver.

README 文档

README

This package allows you to process sns messages posted on various topics subscribed by an SQS to be processed as a job.

The queue also processes standard jobs pushed via laravel.

This package is a great use cases for applications beings deployed to microservices.

Requirements

  • PHP >= 7.2
  • Laravel 6
  • SQS driver for laravel
  • SQS in AWS
  • SNS in AWS

Installation

Install using composer

composer require maxgaurav/laravel-sns-sqs-queue

The package will automatically register its service provider.

Configuration

In queue.php add the following driver setup

return [
    //...

    'sqs' => [
        'driver' => 'sqs',
        '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', 'your-queue-name'),
        'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
     ],

    'sns-sqs' => [
        'driver' => 'sns-sqs',
        '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', 'your-queue-name'),
        'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
        'sns-config' => [
            'topics' => [
                'topicName' => \App\Jobs\YourJob::class,
                'topic2Name' => \App\Jobs\YourOtherJob::class
                //...
            ],
            'default-job' => '', // if you want to override the default job executed for non matching topics
            'prefix' => env('SNS_PREFIX', 'arn:aws:sns:us-east-2:123345666:'), // SNS Topic Prefix (must include the last colon)
        ],
    ],

Prerequisites

  • First setup your SQS queue in AWS
  • The SQS must be subscribed to all the topics of SNS you want to process through your job.

Usage

Each job created must have two constructor inputs. First input is for the topic name the job is executing for and second is the array of json decoded data sent in the message.

class SampleJob {

    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * @var string
     */
    public $topic;

    /**
     * @var array
     */
    public $body;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($topic, $body)
    {
        $this->topic = $topic;
        $this->body = $body;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        // do your handling
    }

}

Default Job

The package uses a default job instance \MaxGaurav\LaravelSnsSqsQueue\DefaultJob for topics not mapped in the configuration. The job has a default functionality to fail for such topics. This is done to allow the application to tell that topics are not mapped.

The DefaultJob class can be replaced with a custom default job handler using key default-job. Pass your class instance and it would be used instead.

Normal Jobs

The package can also be used to push normal jobs to SQS queue as done using sqs driver. The queue would check if the job is a sns job then would map to topic name and would call the mapped jobs otherwise would fallback to default SQS driver behavior.

maxgaurav/laravel-sns-sqs-queue 适用场景与选型建议

maxgaurav/laravel-sns-sqs-queue 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.82k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2019 年 12 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「queue」 「aws」 「laravel」 「sqs」 「SNS」 「sns-sqs」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 maxgaurav/laravel-sns-sqs-queue 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 maxgaurav/laravel-sns-sqs-queue 我们能提供哪些服务?
定制开发 / 二次开发

基于 maxgaurav/laravel-sns-sqs-queue 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3.82k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 11
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-12-24