new-immo-group/messenger-transport-sqs-iam 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

new-immo-group/messenger-transport-sqs-iam

Composer 安装命令:

composer require new-immo-group/messenger-transport-sqs-iam

包简介

aws connector handling ini IAM files to access IAM roles

README 文档

README

This lib allows a simpler integration of AWS's SQS queues through IAM authentication.

It will register a new Messenger Transport for any DSN matching ^https://sqs..

Installation

$ composer require new-immo-group/messenger-transport-sqs-iam

Configuration

Env variables

These env variables will be required:

AWS_REGION=                         # in my case, eu-west-3
AWS_VERSION=                        # generically latest
AWS_SDK_LOAD_NONDEFAULT_CONFIG=true # whether to load .aws/config
AWS_PROFILE=                        # profile in $HOME/.aws/config you want to load
AWS_ACCOUNT_ID=
MESSENGER_TRANSPORT_DSN=https://sqs.${AWS_REGION}.amazonaws.com/${AWS_ACCOUNT_ID}

AWS SDK

The files $HOME/.aws/config and $HOME/.aws/credentials must exists on the host.

Note that if the env variable AWS_SDK_LOAD_NONDEFAULT_CONFIG is set, when loading .aws/credentials the AWS-SDK will also load .aws/config.

If there is an active open_basedir() restriction, make sure to add $HOME/.aws to the allowed path list.

Symfony

Register the SQS transport

services:
  NewImmoGroup\AwsBroker\SqsTransportFactory:
    class: NewImmoGroup\AwsBroker\SqsTransportFactory
    tags: [messenger.transport_factory]
    arguments:
      $defaultOptions:
        auto_setup: true
        queue_prefix: 'some-prefix-'
        queue_tags:
          queue_env: "%env(APP_ENV)%"

We can provide the factory optional default option values:

  • auto_setup: It controls, at the Transport level, whether the queue is created automatically when a message is sent. Default to false.
  • queue_prefix: Define a prefix that will be added to the queue name.
  • queue_tags: A list of tags that will be set on all created queues.

Any of these options can be overridden at the queue level (see below).

Queue configuration example

framework:
  messenger:
    transports:
      async_fail:
        dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
        options:
          queue_name: &failed_queue_name 'async-failed'
          use_extended_configuration: true
          configure_receiver:
            idempotent_explicit_setup: true
            message_retention_period: 43200
            receive_message_wait_time_seconds: 20
            redrive_allow_policy: 'allowAll'
        retry_strategy:
          max_retries: 20

      async:
        dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
        failure_transport: async_fail
        options:
          queue_name: 'async'
          use_extended_configuration: true
          configure_receiver:
            idempotent_explicit_setup: true
            delay_seconds: 0
            message_retention_period: 43200
            receive_message_wait_time_seconds: 20
            redrive_policy:
              max_receive_count: 10
              dead_letter_target_name: *failed_queue_name

Here is the spec of the configuration of the options :

queue_prefix
facultative a queue prefix
queue_name
mandatory the queue name
auto_setup
facultative the option for a queue to be auto-created when it does not exist (mutually exclusive with configure_receiver.idempotent_explicit_setup)
aws_client_options
facultative Options to give to AWS's SDK
use_extended_configuration: true
facultative Opt in the second version of the implementation
configure_receiver
facultative A dictionnary to configure finely a queue from the point of view of the owner of this queue
configure_receiver.idempotent_explicit_setup
facultative When using messenger:setup, should we overwrite an existing queue config to match the description of the queue (mutually exclusive with auto_setup
configure_receiver.idempotent_explicit_setup
facultative When using messenger:setup, should we overwrite an existing queue config to match the description of the queue (mutually exclusive with auto_setup
configure_receiver.tags
facultative A dictionnary of key and value pairs to describe the queue tags. Watch out, true and false should be quoted as strings
configure_receiver.delay_seconds
facultativeAws's DelaySeconds setting
configure_receiver.message_retention_period
facultativeAws's MessageRetentionPeriod setting
configure_receiver.receive_message_wait_time_seconds
facultativeAws's ReceiveMessageWaitTimeSeconds setting
configure_receiver.visibility_timeout
facultativeAws's VisibilityTimeout setting
configure_receiver.maximum_message_size
facultativeAws's MaximumMessageSize setting
configure_receiver.redrive_policy
facultativeAws's RedrivePolicy setting, except the dictionnary it expects has dead_letter_target_name instead of arn
configure_receiver.redrive_allow_policy
facultativeAws's RedriveAllowPolicy setting. It does not accept per queue as setting

For reference, see https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SetQueueAttributes.html

CI/Tests

PHP7.4-CLI and PHP8.1-CLI are required.

The end-to-end/functional test will require a valid AWS configuration (which usually expires after a few hours).

make test # Symfony5/PHP7.4
make test@php8 # Symfony5/PHP8.1
make test@sf6 # Symfony6/PHP8.1

AWS.SQS Permissions

Provided user should be able to call :

  • GetQueueUrl
  • CreateQueue
  • SendMessage
  • DeleteMessage
  • GetQueueAttribute
  • SetQueueAttribute
  • UntagQueue
  • TagQueue
  • ListQueueTags

new-immo-group/messenger-transport-sqs-iam 适用场景与选型建议

new-immo-group/messenger-transport-sqs-iam 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 28.09k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 11 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 new-immo-group/messenger-transport-sqs-iam 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: mit
  • 更新时间: 2022-11-21