Akka-Stream using Partition stage

时间:2017-08-30 20:42:15

标签: akka-stream

I am trying to find an example that shows how to use, Akka Stream Partition capability. I am trying to optimize writing a Store. For that i would like to group item in a batch of my choosing and write them at once, however to make use of parallelism i would like to do it in parallel. Hence the batch and then the writing in the database would happen let say on 8 simultaneous threads.

I would be able to write 30 records as one update on 8 parallel threads.

Grouped or GroupedWithin are well documented and i have tried them with success. However, the only thing i see to do what i want to in parallel is actually a partitioning. I'd to partition randomly, i don't care about how it is partition. If there is facilities to like round-robin partitioner, i'd like to know as well.

But first and foremost how do I use partition. Do i have to build a GraphBuilder ?

Please help

1 个答案:

答案 0 :(得分:1)

可以找到Partition的使用示例here

如果您正在寻找随机分区,Balance阶段就是您所需要的。文档提供了一个示例here

在这两种情况下,您都需要使用GraphDSL,记录为here