定制 pmg/sqs-transport 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

pmg/sqs-transport

Composer 安装命令:

composer require pmg/sqs-transport

包简介

A Symfony Messenger transport for SQS

README 文档

README

⚠️ DEPRECATION NOTICE: This project is no longer maintained and might not work as expected. Use Alli Platform Bundle instead. Check this migration guide for more information: Migrating from PMG SQS Transport to Alli Platform Bundle

Installation

composer require pmg/sqs-transport

Bundle Usage

Add the PMG\SqsTransport\Bundle\PmgSqsTransportBundle to your application's kernel. By default the transport bundle will use an aws.sqs service when creating the transport factory and, by extension, the transport instances. This service name is configurable, but it should place nice with the AWS Bundle.

class AppKernel extends Kernel
{
    // ...

    public function registerBundles()
    {
        $bundles = [
            new \Aws\Symfony\AwsBundle(),
            new \PMG\SqsTransport\Bundle\PmgSqsTransportBundle(),
        ];

        // ...

        return $bundles;
    }
}

SqsClient Service Configuration

If you're not using the AwsBundle and would like to manually specify a service that contains an instance of Aws\Sqs\SqsClient, some bundle configuration is necessary.

pmg_sqs_transport:
  sqs_client_service: your_sqs_service_id

Messenger Configuration

framework:
  # ...
  messenger:
    transports:
      # will create a transport with a queue URL of
      # https://queue.amazonaws.com/80398EXAMPLE/MyQueue
      sqs: sqs://queue.amazonaws.com/80398EXAMPLE/MyQueue
      
      # this will also make an https URL:
      # https://queue.amazonaws.com/80398EXAMPLE/MyQueue
      sqs_https: sqs+https://queue.amazonaws.com/80398EXAMPLE/MyQueue

      # or you may wish to use `http://`, like if running a localstack
      # instance for local dev. Queue url would be http://localhost:4576/queue/MyQueue
      sqs_http: sqs+http://localhost:4576/queue/MyQueue

      # specify how many message to receive at once with query params
      # must be >= 1 and <= 10
      sqs: sqs://queue.amazonaws.com/80398EXAMPLE/MyQueue?receive_count=10

      # specify a wait timeout when making a call to receive messages (in seconds)
      sqs: sqs://queue.amazonaws.com/80398EXAMPLE/MyQueue?receive_wait=10

      # or specify those things in `options`
      sqs:
        dsn: sqs://queue.amazonaws.com/80398EXAMPLE/MyQueue
        options:
          receive_wait: 10
          receive_count: 5

SQS Stamps

  • PMG\SqsTransport\Stamp\SqsReceiptHandleStamp: added when a message is received from SQS via the get method. This allows the message to be acked or rejected later.
  • PMG\SqsTransport\Stamp\SqsStringAttributeStamp: Allows you to add a custom message attribute. with a DataType set to String and a string value.
  • PMG\SqsTransport\Stamp\SqsNumberAttributeStamp: Allows you to add a custom message attribute. with a DataType set to Number and a numeric value.
$messageBus->dispatch(new YourMessage(), [
  new SqsStringAttributeStamp('stringAttributeName', 'attributeValue'),
  new SqsNumberAttributeStamp('numberAttributeName', 123),
]);

SQS Has a limit of 10 attributes per message, but the transport will generally use at least one attribute to send the headers from the transport serializer.

On Retries

The symfony messenger worker modifies an envelope with some retry metadata. Since messages in SQS cannot be modified in place, we just put a new message into the queue when that happens and the subsequent call to ack removes the existing message.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-09-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固