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/Component/Messenger/Tests
Fabien Potencier 6ffad7bba4 feature #30759 [Messenger] Adding the "sync" transport to call handlers synchronously (weaverryan)
This PR was merged into the 4.3-dev branch.

Discussion
----------

[Messenger] Adding the "sync" transport to call handlers synchronously

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | none
| License       | MIT
| Doc PR        | symfony/symfony-docs#11236

This adds a `sync://` transport that just calls the handlers immediately. Why? This allows you to route your messages to some "async" transport. But then, when developing locally or running your tests, you can choose to run them synchronously instead:

```yml
# config/packages/messenger.yaml
framework:
    messenger:
        transports:
            async: '%env(MESSENGER_TRANSPORT_DSN)%'
        routing:
            'App\Message\SmsNotification': async
            'App\Message\OtherMessage': async
```

```
# .env
# by default, handle this sync
MESSENGER_TRANSPORT_DSN=sync://
```

```
# .env.local on production (or set this via real env vars)
# on production, use amqp
MESSENGER_TRANSPORT_DSN=amqp://.......
```

Cheers!

Commits
-------

3da5a438aa Adding the "sync" transport to call handlers synchronously
2019-03-30 08:22:14 +01:00
..
Command [Messenger] ReceiverInterface::handle() to get() & Worker with prioritized transports 2019-03-30 08:01:26 +01:00
DataCollector fixed CS 2019-01-16 19:35:49 +01:00
DependencyInjection [Messenger] ReceiverInterface::handle() to get() & Worker with prioritized transports 2019-03-30 08:01:26 +01:00
Fixtures [Messenger] ReceiverInterface::handle() to get() & Worker with prioritized transports 2019-03-30 08:01:26 +01:00
Handler fixed CS 2019-01-16 21:35:37 +01:00
Middleware Adding the "sync" transport to call handlers synchronously 2019-03-28 14:59:51 -04:00
Retry Adding global retry support, events & more to messenger transport 2019-03-23 09:39:27 -04:00
Stamp Fixing bad return on getter 2019-03-26 23:10:31 -04:00
Transport [Messenger] ReceiverInterface::handle() to get() & Worker with prioritized transports 2019-03-30 08:01:26 +01:00
Worker [Messenger] ReceiverInterface::handle() to get() & Worker with prioritized transports 2019-03-30 08:01:26 +01:00
EnvelopeTest.php Adding global retry support, events & more to messenger transport 2019-03-23 09:39:27 -04:00
HandleTraitTest.php [Messenger] Add a trait for synchronous query & command buses 2018-11-20 19:19:09 +01:00
MessageBusTest.php fixed CS 2019-01-16 21:35:37 +01:00
RoutableMessageBusTest.php Fixing a bug where a transport could receive a message and dispatch it to a different bus 2019-03-23 21:29:45 +07:00
TraceableMessageBusTest.php fixed CS 2019-01-16 21:35:37 +01:00
WorkerTest.php [Messenger] ReceiverInterface::handle() to get() & Worker with prioritized transports 2019-03-30 08:01:26 +01:00