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

Skip to content

[Messenger] Require default_bus with multiple buses #31624

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

Closed
weaverryan opened this issue May 26, 2019 · 4 comments
Closed

[Messenger] Require default_bus with multiple buses #31624

weaverryan opened this issue May 26, 2019 · 4 comments
Labels
DX DX = Developer eXperience (anything that improves the experience of using Symfony) Messenger
Milestone

Comments

@weaverryan
Copy link
Member

Symfony version(s) affected: 4.3

Description
At least in 4.3, if you have multiple messenger buses, you need to specify framework.messenger.default_bus. If you do not, you'll get:

The service "messenger.routable_message_bus" has a dependency on a non-existent service "messenger.default_bus"

How to reproduce
Add framework.messenger.buses with two entries below, but do not specify framework.messenger.default_bus.

Possible Solution
In the FrameworkBundle Configuration class, we should probably add validation to throw a better message.

@weaverryan weaverryan modified the milestones: 4.3, next May 26, 2019
@xabbuh xabbuh added the DX DX = Developer eXperience (anything that improves the experience of using Symfony) label May 27, 2019
@vincenttouzet
Copy link
Contributor

@weaverryan Maybe we can also just modify this line :

if (null === $config['default_bus'] && 1 === \count($config['buses'])) {

Changing the condition from :

        if (null === $config['default_bus'] && 1 === \count($config['buses'])) {
            $config['default_bus'] = key($config['buses']);
        }

to

        if (null === $config['default_bus']) {
            $config['default_bus'] = key($config['buses']);
        }

Then the default bus will be the first declared. WDYT 🤔 ?

@weaverryan
Copy link
Member Author

Hmm... I kinda like the idea of forcing the user to be explicit - an exception would almost be a built-in README to communicate that the user needs to choose one bus as their main bus, instead of not realizing that it's happening.

@chalasr
Copy link
Member

chalasr commented May 28, 2019

Same as @weaverryan. We deprecated a similar behavior for security user providers which was to take the first defined provider in favor of explicitly defining the provider on a single firewall/listener.

@vincenttouzet
Copy link
Contributor

Ok I understand. I've made the PR to add a validation

Tobion added a commit that referenced this issue May 29, 2019
…ion (vincenttouzet)

This PR was merged into the 4.3 branch.

Discussion
----------

[FrameworkBundle] Add a validation on the messenger section

| Q             | A
| ------------- | ---
| Branch?       | 4.3  <!-- see below -->
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #31624    <!-- #-prefixed issue number(s), if any -->
| License       | MIT

<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.

Additionally (see https://symfony.com/roadmap):
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against the master branch.
-->

Commits
-------

36f16e8 [FrameworkBundle] Add a validation on the messenger section
@Tobion Tobion closed this as completed May 29, 2019
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.4 Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX DX = Developer eXperience (anything that improves the experience of using Symfony) Messenger
Projects
None yet
Development

No branches or pull requests

7 participants