This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection
Samuel ROZE aa04d06dc4 feature #26632 [Messenger] Add AMQP adapter (sroze)
This PR was squashed before being merged into the 4.1-dev branch (closes #26632).

Discussion
----------

[Messenger] Add AMQP adapter

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | ø
| License       | MIT

- [x] Depends on the Messenger component #24411
- [x] Add tests once we are all happy about the structure

---

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](https://github.com/sroze/enqueue-bridge) can also be used.

Configuring the adapter is as simple as the following configuration:
```yaml
# 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.

```yaml
# 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.

```yaml
# 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
```

Commits
-------

798c230ad5 [Messenger] Add AMQP adapter
2018-04-12 09:16:00 +01:00
..
Compiler Merge branch '3.4' into 4.0 2018-04-04 20:24:59 +02:00
config Update default translations path 2017-11-21 09:08:09 -05:00
Fixtures [Messenger] Add AMQP adapter 2018-04-12 09:15:52 +01:00
translations Update default translations path 2017-11-21 09:08:09 -05:00
ConfigurationTest.php [Messenger] Add AMQP adapter 2018-04-12 09:15:52 +01:00
FrameworkExtensionTest.php feature #26632 [Messenger] Add AMQP adapter (sroze) 2018-04-12 09:16:00 +01:00
PhpFrameworkExtensionTest.php [FrameworkBundle] Remove unused code in test 2016-01-31 22:09:31 +01:00
XmlFrameworkExtensionTest.php disable the assets helper when assets are disabled 2016-02-20 17:58:32 +01:00
YamlFrameworkExtensionTest.php [FrameworkBundle] Only enable CSRF protection when enabled in config 2013-10-28 10:42:32 +01:00