Commit Graph

297 Commits

Author SHA1 Message Date
Nicolas Grekas
2ddb89b7a3 Revert "feature #26702 Mark ExceptionInterfaces throwable (ostrolucky)"
This reverts commit 9fda6d3ee3, reversing
changes made to ca53d3e0fd.
2018-05-30 09:26:09 +02:00
Fabien Potencier
1f4100d635 Merge branch '4.1'
* 4.1:
  Supress deprecation notices thrown when getting private servies from container in tests
  Uses `protected` for test functions
  [Messenger] Allow to scope handlers per bus
  do not mock the session in token storage tests
  [DependencyInjection] resolve array env vars
  Add Occitan plural rule
  Fix security/* cross-dependencies
  [Messenger] implement several senders using a ChainSender
  [Lock] Skip test if posix extension is not installed
  fix bug when imported routes are prefixed
  [DI] Allow defining bindings on ChildDefinition
  use strict compare in url validator
  Disallow illegal characters like "." in session.name
  [HttpKernel] do file_exists() check instead of silent notice
  Select alternatives on missing receiver arg or typo
  fix rounding from string
2018-05-21 12:10:22 +02:00
Maxime Steinhausser
6e43838c5d [Messenger] Activation middleware decorator 2018-05-20 13:30:39 +02:00
Samuel ROZE
fd810cdee0 Uses protected for test functions 2018-05-20 10:26:34 +01:00
Maxime Steinhausser
9d658e915e [Messenger] Allow to scope handlers per bus 2018-05-19 12:07:07 +02:00
Samuel ROZE
160c97e57e feature #27230 [Messenger] Select alternatives on missing receiver arg or typo (yceruto)
This PR was merged into the 4.1 branch.

Discussion
----------

[Messenger] Select alternatives on missing receiver arg or typo

| Q             | A
| ------------- | ---
| Branch?       | 4.1
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

If there is more than one receiver available - `bin/console messenger:consume-messages`:
![messenger_consume_missing](https://user-images.githubusercontent.com/2028198/39895594-d4f652c6-5478-11e8-87cf-a1e08e681320.png)

If typo and there is similarities - `bin/console messenger:consume-messages amq`:
![messenger_consume_typo](https://user-images.githubusercontent.com/2028198/39895599-d9f0705e-5478-11e8-9d6b-59d62930d4cb.png)

requires https://github.com/symfony/symfony/pull/27224

Commits
-------

54c2541d94 Select alternatives on missing receiver arg or typo
2018-05-17 08:19:04 +01:00
Samuel ROZE
f1967aa37d minor #27002 [Messenger] implement several senders using a ChainSender (Tobion)
This PR was merged into the 4.1 branch.

Discussion
----------

[Messenger] implement several senders using a ChainSender

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets |
| License       | MIT
| Doc PR        |

Commits
-------

198925ee4e [Messenger] implement several senders using a ChainSender
2018-05-17 08:12:54 +01:00
Nicolas Grekas
61fc221e70 Merge branch '4.1'
* 4.1: (22 commits)
  Fix CS
  [PropertyInfo] fix resolving parent|self type hints
  fixed CS
  fix merge
  [Security] Fix logout
  Cleanup 2 tests for the HttpException classes
  #27250 limiting GET_LOCK key up to 64 char due to changes in MySQL 5.7.5 and later
  [Config] Fix tests when path contains UTF chars
  [DI] Shared services should not be inlined in non-shared ones
  [Profiler] Remove propel & event_listener_loading category identifiers
  [Filesystem] Fix usages of error_get_last()
  [Cache][Lock] Fix usages of error_get_last()
  [Debug] Fix populating error_get_last() for handled silent errors
  fixed CS
  fixed CS
  fixed CS
  [FrameworkBundle] Fix cache:clear on vagrant
  [HttpKernel] Handle NoConfigurationException "onKernelException()"
  Fix misses calculation when calling getItems
  [DI] Display previous error messages when throwing unused bindings
  ...
2018-05-16 16:42:13 +02:00
Nicolas Grekas
71a1e29c82 Fix CS 2018-05-16 16:41:07 +02:00
Tobias Schultze
198925ee4e [Messenger] implement several senders using a ChainSender 2018-05-16 15:12:01 +02:00
Samuel ROZE
4a7e6fa9bc Merge branch '4.1'
* 4.1:
  [Messenger] Middleware factories support in config
  [HttpKernel] Make TraceableValueResolver $stopwatch mandatory
  [Messenger] Improve the profiler panel
  [Workflow] Added DefinitionBuilder::setMetadataStore().
  [Messenger][DX] Uses custom method names for handlers
  [Messenger] remove autoconfiguration for Sender/ReceiverInterface
  [Messenger] Make sure default receiver name is set before command configuration
  [HttpKernel] Fix services are no longer injected into __invoke controllers method
  Rename tag attribute "name" by "alias"
  Autoconfiguring TransportFactoryInterface classes
  [Messenger] Fix new AMQP Transport test with Envelope
  Fixed return senders based on the message parents/interfaces
  [Messenger] Make sure Sender and Receiver locators have valid services
  [Workflow] add is deprecated since Symfony 4.1. Use addWorkflow() instead
  [Messenger] Fix TraceableBus with envelope
  Ensure the envelope is passed back and can be altered Ensure that the middlewares can also update the message within the envelope
  feature #26945 [Messenger] Support configuring messages when dispatching (ogizanagi)
  Add more tests around the AMQP transport
2018-05-14 20:20:21 +01:00
Samuel ROZE
f59ce97eff feature #27128 [Messenger] Middleware factories support in config (ogizanagi)
This PR was squashed before being merged into the 4.1 branch (closes #27128).

Discussion
----------

[Messenger] Middleware factories support in config

| Q             | A
| ------------- | ---
| Branch?       | master <!-- see below -->
| Bug fix?      | no
| New feature?  | yes <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no  <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | N/A   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | todo

Following https://github.com/symfony/symfony/pull/26864, this would allow to configure easily the middlewares by using an abstract factory definition to which are provided simple arguments (just scalars, no services references).

For instance, here is how the DoctrineBundle would benefit from such a feature (also solving the wiring of the `DoctrineTransactionMiddleware` reverted in https://github.com/symfony/symfony/pull/26684):

```yaml
framework:
    messenger:
      buses:
        default:
          middleware:
            - logger
            - doctrine_transaction_middleware: ['entity_manager_name']
```

where `doctrine_transaction_middleware` would be an abstract factory definition provided by the doctrine bundle:

```yml
services:

    doctrine.orm.messenger.middleware_factory.transaction:
      class: Symfony\Bridge\Doctrine\Messenger\DoctrineTransactionMiddlewareFactory
      arguments: ['@doctrine']

    doctrine_transaction_middleware:
      class: Symfony\Bridge\Doctrine\Messenger\DoctrineTransactionMiddleware
      factory: ['@doctrine.orm.messenger.middleware_factory.transaction', 'createMiddleware']
      abstract: true
      # the default arguments to use when none provided from config.
      # i.e:
      #   middlewares:
      #     - doctrine_transaction_middleware: ~
      arguments: ['default']
```

and is interpreted as:

```yml
buses:
    default:
        middleware:
            -
                id: logger
                arguments: {  }
            -
                id: doctrine_transaction_middleware
                arguments:
                    - entity_manager_name
        default_middleware: true
```

---

<details>

<summary>Here is the whole config reference with these changes: </summary>

```yaml
# Messenger configuration
messenger:
    enabled:              true
    routing:

        # Prototype
        message_class:
            senders:              []
    serializer:
        enabled:              true
        format:               json
        context:

            # Prototype
            name:                 ~
    encoder:              messenger.transport.serializer
    decoder:              messenger.transport.serializer
    adapters:

        # Prototype
        name:
            dsn:                  ~
            options:              []
    default_bus:          null
    buses:

        # Prototype
        name:
            default_middleware:  true
            middleware:

                # Prototype
                -
                    id:                   ~ # Required
                    arguments:            []
```

</details>

Commits
-------

f5ef421474 [Messenger] Middleware factories support in config
2018-05-14 20:17:15 +01:00
Maxime Steinhausser
f5ef421474 [Messenger] Middleware factories support in config 2018-05-14 20:17:01 +01:00
Fabien Potencier
8335537446 feature #27202 [Messenger] Improve the profiler panel (ogizanagi)
This PR was squashed before being merged into the 4.1 branch (closes #27202).

Discussion
----------

[Messenger] Improve the profiler panel

| Q             | A
| ------------- | ---
| Branch?       | 4.1 <!-- see below -->
| Bug fix?      | no
| New feature?  | yes <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes <!-- please add some, will be required by reviewers -->
| Fixed tickets | N/A   <!-- #26597  issue number(s), if any -->
| License       | MIT
| Doc PR        | N/A

This is an attempt to enhance the profiler panel a bit.

**with the following messages dispatched:**

```php
$queryBus->dispatch(Envelope::wrap(new GetGreetingsQuery('Hello you'))
    ->with(new JustAFriendOfMine())
    ->with(new AndHisPlusO̶n̶e̶Eleven())
);
$commandBus->dispatch(new SendGiftCommand());
$queryBus->dispatch(new GetGreetingsQuery('Exterminate!'));
```

## Before

<img width="1084" alt="screenshot 2018-05-12 a 13 57 57" src="https://user-images.githubusercontent.com/2211145/39957055-8a0f009e-55ec-11e8-9d8e-bf79aad4b420.PNG">

🐛calls order are wrong here, fixed in this PR

## After

### collapsed

<!-- <img width="1083" alt="screenshot 2018-05-10 a 23 51 07" src="https://user-images.githubusercontent.com/2211145/39896093-19a8c7ee-54ad-11e8-8dcb-4e165ffd2eae.PNG">-->

<img width="1085" alt="screenshot 2018-05-12 a 13 18 35" src="https://user-images.githubusercontent.com/2211145/39956802-9d4c38a2-55e7-11e8-8425-ad090c0871b6.PNG">
<img width="1085" alt="screenshot 2018-05-12 a 13 26 44" src="https://user-images.githubusercontent.com/2211145/39956827-25d9e426-55e8-11e8-9116-160603649f33.PNG">

📝 _When loading the page, all messages details are collapsed by default but the first one per tab._

### expanded

<!-- <img width="1083" alt="screenshot 2018-05-10 a 23 13 39" src="https://user-images.githubusercontent.com/2211145/39894779-42c9cc9a-54a8-11e8-9529-6292481536d4.PNG"> -->

<img width="1086" alt="screenshot 2018-05-12 a 13 49 42" src="https://user-images.githubusercontent.com/2211145/39956981-639fc3d6-55eb-11e8-9224-a48f591db3da.PNG">

### live

<!-- ![mai-10-2018 23-16-17](https://user-images.githubusercontent.com/2211145/39894789-4b8fa138-54a8-11e8-986c-fccf6cd0234f.gif) -->

![mai-12-2018 13-55-40](https://user-images.githubusercontent.com/2211145/39957041-37f17b34-55ec-11e8-8569-a733a104bf82.gif)

### toolbar (with exceptions)

<img width="284" alt="screenshot 2018-05-10 a 23 18 32" src="https://user-images.githubusercontent.com/2211145/39895011-0467f2a0-54a9-11e8-9d78-25461cf71c41.PNG">

## Notes

- Table headers are clickable, so you can jump directly to the message class in the code
- Reversing headers/rows allows to have a wider space for dumps and allows to add more entries in the future. This is an issue we already have with the Validator panel (when there is both an invalid value as object and a constraint violation dumped) which I'd like to revamp soon.
- ~~I wonder if we should keep the dispatched messages in call order, or if we can segregate by bus (using tabs?).~~
- ~~we could add a left container listing messages classes only, allowing to show details of a single message dispatched on a right container (similar to what the Form panel does). I'll probably suggest the same for the Validator panel.~~

Commits
-------

3d19578297 [Messenger] Improve the profiler panel
2018-05-13 08:14:37 +02:00
Maxime Steinhausser
3d19578297 [Messenger] Improve the profiler panel 2018-05-13 08:14:09 +02:00
Yonel Ceruto
54c2541d94 Select alternatives on missing receiver arg or typo 2018-05-11 09:46:46 -04:00
Samuel ROZE
982fc66760 feature #27034 [Messenger][DX] Uses custom method names for handlers (sroze)
This PR was merged into the 4.1 branch.

Discussion
----------

[Messenger][DX] Uses custom method names for handlers

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | https://github.com/symfony/symfony/pull/26685#issuecomment-383888657
| License       | MIT
| Doc PR        | ø

This has been discussed mostly in the [`MessageHandlerInterface` pull-request](https://github.com/symfony/symfony/pull/26685). For consistency reasons and convenience, this PR adds the ability to configure the method to be used on handlers:
```php
use Symfony\Component\Messenger\Handler\MessageSubscriberInterface;
use Symfony\Component\Messenger\Handler\MessageSubscriberConfiguration;

class CreateNumberMessageHandler implements MessageSubscriberInterface
{
    /**
     * {@inheritdoc}
     */
    public static function getHandledMessages(): array
    {
        return [
            CreateNumber::class => ['createNumber', 10],
            AnotherMessage::class => 'anotherMethod',
        ];
    }

    public function createNumber(CreateNumber $command)
    {
        // ...
    }
}
```

Commits
-------

2461e5119a [Messenger][DX] Uses custom method names for handlers
2018-05-11 15:17:34 +02:00
Samuel ROZE
2461e5119a [Messenger][DX] Uses custom method names for handlers 2018-05-11 15:00:51 +02:00
Tobias Schultze
497ce74f9e bug #27229 [Messenger] Rename tag attribute "name" by "alias" (yceruto)
This PR was merged into the 4.1 branch.

Discussion
----------

[Messenger] Rename tag attribute "name" by "alias"

| Q             | A
| ------------- | ---
| Branch?       | 4.1
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

As "name" is a reserved attribute in YAML and XML schema it makes impossible to register manually a custom Sender or Receiver with another "name" attribute.

> The file ".../demos/messenger-flex/config/services.yaml" does not contain valid YAML.
Duplicate key "name" detected at line 30 (near "- { name: 'messenger.receiver', name: 'mail' }").

Commits
-------

1ef27a7e6a Rename tag attribute "name" by "alias"
2018-05-11 11:17:32 +02:00
Yonel Ceruto
63871c9ce4 [Messenger] Make sure default receiver name is set before command configuration 2018-05-11 09:42:20 +02:00
Yonel Ceruto
1ef27a7e6a Rename tag attribute "name" by "alias" 2018-05-10 17:13:07 -04:00
Samuel ROZE
3cc4a701e6 bug #27220 [Messenger] Fix new AMQP Transport test with Envelope & fix contract (ogizanagi)
This PR was merged into the 4.1 branch.

Discussion
----------

[Messenger] Fix new AMQP Transport test with Envelope & fix contract

| Q             | A
| ------------- | ---
| Branch?       | 4.1 <!-- see below -->
| Bug fix?      | yes
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | https://travis-ci.org/symfony/symfony/jobs/377246434#L3685-L3686, https://ci.appveyor.com/project/fabpot/symfony/build/1.0.36261#L297   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | N/A

Commits
-------

7223bd75f9 [Messenger] Fix new AMQP Transport test with Envelope
2018-05-10 17:06:07 +02:00
Samuel ROZE
d013ab6f71 bug #27184 [Messenger] Fix return senders based on the message parents/interfaces (yceruto)
This PR was merged into the 4.1 branch.

Discussion
----------

[Messenger] Fix return senders based on the message parents/interfaces

| Q             | A
| ------------- | ---
| Branch?       | 4.1
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

c3d4536203/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php (L1494-L1499)

According to the code a message interface is supported into routing configuration, but it doesn't work when `SendMessageMiddleware` gets the mapping senders for the current object message.

This PR tries to fix it.

Commits
-------

41e25abf8c Fixed return senders based on the message parents/interfaces
2018-05-10 17:05:13 +02:00
Maxime Steinhausser
7223bd75f9 [Messenger] Fix new AMQP Transport test with Envelope 2018-05-10 14:29:23 +02:00
Samuel ROZE
ebbe1adebc minor #27206 [Messenger] Add more tests around the AMQP transport (sroze)
This PR was merged into the 4.1 branch.

Discussion
----------

[Messenger] Add more tests around the AMQP transport

| Q             | A
| ------------- | ---
| Branch?       | 4.1
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | ø
| License       | MIT
| Doc PR        | ø

Adding more tests to the AMQP transport/factory. These should have captured the following 3 bugs: #27198, #27197, #27196.

Commits
-------

faf9382223 Add more tests around the AMQP transport
2018-05-10 08:14:28 +01:00
Yonel Ceruto
41e25abf8c Fixed return senders based on the message parents/interfaces 2018-05-09 15:16:14 -04:00
Samuel ROZE
64a4a2b47f minor #27200 [Messenger] Make sure Sender and Receiver locators have valid services (yceruto)
This PR was squashed before being merged into the 4.1 branch (closes #27200).

Discussion
----------

[Messenger] Make sure Sender and Receiver locators have valid services

| Q             | A
| ------------- | ---
| Branch?       | 4.1
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

This make sure that Sender and Receiver locators have valid services. Also adds minor improvements into consume command.

Commits
-------

301ce5f839 [Messenger] Make sure Sender and Receiver locators have valid services
2018-05-09 19:57:59 +01:00
Yonel Ceruto
301ce5f839 [Messenger] Make sure Sender and Receiver locators have valid services 2018-05-09 19:57:45 +01:00
Maxime Steinhausser
21e49d21d8 [Messenger] Fix TraceableBus with envelope 2018-05-09 15:46:48 +01:00
Samuel ROZE
599f32c085 Ensure the envelope is passed back and can be altered
Ensure that the middlewares can also update the message within the envelope
2018-05-09 15:46:48 +01:00
Samuel ROZE
7c33cb27ab feature #26945 [Messenger] Support configuring messages when dispatching (ogizanagi)
This reverts commit 76b17b0e0f.
2018-05-09 15:46:25 +01:00
Samuel ROZE
cb2a77b24b Merge branch '4.1'
* 4.1:
  [Messenger][DX] Uses a default receiver when only one is defined
  fix deps
  [Profiler] Join using ';\n'
  Rename the command `DebugCommand`
  [Messenger] Add debug:messenger CLI command
  [Messenger] Fix default bus name
  Fix the transport factory after moving it
  [Messenger] Fix AMQP Transport factory & TransportFactoryInterface
  Fix AmqpTransport
  [Profiler] Fix dump makes toolbar disappear
  Improved exception on invalid message type
  bumped Symfony version to 4.1.0
  updated VERSION for 4.1.0-BETA1
  updated CHANGELOG for 4.1.0-BETA1
  [Messenger] Add TransportInterface as first class citizen sender+receiver
2018-05-09 15:43:48 +01:00
Samuel ROZE
e0f225bd85 minor #27203 [Messenger][DX] Uses a default receiver when only one is defined (sroze)
This PR was squashed before being merged into the 4.1 branch (closes #27203).

Discussion
----------

[Messenger][DX] Uses a default receiver when only one is defined

| Q             | A
| ------------- | ---
| Branch?       | 4.1
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | ø
| License       | MIT
| Doc PR        | ø

When using only one receiver, as a developer, it makes no sense for me to have to precise the receiver name when using the `messenger:consume-messages` command. This is the change:

```patch
- bin/console messenger:consume-messages default
+ bin/console messenger:consume-messages
```

If I have more than one transport configured, I'll get the following message:

>
>  You have 0 or more than one receiver (no default have been found). You need to specify the receiver name with an argument.
>

Commits
-------

8315b868d5 [Messenger][DX] Uses a default receiver when only one is defined
2018-05-09 15:41:23 +01:00
Samuel ROZE
8315b868d5 [Messenger][DX] Uses a default receiver when only one is defined 2018-05-09 15:41:15 +01:00
Samuel ROZE
6207d70964 feature #26803 [Messenger] Add debug:messenger CLI command (ro0NL, sroze)
This PR was merged into the 4.1 branch.

Discussion
----------

[Messenger] Add debug:messenger CLI command

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #...   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

Adds a `debug:messenger` CLI command to expose message classes that can be dispatched. Heavily inspired by `debug:autowiring`.

Commits
-------

7f87309c10 fix deps
290c7eb1bc Rename the command `DebugCommand`
9847b83723 [Messenger] Add debug:messenger CLI command
2018-05-09 15:39:20 +01:00
Samuel ROZE
9ce5941ee1 minor #27192 [Messenger] Improved exception on invalid message type (yceruto)
This PR was merged into the 4.1 branch.

Discussion
----------

[Messenger] Improved exception on invalid message type

| Q             | A
| ------------- | ---
| Branch?       | 4.1
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

before:
![invalid_message_type_before](https://user-images.githubusercontent.com/2028198/39728992-91f592e6-5227-11e8-8a29-b13d1fed82f8.png)

after:
![invalid_message_type_after](https://user-images.githubusercontent.com/2028198/39728982-8ba5b790-5227-11e8-949d-64265b702fa7.png)

Commits
-------

01fe64856f Improved exception on invalid message type
2018-05-09 13:10:57 +01:00
Samuel ROZE
290c7eb1bc Rename the command DebugCommand 2018-05-09 09:31:45 +01:00
Roland Franssen
9847b83723 [Messenger] Add debug:messenger CLI command 2018-05-09 09:27:25 +01:00
Samuel ROZE
faf9382223 Add more tests around the AMQP transport 2018-05-09 09:02:39 +01:00
Samuel ROZE
ef2c091787 bug #27197 [Messenger] Fix AMQP Transport factory & TransportFactoryInterface (ogizanagi)
This PR was merged into the 4.1 branch.

Discussion
----------

[Messenger] Fix AMQP Transport factory & TransportFactoryInterface

| Q             | A
| ------------- | ---
| Branch?       | 4.1 <!-- see below -->
| Bug fix?      | yes
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #27164  <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | N/A

Seems like we did review a bit fast here 😅

Commits
-------

98967cd73a [Messenger] Fix AMQP Transport factory & TransportFactoryInterface
2018-05-08 16:21:30 +01:00
Maxime Steinhausser
98967cd73a [Messenger] Fix AMQP Transport factory & TransportFactoryInterface 2018-05-08 17:08:45 +02:00
Yonel Ceruto
b8a4d5a232 Fix AmqpTransport 2018-05-08 10:54:44 -04:00
Yonel Ceruto
01fe64856f Improved exception on invalid message type 2018-05-08 06:58:53 -04:00
Fabien Potencier
016d556262 updated version to 4.2 2018-05-07 16:51:25 +02:00
Nicolas Grekas
379b8eb56b [Messenger] Add TransportInterface as first class citizen sender+receiver 2018-05-07 07:49:40 -07:00
Samuel ROZE
76b17b0e0f Revert "feature #26945 [Messenger] Support configuring messages when dispatching (ogizanagi)"
This reverts commit e7a0b80cb2, reversing
changes made to 388d684d75.
2018-05-07 15:33:34 +01:00
Samuel ROZE
e7a0b80cb2 feature #26945 [Messenger] Support configuring messages when dispatching (ogizanagi)
This PR was squashed before being merged into the 4.1-dev branch (closes #26945).

Discussion
----------

[Messenger] Support configuring messages when dispatching

| Q             | A
| ------------- | ---
| Branch?       | master <!-- see below -->
| Bug fix?      | no
| New feature?  | yes <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | see CI checks    <!-- please add some, will be required by reviewers -->
| Fixed tickets | N/A   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | todo

For now, this is mainly a RFC to get your opinion on such a feature (so it misses proper tests).
Supporting wrapped messages out-of-the-box would mainly allow to easily create middlewares that should act only or be configured differently for specific messages (by using wrappers instead of making messages implements specific interfaces and without requiring dedicated buses). For instance, I might want to track specific messages and expose metrics about it.

The Symfony Serializer transport (relates to #26900) and Validator middleware serve as guinea pigs for sample purpose here. But despite message validation usually is simple as it matches one use-case and won't require specific validation groups in most cases, I still think it can be useful sometimes. Also there is the case of the [`AllValidator` which currently requires using a `GroupSequence`](https://github.com/symfony/symfony/pull/26477) as a workaround, but that could also be specified directly in message metadata instead.

## Latest updates

PR updated to use a flat version of configurations instead of wrappers, using an `Envelope` wrapper and a list of envelope items.
Usage:

```php
$message = Envelope::wrap(new DummyMessage('Hello'))
    ->with(new SerializerConfiguration(array(ObjectNormalizer::GROUPS => array('foo'))))
    ->with(new ValidationConfiguration(array('foo', 'bar')))
;
```

~~By default, Messenger protagonists receive the original message. But each of them can opt-in to receive the envelope instead, by implementing `EnvelopeReaderInterface`.
Then, they can read configurations from it and forward the original message or the envelope to another party.~~

Senders, encoders/decoders & receivers always get an `Envelope`.
Middlewares & handlers always get a message. But middlewares can opt-in to receive the envelope instead, by implementing `EnvelopeReaderInterface`.

Commits
-------

749054a1e8 [Messenger] Support configuring messages when dispatching
2018-05-07 14:50:19 +01:00
Maxime Steinhausser
749054a1e8 [Messenger] Support configuring messages when dispatching 2018-05-07 14:50:10 +01:00
Samuel ROZE
388d684d75 bug #27177 Rename middlewares to middleware (fabpot, sroze)
This PR was merged into the 4.1-dev branch.

Discussion
----------

Rename middlewares to middleware

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

`middleware` is uncountable in English (like software or information). So, I've removed the `s` everywhere. We can probably be a bit more explicit if we think it makes thing easier to understand like I've done in one class, like `middlewareHandler`.

Commits
-------

9ae7c11805 Do not fix the `middleware` XML name anymore
52e7500edb removed usage of middlewares
2018-05-07 14:02:32 +01:00
Fabien Potencier
559c914e1b minor #27178 [Messenger] Add missing @experimental annotations (sroze)
This PR was merged into the 4.1-dev branch.

Discussion
----------

[Messenger] Add missing `@experimental` annotations

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

So we have all the Messenger interfaces tagged with `@experimental`.

Commits
-------

7f875cb52b Add missing `@experimental` annotations
2018-05-07 14:39:43 +02:00
Fabien Potencier
52e7500edb removed usage of middlewares 2018-05-07 13:37:49 +02:00
Samuel ROZE
7f875cb52b Add missing @experimental annotations 2018-05-07 11:19:29 +02:00
Nicolas Grekas
c7a0045cbd [FrameworkBundle][Messenger] Remove convention-based service id generation for buses 2018-05-06 08:37:23 -07:00
Nicolas Grekas
5434780d58 [Messenger] Rename TolerateNoHandler to AllowNoHandlerMiddleware 2018-05-04 16:04:01 -07:00
Simon DELICATA
5536ee1b3e Add a new time limit receiver 2018-05-04 13:09:11 +02:00
Nicolas Grekas
47da23c7cb minor #27129 [Messenger] Rename Adapters to Transports (sroze)
This PR was squashed before being merged into the 4.1-dev branch (closes #27129).

Discussion
----------

[Messenger] Rename Adapters to Transports

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

Last of our tasks on the "plan to beta", renaming "adapters" to "transports". This is a term that makes more sense and is commonly used within the "queue community".

Commits
-------

13b747565f [Messenger] Rename Adapters to Transports
2018-05-03 17:10:25 -07:00
Samuel ROZE
13b747565f [Messenger] Rename Adapters to Transports 2018-05-03 17:09:35 -07:00
Iltar van der Berg
94314f9d55 [DI] Minor performance tweak in PriorityTaggedServiceTrait 2018-05-03 17:03:52 -07:00
Maxime Steinhausser
c68887e1e8 [Messenger] Reset traceable buses 2018-05-01 14:54:27 +02:00
Maxime Steinhausser
eb943619b1 [Messenger] Late collect & clone messages 2018-04-30 16:27:31 +02:00
Tobias Schultze
3b363a8808 minor #27066 [Messenger] unwrap ReceivedMessage in LoggingMiddleware to improve log detail (kbond)
This PR was merged into the 4.1-dev branch.

Discussion
----------

[Messenger] unwrap ReceivedMessage in LoggingMiddleware to improve log detail

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

The change gives better visibility in your logs when consuming messages.

Commits
-------

78bb0252b4 [Messenger] unwrap ReceivedMessage in LoggingMiddleware to improve log detail
2018-04-27 01:19:14 +02:00
Kevin Bond
78bb0252b4
[Messenger] unwrap ReceivedMessage in LoggingMiddleware to improve log detail 2018-04-26 10:41:06 -04:00
Simon DELICATA
08f98cfaf1 [Messenger] Add a memory limit option for ConsumeMessagesCommand 2018-04-26 10:28:37 +02:00
Samuel ROZE
da4fccd37c feature #26864 [Messenger] Define multiple buses from the framework.messenger.buses configuration (sroze)
This PR was squashed before being merged into the 4.1-dev branch (closes #26864).

Discussion
----------

[Messenger] Define multiple buses from the `framework.messenger.buses` configuration

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #26652
| License       | MIT
| Doc PR        | https://github.com/symfony/symfony-docs/issues/9617

Not everybody will benefit from having only one bus, especially with the CQRS-like usages. While keeping the extremely use of use of the single bus, this PR has the following:

- Create multiple buses from the YAML configuration
- Tag middleware only a specific buses
- Register middlewares from the YAML configuration

Even if it's visible in the PR's tests, here's how it will look like, for a completely full-customised version:
```yaml
framework:
    messenger:
        default_bus: commands
        buses:
            commands: ~
            events:
                middlewares:
                    - validation
                    - route_messages
                    - "Your\\Middleware\\Service"
                    - call_message_handler
```

A few things to note:
1. The YAML configuration creates `messenger.bus.[name]` services for the buses.
2. The YAML configuration for middleware just adds tags to the corresponding middlewares.
3. If the middleware definition does not exists, it creates it. (without any magic on the arguments though, if it isn't auto-wirable, well... "your problem")
4. In the PR, there is this "TolerateNoHandler" middleware that is a great example for event buses

Commits
-------

e5deb8499b [Messenger] Define multiple buses from the `framework.messenger.buses` configuration
2018-04-25 18:39:19 +02:00
Samuel ROZE
e5deb8499b [Messenger] Define multiple buses from the framework.messenger.buses configuration 2018-04-25 18:39:05 +02:00
David Barratt
566a8be35b [Messenger] Typecast the auto-setup as a bool. 2018-04-25 12:51:00 +02:00
Samuel ROZE
4429c9b20f bug #26956 [Messenger][AmqpExt] Allow disabling the auto-setup of the connection (sroze)
This PR was squashed before being merged into the 4.1-dev branch (closes #26956).

Discussion
----------

[Messenger][AmqpExt] Allow disabling the auto-setup of the connection

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #26937
| License       | MIT
| Doc PR        | ø

Allow disabling the auto-setup of the AMQP connection. Especially useful when the messages are published to another system (see #26937)

Commits
-------

b3039faa1a [Messenger][AmqpExt] Allow disabling the auto-setup of the connection
2018-04-17 17:51:29 +01:00
Samuel ROZE
b3039faa1a [Messenger][AmqpExt] Allow disabling the auto-setup of the connection 2018-04-17 17:51:20 +01:00
Samuel ROZE
fe199317da feature #26941 [Messenger] Allow to configure the transport (sroze)
This PR was squashed before being merged into the 4.1-dev branch (closes #26941).

Discussion
----------

[Messenger] Allow to configure the transport

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | ish
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #26900, #26908, #26935
| License       | MIT
| Doc PR        | ø

We allow users to configure the encoder/decoder used by the built-in adapter(s). This also adds the support of configuring the default's encoder/decoder format and context.

Commits
-------

1a3f0bbb14 [Messenger] Allow to configure the transport
2018-04-17 17:47:47 +01:00
Samuel ROZE
1a3f0bbb14 [Messenger] Allow to configure the transport 2018-04-17 17:47:06 +01:00
abluchet
a4737915c8 [Messenger] Allow sender tag name omission 2018-04-17 14:59:00 +02:00
Fabien Potencier
7e4de96c03 minor #26909 [Messenger][DX] Uses the adapter name instead of the service name (sroze)
This PR was squashed before being merged into the 4.1-dev branch (closes #26909).

Discussion
----------

[Messenger][DX] Uses the adapter name instead of the service name

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

As a developer, I don't get why I would need to use the service name while I give a name to the adapters. This is basically what this PR means for me in terms of configuration:
```patch
framework:
    messenger:
        routing:
            # We want the command below to be handled async with the "messenger.default_sender" (AMQP producer).
-            'App\Message\Command\CreateNumber': messenger.sender.amqp
+            'App\Message\Command\CreateNumber': amqp

        adapters:
            amqp: "%env(AMQP_DSN)%"
```

And in terms of pulling the messages:
```patch
- bin/console messenger:consume-messages messenger.receiver.amqp
+ bin/console messenger:consume-messages amqp
```

Commits
-------

b5afb40441 [Messenger][DX] Uses the adapter name instead of the service name
2018-04-16 19:19:59 +02:00
Samuel ROZE
b5afb40441 [Messenger][DX] Uses the adapter name instead of the service name 2018-04-16 19:19:48 +02:00
Yonel Ceruto
eedad4c061 Make logger arg a hard dependency, remove dead code and add tests 2018-04-14 13:36:02 -04:00
Nicolas Grekas
ce5b3e7ded minor #26913 [Messenger] Add tests for ValidationMiddleware (yceruto)
This PR was merged into the 4.1-dev branch.

Discussion
----------

[Messenger] Add tests for ValidationMiddleware

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

Commits
-------

4a3f8f4 Add tests for ValidationMiddleware
2018-04-14 09:04:31 -05:00
Yonel Ceruto
2d3ce1dc58 Add tests for ChainHandler class 2018-04-14 08:58:06 -04:00
Yonel Ceruto
4a3f8f4775 Add tests for ValidationMiddleware 2018-04-13 08:28:05 -04:00
Samuel ROZE
6bbb5bcc52 minor #26907 [Messenger] Minor improvements and cleanup (yceruto)
This PR was merged into the 4.1-dev branch.

Discussion
----------

[Messenger] Minor improvements and cleanup

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

- enable some of opcode optimizations
- add missing typehints
- cleanup

Commits
-------

d8cc7a4715 Minor improvements and cleanup
2018-04-12 21:15:39 +01:00
Samuel ROZE
d60425c868 Allow the logger to be null (as per every other bits in the FrameworkBundle) 2018-04-12 19:18:53 +01:00
Yonel Ceruto
d8cc7a4715 Minor improvements and cleanup
- enable some of opcode optimizations
- add missing typehints
- cleanup
2018-04-12 11:42:15 -04:00
Samuel ROZE
798c230ad5 [Messenger] Add AMQP adapter 2018-04-12 09:15:52 +01:00
Fabien Potencier
3a37e41bfb bug #26816 [Messenger][FrameworkBundle] Move collector, command into the component & minor tweaks (ogizanagi)
This PR was squashed before being merged into the 4.1-dev branch (closes #26816).

Discussion
----------

[Messenger][FrameworkBundle] Move collector, command into the component & minor tweaks

| Q             | A
| ------------- | ---
| Branch?       | master <!-- see below -->
| Bug fix?      | no
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | N/A   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | N/A

Some suggestions more aligned with most of the core practices, mainly:

- Move the command & collector to the component itself. They are not dependent of the Fwb in any way and are useful out of the fwb usage.
- Add an exception in FrameworkExtension if the `framework.messenger` key is enabled, but the component isn't installed.

Commits
-------

6aec62bad3 [FrameworkBundle] Minor messenger component tweaks
f9c9ca0514 [Messenger] Move data collector & command into the component
2018-04-06 07:28:47 +02:00
Maxime Steinhausser
f9c9ca0514 [Messenger] Move data collector & command into the component 2018-04-05 17:21:58 +02:00
Maxime Steinhausser
a01b8e420d [Messenger] Fix composer branch-alias 2018-04-04 23:42:37 +02:00
Roland Franssen
92f7e37a27 [Messenger] Fix handles tag attribute 2018-04-04 20:34:01 +01:00
Samuel ROZE
ff9153ea67 Mention the interface is a marker 2018-04-04 08:28:34 +01:00
Fabien Potencier
c9ebbce82f fixed a typo 2018-04-04 07:23:22 +02:00
Samuel ROZE
d5b88eb7eb feature #26685 [Messenger] Add a MessageHandlerInterface (multiple messages + auto-configuration) (sroze)
This PR was squashed before being merged into the 4.1-dev branch (closes #26685).

Discussion
----------

[Messenger] Add a `MessageHandlerInterface` (multiple messages + auto-configuration)

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

Based on @chalasr's PR: https://github.com/symfony/symfony/pull/26672.

This reduces the hassle of registering handlers: it allows the auto-configuration with a new interface `HandlerInterface`. At the same time, it allows a handler to handle multiple messages.

Commits
-------

07e6bc73a3 [Messenger] Add a `MessageHandlerInterface` (multiple messages + auto-configuration)
2018-04-03 21:23:24 +01:00
Samuel ROZE
07e6bc73a3 [Messenger] Add a MessageHandlerInterface (multiple messages + auto-configuration) 2018-04-03 21:23:12 +01:00
Tobias Nyholm
43a51714d4 [Messenger] Added a middleware that validates messages 2018-04-03 21:17:07 +01:00
Gabriel Ostrolucký
b2d8792908 Mark ExceptionInterfaces throwable 2018-03-30 17:58:13 +02:00
Fabien Potencier
6f15386b89 minor #26706 [Messenger] Make NoHandlerForMessageException a logic exception (ogizanagi)
This PR was merged into the 4.1-dev branch.

Discussion
----------

[Messenger] Make NoHandlerForMessageException a logic exception

| Q             | A
| ------------- | ---
| Branch?       | master <!-- see below -->
| Bug fix?      | no
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | https://github.com/symfony/symfony/pull/26648#discussion_r178049882   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | N/A <!-- required for new features -->

To me, a missing handler for a message is a program logic exception (or misconfiguration). Even if it's only detected at runtime here.
It's the same as `ServiceNotFoundException` which even is an `\InvalidArgumentException`. Could eventually also be the case here.

Commits
-------

0489bbd948 [Messenger] Make NoHandlerForMessageException a logic exception
2018-03-30 09:58:18 +02:00
Maxime Steinhausser
0489bbd948 [Messenger] Make NoHandlerForMessageException a logic exception 2018-03-29 15:15:19 +02:00
Robin Chalas
2889acf7f5 [Messenger] Compile time errors fixes and tweaks 2018-03-27 14:18:30 +02:00
Samuel ROZE
bddebc47b8 Uses the messenger.message_handler tag instead of message.handler 2018-03-26 21:48:21 +01:00
Samuel ROZE
2bcf93db2d Remove the default transport if no serializer 2018-03-23 09:57:11 +00:00
Samuel ROZE
c9cfda990b [Messenger] Add a new Messenger component 2018-03-23 09:01:52 +01:00