I'd like to complete a stream with predefined messages count:
Source.actorRef(Integer.MAX_VALUE, OverflowStrategy.fail())
.limit(1)
.to(Sink.onComplete(System.out::println))
.run(materializer);
.tell("Do Complete!", ActorRef.noSender());
From the limit method documentation:
Completes when the defined number of elements has been taken or upstream completes
Why does stream not complete?
That is the documentation for take
, not limit
.
And indeed, you should use take
to solve your problem.