I have case in that we need to have multiple producer and multiple consumer. Producers & consumers should run on separate Task.
When I googled it I saw multiple options available in C# like BlockingCollection, DataFlow, Queue etc.
I have tried all of them in my POC, what I see is those are not fitting in my projects requirement.
My requirement is that Producers may spin Tasks asynchronously but there Consumers must do there processing job serially e.g. below
Producer1 - This should polls message for processing and pass it to below consumers
Consumer1
Consumer2
Consumer3
but processing should happen serially i.e. Consumer1 should process all message first then consumer2 and consumer3
Producer2
Consumer1
Consumer2
Consumer3
same should happen with producer2 also.
I have tried below links for my reference. https://www.codeproject.com/Articles/1112510/TPL-Producer-Consumer-Pattern-Thread-Safe-Queue-Co
https://jeremydmiller.com/2016/08/09/building-a-producer-consumer-queue-with-tpl-dataflow/
http://www.dotnetcurry.com/patterns-practices/1407/producer-consumer-pattern-dotnet-csharp