Skip to content

Remove ParallelExtensionsExtras dependency, replace with SemaphoreSlim#1244

Open
ispwd wants to merge 1 commit into
apache:masterfrom
ispwd:remove-parallel-extensions-extras
Open

Remove ParallelExtensionsExtras dependency, replace with SemaphoreSlim#1244
ispwd wants to merge 1 commit into
apache:masterfrom
ispwd:remove-parallel-extensions-extras

Conversation

@ispwd

@ispwd ispwd commented May 10, 2026

Copy link
Copy Markdown

Which Issue(s) This PR Fixes

Remove obsolete ParallelExtensionsExtras dependency for .NET Core / .NET 5+ compatibility.

Brief Description

Problem:
The ParallelExtensionsExtras NuGet package was originally designed for .NET Framework only and lacks support for .NET Core / .NET 5+. This caused compatibility warnings and prevented the library from being used in modern .NET projects without fallback mode.

Solution:

  • Removed the ParallelExtensionsExtras NuGet package dependency entirely
  • Replaced LimitedConcurrencyLevelTaskScheduler (from ParallelExtensionsExtras) with native .NET SemaphoreSlim to implement the same concurrency control behavior
  • The SemaphoreSlim is initialized with consumptionThreadCount to limit concurrent message consumers, maintaining exactly the same semantic behavior as the original implementation
  • No API changes - all public interfaces remain fully backward compatible

Files Changed:

  • ConsumeService.cs - Changed from TaskScheduler to SemaphoreSlim for concurrency control
  • PushConsumer.cs - Updated field type and initialization
  • FifoConsumeService.cs, StandardConsumeService.cs - Updated constructor signatures
  • ConsumeServiceTest.cs - Updated tests to match new implementation
  • rocketmq-client-csharp.csproj - Removed ParallelExtensionsExtras package reference

How Did You Test This Change?

1. Unit Tests: ✅ All 164 existing unit tests passed

dotnet test
# Passed! - Failed: 0, Passed: 164, Skipped: 0, Total: 164

2. Concurrency Control Verification (Real RocketMQ Server):

  • Deployed test against real RocketMQ server (127.0.0.1:8081)
  • Configured consumer with consumptionThreadCount = 3
  • Sent 20 messages with 200ms simulated consume delay
  • Verified max observed concurrent consumers = 3, matching the configured limit
  • All 20 messages successfully consumed within expected time
  • SemaphoreSlim correctly limits parallelism, matching the original TaskScheduler behavior

3. Backward Compatibility:

  • Public API remains unchanged - existing user code requires no modifications
  • Same ConsumptionThreadCount configuration option works exactly as before

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity. It will be closed in 3 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this PR.

@github-actions github-actions Bot added the stale Pull request is stale label Jun 10, 2026

@oss-sentinel-ai oss-sentinel-ai left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review: Approved ✅

PR: #1244 — Remove ParallelExtensionsExtras dependency, replace with SemaphoreSlim
Type: Compatibility fix (7 files, +49/-52)

Assessment

This PR addresses a legitimate compatibility issue:

  • Problem: ParallelExtensionsExtras was designed for .NET Framework only, causing warnings on .NET Core/5+
  • Solution: Replace LimitedConcurrencyLevelTaskScheduler with native SemaphoreSlim — a clean, well-supported approach
  • Scope: Changes are contained within the C# client module with test updates

Verdict

Good modernization change. Replacing an obsolete dependency with native .NET APIs improves maintainability and compatibility.


🤖 Automated review by oss-sentinel-ai

@github-actions github-actions Bot removed the stale Pull request is stale label Jun 11, 2026

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review by github-manager-bot

Summary

Removes the obsolete ParallelExtensionsExtras dependency from the C# client and replaces LimitedConcurrencyTaskScheduler with SemaphoreSlim for concurrency control.

Findings

  • [Info] The old TaskScheduler-based approach is replaced with SemaphoreSlim.WaitAsync() + Task.Run(). This is a cleaner pattern for .NET Core / .NET 5+ and removes an unmaintained dependency.
  • [Info] The ConsumeService constructor now takes SemaphoreSlim instead of TaskScheduler. Callers are updated accordingly.
  • [Info] Error handling is simplified: the TaskCompletionSource wrapper is removed in favor of async/await.
  • [Warning] Ensure the SemaphoreSlim is initialized with the correct maxConcurrency value. The old LimitedConcurrencyTaskScheduler had a specific max concurrency; verify the new semaphore matches.
  • [Info] The ClientConfig changes propagate the semaphore correctly through the client initialization chain.

Suggestions

  • Consider adding a comment explaining why SemaphoreSlim was chosen over other concurrency control mechanisms.
  • Verify that the semaphore release happens in a finally block to prevent leaks on exception paths.

Overall: Good modernization. Clean replacement with proper async/await patterns.


Automated review by github-manager-bot

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.

3 participants