williamrijksen/symfony-messenger-azure

Azure adapter for symfony/messenger component

0.1.0 2018-12-12 15:19 UTC

This package is auto-updated.

Last update: 2024-03-14 04:01:10 UTC


README

Build Status

This is an experimental Receiver/Sender on Azure for the symfony/messenger component for topic and subscribers.

Quick start

First of all: This uses topics / subscriptions like described here. Make sure you have a connection-string ready.

For now we're exposing a bundle which is pre-configuring the Messenger component with receivers and senders.

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

Add the bundle new WilliamRijksen\AzureMessengerAdapter\Bundle\AzureMessengerAdapterBundle().

Add the following configuration:

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

Add a message handler:

<?php

namespace App\MessageHandler;

use App\Message\Foo;

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

Tag it:

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

You're done!

Launch bin/console messenger:consume-messages azure_messenger.receiver.foo_queue and dispatch messages from the bus:

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

Configuration reference

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

Links