Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Messenger] Do not return fallback senders when other senders were already found #48121

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
Dec 21, 2022

Conversation

wouterj
Copy link
Member

@wouterj wouterj commented Nov 5, 2022

Q A
Branch? 6.3
Bug fix? yes
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR n/a

See https://github.com/wouterj/sf-reproducer/tree/messenger-star-routing for a reproducer of the current situation.

Currently, if you use the special * in the Messenger's routing configuration, this sender is always returned for all messages (also for messages explicitly configured to use another sender). According to the documentation, the star should act as a fallback instead:

You may use '*' as the message class. This will act as a default routing rule for any message not matched under routing. This is useful to ensure no message is handled synchronously by default.

@fabpot fabpot modified the milestones: 4.4, 5.4 Nov 23, 2022
@fabpot
Copy link
Member

fabpot commented Dec 11, 2022

As this is a behavior change, I would suggest merging it into 6.3 instead.

@wouterj wouterj changed the base branch from 4.4 to 6.3 December 11, 2022 10:51
@wouterj wouterj force-pushed the messenger-fallback-sender branch 2 times, most recently from a464b31 to cd43ccd Compare December 11, 2022 10:52
@chalasr chalasr modified the milestones: 5.4, 6.3 Dec 11, 2022
@wouterj wouterj force-pushed the messenger-fallback-sender branch from cd43ccd to acae5ca Compare December 20, 2022 22:20
@nicolas-grekas
Copy link
Member

Thank you @wouterj.

@nicolas-grekas nicolas-grekas merged commit fcfca3e into symfony:6.3 Dec 21, 2022
@wouterj wouterj deleted the messenger-fallback-sender branch December 21, 2022 21:55
@fabpot fabpot mentioned this pull request May 1, 2023
nicolas-grekas added a commit that referenced this pull request Sep 29, 2023
…altzu)

This PR was merged into the 6.3 branch.

Discussion
----------

[Messenger] Fix routing to multiple fallback transports

| Q             | A
| ------------- | ---
| Branch?       | 6.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| License       | MIT

The change made in #48121 means that it's not possible to route into multiple transport as fallback like

```yaml
framework:
  messenger:
    routing:
      My\Message\*: [async, audit]
```

F.e. the message `My\Message\ToBeSentToTwoSenders` would only reach `async`.

The comment in the code mentions

> if other senders already matched **with previous types**, skip the senders bound to the fallback

While in reality how it works is

> if other senders already matched, skip the senders bound to the fallback

After the changes in this MR it works as mentioned in the original comment, meaning it does not skip for the same type, but routes to all transports for that type.

---

This is not a BC break because anyone who has more than one transport in a wildcard rule has never received anything matching the wildcard on other than the 1st transport – so only if you had a misconfiguration in the first place you're affected.

Commits
-------

76f2433 Fix routing to multiple fallback transports
symfony-splitter pushed a commit to symfony/messenger that referenced this pull request Sep 29, 2023
…altzu)

This PR was merged into the 6.3 branch.

Discussion
----------

[Messenger] Fix routing to multiple fallback transports

| Q             | A
| ------------- | ---
| Branch?       | 6.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| License       | MIT

The change made in symfony/symfony#48121 means that it's not possible to route into multiple transport as fallback like

```yaml
framework:
  messenger:
    routing:
      My\Message\*: [async, audit]
```

F.e. the message `My\Message\ToBeSentToTwoSenders` would only reach `async`.

The comment in the code mentions

> if other senders already matched **with previous types**, skip the senders bound to the fallback

While in reality how it works is

> if other senders already matched, skip the senders bound to the fallback

After the changes in this MR it works as mentioned in the original comment, meaning it does not skip for the same type, but routes to all transports for that type.

---

This is not a BC break because anyone who has more than one transport in a wildcard rule has never received anything matching the wildcard on other than the 1st transport – so only if you had a misconfiguration in the first place you're affected.

Commits
-------

76f2433fa9 Fix routing to multiple fallback transports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants