parent
e44fafd4b7
commit
3ea59b1e76
7 changed files with 135 additions and 4 deletions
|
|
@ -22,6 +22,7 @@ import org.junit.Test;
|
|||
import scala.concurrent.duration.Duration;
|
||||
import scala.concurrent.duration.FiniteDuration;
|
||||
import akka.actor.ActorSystem;
|
||||
import akka.actor.ActorRef;
|
||||
import akka.actor.Cancellable;
|
||||
import akka.dispatch.Futures;
|
||||
import akka.stream.*;
|
||||
|
|
@ -271,6 +272,22 @@ public class FlowDocTest extends AbstractJavaTest {
|
|||
//#flow-mat-combine
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sourcePreMaterialization() {
|
||||
//#source-prematerialization
|
||||
Source<String, ActorRef> matValuePoweredSource =
|
||||
Source.actorRef(100, OverflowStrategy.fail());
|
||||
|
||||
Pair<ActorRef, Source<String, NotUsed>> actorRefSourcePair =
|
||||
matValuePoweredSource.preMaterialize(mat);
|
||||
|
||||
actorRefSourcePair.first().tell("Hello!", ActorRef.noSender());
|
||||
|
||||
// pass source around for materialization
|
||||
actorRefSourcePair.second().runWith(Sink.foreach(System.out::println), mat);
|
||||
//#source-prematerialization
|
||||
}
|
||||
|
||||
public void fusingAndAsync() {
|
||||
//#flow-async
|
||||
Source.range(1, 3)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue