splashx/notification-mq-bundle

将队列添加到通知包中

安装: 7

依赖关系: 0

建议者: 0

安全: 0

星标: 1

分支: 0

类型:symfony-bundle

v0.0.1 2018-09-13 07:28 UTC

This package is not auto-updated.

Last update: 2024-09-20 21:27:21 UTC


README

此扩展提供了发送延迟消息的能力

用法

  • 安装扩展。
  • 配置 AMQPStreamConnection 连接
    PhpAmqpLib\Connection\AMQPStreamConnection:
        autowire: true
        arguments:
          - '%rabbit_host%'
          - '%rabbit_port%'
          - '%rabbit_login%'
          - '%rabbit_pass%'
    
  • 配置 MQClient
    Splashx\NotificationQueueBundle\Driver\MQClient:
    arguments:
    - '%rabbit_queue%'
    - '%rabbit_consumer%'
    - '@PhpAmqpLib\Connection\AMQPStreamConnection'
    
  • 使用以下方式配置 NotificationManager 装饰
    Splashx\NotificationQueueBundle\Model\NotificationManagerDecorator:
    decorates: 'symfony_bro.notification_core.notification_manager'
    arguments: ['@Splashx\NotificationQueueBundle\Model\NotificationManagerDecorator.inner']
    
  • 在你的 NotificationBuilder 中,使用 MQNotificationDecorator 通知类型和需要发送的延迟通知对象。
    return new MQNotificationDecorator(new TelegramNotification([
      'chat_id' => '276316291',
      'fullName' => $context->getUserChangedPost()->getFullName(),
      'postTitle' => $context->getPost()->getTitle(),
      'template' => $template->getTemplate(),
    ]));
    
  • 配置命令
    splashx_notification_queue.command.mqread_queue_command:
    class: Splashx\NotificationQueueBundle\Command\MQReadQueueCommand
    arguments: ['@symfony_bro.notification_core.notification_manager', '@Splashx\NotificationQueueBundle\Driver\MQClient']
    tags:
    - { name: console.command }
    
  • 使用 MQnotifications:readQueue 监听通知队列
  • 祝您愉快!