Commit Graph

285 Commits

Author SHA1 Message Date
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