定制 happyr/bref-messenger-failure-strategies 二次开发

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

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

happyr/bref-messenger-failure-strategies

Composer 安装命令:

composer require happyr/bref-messenger-failure-strategies

包简介

Make sure you can use Bref Symfony Messenger failure strategies

README 文档

README

So you have fallen in love with Bref and you really want to use Symfony's excellent Messenger component. You've probably also installed the Bref Symfony Messenger bundle that allows you to publish messages on SQS and SNS etc. But you are missing something... You want to be able to use Symfony Messenger retry strategies, right?

This is the package for you!

Install

composer require happyr/bref-messenger-failure-strategies

Now you have a class called Happyr\BrefMessenger\SymfonyBusDriver that implements Bref\Symfony\Messenger\Service\BusDriver. Feel free to configure your consumers with this new class.

Example

On each consumer you can choose to let Symfony handle failures as described in the documentation.

# config/packages/messenger.yaml

framework:
    messenger:
        failure_transport: failed
        transports:
            failed: 'doctrine://default?queue_name=failed'
            workqueue:
              dsn: 'https://sqs.us-east-1.amazonaws.com/123456789/my-queue'
              retry_strategy:
                  max_retries: 3
                  # milliseconds delay
                  delay: 1000
                  multiplier: 2
                  max_delay: 60

services:
    Happyr\BrefMessenger\ExceptionLogger:
        autowire: true
        autoconfigure: true

    Happyr\BrefMessenger\SymfonyBusDriver:
        autowire: true

    Bref\Symfony\Messenger\Service\Sqs\SqsConsumer:
        arguments:
            - '@Happyr\BrefMessenger\SymfonyBusDriver'
            - '@messenger.routable_message_bus'
            - '@Symfony\Component\Messenger\Transport\Serialization\SerializerInterface'
            - 'my_sqs' # Same as transport name

# ...

The delay is only supported on SQS "normal queue". If you are using SNS or SQS FIFO you should use the failure queue directly.

# config/packages/messenger.yaml

framework:
    messenger:
        failure_transport: failed
        transports:
            failed: 'doctrine://default?queue_name=failed'
            workqueue:
              dsn: 'sns://arn:aws:sns:us-east-1:1234567890:foobar'
              retry_strategy:
                  max_retries: 0
services:
    # ...

Make sure you re-run the failure queue time to time. The following config will run a script for 5 seconds every 30 minutes. It will run for 5 seconds even though no messages has failed.

# serverless.yml

functions:
    website:
        # ...
    consumer:
        # ...

    console:
        handler: bin/console
        Timeout: 120 # in seconds
        layers:
            - ${bref:layer.php-74}
            - ${bref:layer.console}
        events:
            - schedule:
                  rate: rate(30 minutes)
                  input:
                      cli: messenger:consume failed --time-limit=5 --limit=50

happyr/bref-messenger-failure-strategies 适用场景与选型建议

happyr/bref-messenger-failure-strategies 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 169.82k 次下载、GitHub Stars 达 11, 最近一次更新时间为 2020 年 01 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 happyr/bref-messenger-failure-strategies 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-01-19