akka/akka-core

concatSubstreams hangs when used as documented.

开放

#25,814 创建于 2018年10月19日

 (14 条评论) (0 个反应) (0 位负责人)Scala (3,547 个派生)batch import
1 - triagedhackathonhelp wantedt:docst:stream

仓库指标

星标
 (13,277 个星标)
PR 合并指标
 (平均合并 8天 19小时) (30 天内合并 10 个 PR)

描述

I'm trying to use concatSubstreams to collapse the results of a groupBy in order (as I can do with rxjava/reactor etc). But when I try this with akka, it hangs after outputting the first element. The docs do indicate it could hang if the number of groupBy streams were insufficient, but the docs also include an example, which I expected to work.

The docs reference this code in the test suite.. https://github.com/akka/akka/blob/v2.5.17/akka-docs/src/test/java/jdocs/stream/SubstreamDocTest.java#L67-L70

Here's that example from the docs/test case slightly modified to run standalone (added println sink)

final ActorSystem system = ActorSystem.create("QuickStart");
final Materializer mat = ActorMaterializer.create(system);
Source.from(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
  .groupBy(3, elem -> elem % 3)
  .concatSubstreams()
  .runWith(Sink.foreach(a -> System.out.println(a)), mat);

When this runs I would expect to see

1
4
7
10
2
5
8
3
6
9

But instead I just see 1 then it hangs.

Are the docs incorrect? are groupBy/concatSubstreams defective? or am I missing something obvious as to why it isn't running?

贡献者指南