dotnetcore / CAP

Distributed transaction solution in micro-service base on eventually consistency, also an eventbus with Outbox pattern
http://cap.dotnetcore.xyz
MIT License
6.61k stars 1.28k forks source link

Question about parallel execution #1528

Closed PoteRii closed 3 months ago

PoteRii commented 4 months ago

Hello, Scenario: Service is consuming events from multiple topics (A and B). I need to retain order and sequential processing for topic A, but need to execute events in parallel for topic B. How can this be achieved?

yang-xiaodong commented 4 months ago

Hello,

CAP's parallel execution configuration is global and does not support separate settings for subscribers.

PoteRii commented 4 months ago

any plans to add this feature? or any hints how we can do it?

yang-xiaodong commented 4 months ago

These are some hints that might be useful for your short-term solution, we still need to investigate whether to add this feature or not.

  1. Place subscribers that require parallel execution into one or more groups, e.g., parallel-group-1, parallel-group-2.
    
    [CapSubscribe("A", Group="parallel-group-1")]
    public void SubA(){
    }

[CapSubscribe("B", Group="parallel-group-2")] public void SubA(){ }


2. Set the `UseDispatchingPerGroup` option to true.
3. Modify `IDispatcher.PerGroup.cs` line 203 as follows :
```cs
if (_enableParallelExecute || key =="parallel-group-1.v1" || key== "parallel-group-2.v1"){

}
PoteRii commented 4 months ago

Thanks, will dive deeper

yang-xiaodong commented 3 months ago

We plan to support consumer concurrent in v8.2.0, please check out the PR #1537 !

yang-xiaodong commented 3 months ago

@PoteRii Version 8.2.0-preview-233720681 is released, take a try.