williamrijksen/symfony-messenger-azure

symfony/messenger 组件的 Azure 适配器

0.1.0 2018-12-12 15:19 UTC

This package is auto-updated.

Last update: 2024-09-14 04:56:40 UTC


README

Build Status

这是 symfony/messenger 组件在 Azure 上用于主题和订阅者的一个实验性接收器/发送器。

快速开始

首先:这里使用主题/订阅方式,如这里所述。请确保您已准备好连接字符串。

目前我们提供了一个已预先配置了接收器和发送器的 Messenger 组件的包。

composer require symfony/messenger williamrijksen/symfony-messenger-azure

添加包 new WilliamRijksen\AzureMessengerAdapter\Bundle\AzureMessengerAdapterBundle()

添加以下配置

azure_messenger_adapter:
    azure:
        connectionString: 'Endpoint=<your token>'
        subscriptionName: 'name of subscription' #topic will be automatically created by this bundle
    messages:
        'App\Message\Foo': 'foo_topic' #topic will be automatically created by this bundle

添加一个消息处理器

<?php

namespace App\MessageHandler;

use App\Message\Foo;

final class FooHandler
{
    public function __invoke(Foo $message)
    {
    }
}

标记它

services:
  App\MessageHandler\FooHandler:
      tags:
          - { name: messenger.message_handler }

完成!

运行 bin/console messenger:consume-messages azure_messenger.receiver.foo_queue 从总线中分发消息

<?php
$bus->dispatch(new Foo());

配置参考

azure_messenger_adapter:
    azure:
        connectionString: 'Endpoint=<your token>'
        subscriptionName: 'name of subscription'
    messages:
        'App\Message\Foo': 'foo_topic'

链接