阿卡。如何用 Source.actorRef 完成一个流?

Akka. How to complete a stream with Source.actorRef?

我想用预定义的消息数完成一个流:

Source.actorRef(Integer.MAX_VALUE, OverflowStrategy.fail())
    .limit(1)
    .to(Sink.onComplete(System.out::println))
    .run(materializer);
    .tell("Do Complete!", ActorRef.noSender());

来自限制方法文档:

Completes when the defined number of elements has been taken or upstream completes

为什么流没有完成?

那是 take 的文档,而不是 limit

确实,您应该使用 take 来解决您的问题。