Sink.combine
Combine several sinks into one using a user specified strategy
Signature
Description
Combine several sinks into one using a user specified strategy
Example
This example shows how to combine multiple sinks with a Fan-out Junction.
- Scala
-
source
val sendRemotely = Sink.actorRef(actorRef, "Done", _ => "Failed") val localProcessing = Sink.foreach[Int](_ => /* do something useful */ ()) val sink = Sink.combine(sendRemotely, localProcessing)(Broadcast[Int](_)) Source(List(0, 1, 2)).runWith(sink)
- Java
-
source
Sink<Integer, NotUsed> sendRemotely = Sink.actorRef(actorRef, "Done"); Sink<Integer, CompletionStage<Done>> localProcessing = Sink.<Integer>foreach( a -> { /*do something useful*/ }); Sink<Integer, NotUsed> sinks = Sink.combine(sendRemotely, localProcessing, new ArrayList<>(), a -> Broadcast.create(a)); Source.<Integer>from(Arrays.asList(new Integer[] {0, 1, 2})).runWith(sinks, system);
Reactive Streams semantics
cancels depends on the strategy
backpressures depends on the strategy
1.1.2+29-e21fa9eb*