tienvx/pact-messenger-bundle 问题修复 & 功能扩展

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

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

tienvx/pact-messenger-bundle

最新稳定版本:v1.0.0

Composer 安装命令:

composer require tienvx/pact-messenger-bundle

包简介

Pact Messenger Bundle

README 文档

README

This Symfony Bundle allow collecting dispatched message using Symfony Messenger.

Installation

composer require tienvx/pact-messenger-bundle

Documentation

namespace App\MessageDispatcher;

use App\Message\UserCreated;
use Tienvx\Bundle\PactMessengerBundle\Service\EnvelopeCollectorInterface;
use Tienvx\Bundle\PactProviderBundle\Attribute\AsMessageDispatcher;
use Tienvx\Bundle\PactProviderBundle\Model\Message;
use Tienvx\Bundle\PactProviderBundle\MessageDispatcher\DispatcherInterface;

#[AsMessageDispatcher(description: 'User created message')]
class UserDispatcher implements DispatcherInterface
{
    public function __construct(private EnvelopeCollectorInterface $collector)
    {
    }

    public function dispatch(): ?Message
    {
        $envelope = $this->collector->getSingle(UserCreated::class);
        if (!$envelope) {
            return null;
        }
        $message = $envelope->getMessage();
        if (!$message instanceof UserCreated) {
            return null;
        }

        return new Message(
            \json_encode([
                'class' => UserCreated::class,
                'id' => $message->userId,
            ]),
            'application/json',
            json_encode(['contentType' => 'application/json'])
        );
    }
}

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-03-28