I am trying to define a graph for Akka stream that contain parallel processing flow (I am using Akka.NET but this shouldn't matter). Imagine a data source of orders, each order consists of an order ID and a list of products (order items). The workflow is as follows:
- Receive and order
- Broadcast the order to two flows, flow A will deal with order items, channel B will deal with Order ID (some bookkeeping work)
- Flow A: Split collection of order items into individual elements, each one to be processed separately
- Flow A: For each order items that result from the split in the previous step call some external service which looks up extra information (price, availability etc.)
- Flow B: do some extra bookkeeping for the given Order ID
- Merge flows A and B
- Send to the sink merged data from the previous step which result in enriched order information
Steps 1 (Source.From), 2 (Broadcast), 4-5 (Map), 6 (Merge), 7 (Sink) looks OK. But how is collection split implemented in Akka or reactive streams terms? This is not broadcasting or flattening, a collection of N elements need to be split into N independent substreams that will later be merged back. How is this achieved?