Skip to content
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

Allow the dispatcher concurrency to be overriden per channel #1669

Merged

Conversation

danielmarbach
Copy link
Collaborator

@danielmarbach danielmarbach commented Sep 11, 2024

Proposed Changes

See #1668

Types of Changes

What types of changes does your code introduce to this project?
Put an x in the boxes that apply

  • Bug fix (non-breaking change which fixes issue #NNNN)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause an observable behavior change in existing systems)
  • Documentation improvements (corrections, new content, etc)
  • Cosmetic change (whitespace, formatting, etc)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating
the PR. If you're unsure about any of them, don't hesitate to ask on the
mailing list. We're here to help! This is simply a reminder of what we are
going to look for before merging your code.

  • I have read the CONTRIBUTING.md document
  • I have signed the CA (see https://cla.pivotal.io/sign/rabbitmq)
  • All tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in related repositories

Further Comments

If this is a relatively large or complex change, kick off the discussion by
explaining why you chose the solution you did and what alternatives you
considered, etc.

@danielmarbach danielmarbach force-pushed the dispatcher-concurrency-override branch 3 times, most recently from df62f86 to e3ced40 Compare September 11, 2024 09:30
@danielmarbach danielmarbach marked this pull request as ready for review September 11, 2024 09:33
@lukebakken lukebakken self-assigned this Sep 11, 2024
@lukebakken lukebakken self-requested a review September 11, 2024 14:00
@lukebakken lukebakken added this to the 7.0.0 milestone Sep 11, 2024
@danielmarbach
Copy link
Collaborator Author

Maybe for v8 the concurrency can be made a consumer level concern since allows more fine-grained control over having a concurrency per consumer instead of sharing the concurrency from the channel with all the consumers.

* Change consumer dispatch concurrency value to a `ushort`

* Create `CreateChannelAsync` extension to use `DefaultConsumerDispatchConcurrency`

* Standardize on `ConsumerDispatchConcurrency` name
@lukebakken lukebakken force-pushed the dispatcher-concurrency-override branch from 8d02a94 to d1101b1 Compare September 11, 2024 17:30
@lukebakken lukebakken merged commit 624cf2e into rabbitmq:main Sep 11, 2024
11 checks passed
@danielmarbach danielmarbach deleted the dispatcher-concurrency-override branch September 11, 2024 20:52
@danielmarbach
Copy link
Collaborator Author

@lukebakken what I find a bit misleading is that my proposal on this PR was different to what you have force pushed to my commit. So effectively you have erased my original proposal with a different approach that now from the history perspective looks like mine and my original proposal is lost.

In my change the value of the property was used as a default when no channel specific override was there. So effectively the property value was the default but now things are different or maybe I'm misunderstanding the code because it is already late and I'm glancing at it from my phone.

@danielmarbach
Copy link
Collaborator Author

Don't get me wrong. I'm not feeling entitled in any way. You as a maintainer are free to have it the way you think is best. But wouldn't it then be better to push those changes as individual commits and then squash on merge to preserve that context of the change at least on the PR instead of force pushing?

@danielmarbach danielmarbach restored the dispatcher-concurrency-override branch September 11, 2024 21:05
@danielmarbach danielmarbach deleted the dispatcher-concurrency-override branch September 11, 2024 21:07
@lukebakken
Copy link
Contributor

lukebakken commented Sep 11, 2024

I didn't mean to change the behavior, just remove the nullable parameter. I want the behavior to use a dispatch concurrency of 1, or what is set in the connection factory, unless consumerDispatchConcurrency: is passed to CreateChannelAsync.

So, there is this API on the IConnection interface:
https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/main/projects/RabbitMQ.Client/client/api/IConnection.cs#L248

...and this extension method:
https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/main/projects/RabbitMQ.Client/client/api/IConnectionExtensions.cs#L10-L14

If a user calls conn.CreateChannelAsync(), it will use the latter extension method, which uses the default value of 1:
https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/main/projects/RabbitMQ.Client/client/api/ConnectionFactory.cs#L95-L98

Otherwise, a value for consumerDispatchConcurrency can be passed for that specific channel.

Is that OK?

@lukebakken
Copy link
Contributor

Argh, I see where I screwed up I think.

@danielmarbach
Copy link
Collaborator Author

danielmarbach commented Sep 11, 2024

I think it would also be fine to remove the property on the factory but my intent was to keep it there for now and use that value as a default when not overwritten. And then might be one or any other value if explicitly set. But never only the constant 1

But if it always falls back to just the constant 1 I wonder what the value of having that property on the connection factory is in the first place. Which might the right question to ask.

@danielmarbach
Copy link
Collaborator Author

In hindsight I should have done a better job in expressing my thoughts about the initial idea. Apologies for that

///
/// Defaults to <see cref="IConnectionFactory.ConsumerDispatchConcurrency"/>.
///
/// For concurrency greater than one this removes the guarantee that consumers handle messages in the order they receive them.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's great to see this mentioned, it's has been a repeated question with the Java client (which has a comparable setting) for many years.

@lukebakken
Copy link
Contributor

But if it always falls back to just the constant 1 I wonder what the value of having that property on the connection factory is in the first place. Which might the right question to ask.

Yep, I see what you mean! I'm preparing a follow-up PR.

lukebakken added a commit that referenced this pull request Sep 11, 2024
As @danielmarbach points out, it's kind of silly to have the dispatch concurrency set in the connection factory as PR #1669 makes this value per-channel.

So, we'll remove it from `IConnectionFactory` and use a default parameter value of `1` in `CreateChannelAsync`
@lukebakken
Copy link
Contributor

Thanks again @danielmarbach - #1671

As for the force-pushes and combination of commits, I'll keep your concerns in mind going forward when I modify contributions!

lukebakken added a commit that referenced this pull request Sep 12, 2024
PR #1669 by @danielmarbach adds the ability to configure consumer
dispatch on a per-channel basis.

* Test that consumer dispatch concurrency is set on the dispatcher.
lukebakken added a commit that referenced this pull request Sep 12, 2024
PR #1669 by @danielmarbach adds the ability to configure consumer
dispatch on a per-channel basis.

* Test that consumer dispatch concurrency is set on the dispatcher.
lukebakken added a commit that referenced this pull request Sep 12, 2024
PR #1669 by @danielmarbach adds the ability to configure consumer
dispatch on a per-channel basis.

* Test that consumer dispatch concurrency is set on the dispatcher.
lukebakken added a commit that referenced this pull request Sep 12, 2024
PR #1669 by @danielmarbach adds the ability to configure consumer
dispatch on a per-channel basis.

* Test that consumer dispatch concurrency is set on the dispatcher.
lukebakken added a commit that referenced this pull request Sep 12, 2024
PR #1669 by @danielmarbach adds the ability to configure consumer
dispatch on a per-channel basis.

* Test that consumer dispatch concurrency is set on the dispatcher.
lukebakken added a commit that referenced this pull request Sep 12, 2024
…llowup

Follow-up to #1669 - per-channel dispatch concurrency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants