8000 [Messenger] Add AMQP adapter by sroze · Pull Request #26632 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Messenger] Add AMQP adapter #26632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 12, 2018
Merged

[Messenger] Add AMQP adapter #26632

merged 1 commit into from
Apr 12, 2018

Conversation

sroze
Copy link
Contributor
@sroze sroze commented Mar 22, 2018
Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? ø
License MIT

In order to give a great DX for simple needs such as sending messages through an AMQP broker such as RabbitMq, we should ship an AMQP adapter for the Messenger component within Symfony Core. It should be as simple as this proposal. We don't need to handle more specific use-cases nor brokers as other adapters such as the enqueue adapter can also be used.

Configuring the adapter is as simple as the following configuration:

# config/packages/messenger_adapters.yaml
framework:
    messenger:
        adapter: "%env(MESSENGER_DSN)%"

With the given .env for example:

MESSENGER_DSN=amqp://guest:guest@localhost:5672/%2f/messages

Keep in mind that after having configured the adapter, developers have to route their messages to the given adapter.

# config/packages/messenger_routes.yaml
framework:
    messenger:
        routing:
producer).
            'App\Message\Command\CreateNumber': messenger.default_sender

Additionally, multiple adapters can be created and messages routed to these ones.

# config/packages/messenger_routes.yaml
framework:
    messenger:
        adapters:
            commands: "amqp://guest:guest@localhost:5672/%2f/commands"
            maintenance: "amqp://guest:guest@localhost:5672/%2f/maintenance"
        routing:
producer).
            'App\Message\Command\CreateNumber': messenger.commands_sender
            'App\Message\Command\MaintenanceSpecificCommand': messenger.maintenance_sender

@sroze sroze force-pushed the add-amqp-adapter branch from dfd8442 to eede0ed Compare March 22, 2018 09:21
@sroze sroze changed the title [AMQP] Add AMQP adapter for Message component [AMQP] Add AMQP adapter for Messenger component Mar 22, 2018
@nicolas-grekas
Copy link
Member
nicolas-grekas commented Mar 22, 2018

Shouldn't this be inside the Messenger component?

use Symfony\Component\Messenger\Transport\Serialization\DecoderInterface;

/**
* Symfony Message receiver to get messages from AMQP brokers using PHP's AMQP extension.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Symfony Message -> Symfony Messenger ?

0