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

Skip to content

[Messenger] Add consumer strategy for poll mechanism of receivers #44294

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
wants to merge 3 commits into from

Conversation

Jeroeny
Copy link
Contributor

@Jeroeny Jeroeny commented Nov 26, 2021

Q A
Branch? 6.1
Bug fix? no
New feature? yes
Deprecations? no
Tickets no
License MIT
Doc PR not yet

When using Symfony messenger to consume messages, the default behaviour is to poll each receiver in order. If a receiver has returned messages that were handled, the loop starts to poll the first receiver again. With a comment at the logic stating:

after handling a single receiver, quit and start the loop again
this should prevent multiple lower priority receivers from
blocking too long before the higher priority are checked

Which makes sense, if you have high and low priority receivers. But I've often found the need for equal polling of receivers, when they don't have different priorities. In that case it is not desired to keep receiving from the first receiver as long as it is returning messages. But to poll each receiver in order.

A random order could also be beneficial for load-balancing. E.g. If you have 2 consumers polling the same receivers in order, and they'd start at the same time, the receivers that are last to be polled will have a handling delay. Until the consumers happen to diverge. But if the order of receivers is randomized, each receiver would likely have less delays between polling.

A --strategy=priority|ordered|random command option (and worker option) could expose this as a feature. I'm curious about the thoughts on this.

I have not yet added a changelog line (or tests) as I'd first like to get input on this idea as a concept.

@fabpot fabpot modified the milestones: 6.0, 6.1 Nov 29, 2021
@ThomasBeauchataud
Copy link

@Jeroeny are you still working on this PR ?
I need it for a feature

@Jeroeny
Copy link
Contributor Author

Jeroeny commented May 12, 2022

@ThomasBeauchataud yes, it's waiting for feedback/review.

@upyx
Copy link
Contributor

upyx commented May 13, 2022

The same #46334 (comment)

@fabpot fabpot modified the milestones: 6.1, 6.2 May 20, 2022
@Jeroeny
Copy link
Contributor Author

Jeroeny commented Sep 7, 2022

Closing due to other (better) efforts in progress: #45882 (comment)

@Jeroeny Jeroeny closed this Sep 7, 2022
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