This is an experimental Receiver/Sender on Azure for the symfony/messenger component for topic and subscribers.
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());
azure_messenger_adapter:
azure:
connectionString: 'Endpoint=<your token>'
subscriptionName: 'name of subscription'
messages:
'App\Message\Foo': 'foo_topic'