Source.completionStage
Send the single value of the CompletionStage
when it completes and there is demand.
Signature
Source.completionStage
Source.completionStage
Description
Send the single value of the CompletionStage
when it completes and there is demand. If the CompletionStage
completes with null
stage is completed without emitting a value. If the CompletionStage
fails the stream is failed with that exception.
For the corresponding operator for the Scala standard library Future
see future.
Example
- Java
-
source
import java.util.concurrent.CompletionStage; import java.util.concurrent.CompletableFuture; import org.apache.pekko.NotUsed; import org.apache.pekko.Done; import org.apache.pekko.actor.typed.ActorSystem; import org.apache.pekko.stream.javadsl.*; CompletionStage<Integer> stage = CompletableFuture.completedFuture(10); Source<Integer, NotUsed> source = Source.completionStage(stage); Sink<Integer, CompletionStage<Done>> sink = Sink.foreach(i -> System.out.println(i.toString())); source.runWith(sink, system); // 10
Reactive Streams semantics
emits the future completes
completes after the future has completed
1.1.2+24-bcd44ee3*