* Implements actorRef source variant with backpressure #17610 * Small improvements to documentation and source #17610 * Small improvements to test #17610 * Small improvements to implementation and tests #17610 * Adds API for akka-typed #17610 * Adds ack sender and java api for typed #17610
This commit is contained in:
parent
a9f4f2dd96
commit
f37f41574d
14 changed files with 472 additions and 6 deletions
|
|
@ -8,8 +8,9 @@ package jdocs.stream.operators;
|
|||
// #range-imports
|
||||
import akka.NotUsed;
|
||||
import akka.actor.ActorSystem;
|
||||
import akka.actor.testkit.typed.javadsl.ManualTime;
|
||||
import akka.actor.testkit.typed.javadsl.TestKitJunitResource;
|
||||
import akka.stream.ActorMaterializer;
|
||||
import akka.stream.CompletionStrategy;
|
||||
import akka.stream.Materializer;
|
||||
import akka.stream.javadsl.Source;
|
||||
// #range-imports
|
||||
|
|
@ -18,7 +19,9 @@ import akka.stream.javadsl.Source;
|
|||
import akka.actor.ActorRef;
|
||||
import akka.actor.Status.Success;
|
||||
import akka.stream.OverflowStrategy;
|
||||
import akka.stream.CompletionStrategy;
|
||||
import akka.stream.javadsl.Sink;
|
||||
import akka.testkit.TestProbe;
|
||||
// #actor-ref-imports
|
||||
|
||||
import java.util.Arrays;
|
||||
|
|
@ -27,6 +30,8 @@ import java.util.Arrays;
|
|||
|
||||
public class SourceDocExamples {
|
||||
|
||||
public static final TestKitJunitResource testKit = new TestKitJunitResource(ManualTime.config());
|
||||
|
||||
public static void fromExample() {
|
||||
// #source-from-example
|
||||
final ActorSystem system = ActorSystem.create("SourceFromExample");
|
||||
|
|
@ -85,4 +90,24 @@ public class SourceDocExamples {
|
|||
actorRef.tell(new Success(CompletionStrategy.draining()), ActorRef.noSender());
|
||||
// #actor-ref
|
||||
}
|
||||
|
||||
static void actorRefWithAck() {
|
||||
final TestProbe probe = null;
|
||||
|
||||
// #actor-ref-with-ack
|
||||
final ActorSystem system = ActorSystem.create();
|
||||
final Materializer materializer = ActorMaterializer.create(system);
|
||||
|
||||
Source<Object, ActorRef> source = Source.actorRefWithAck("ack");
|
||||
|
||||
ActorRef actorRef = source.to(Sink.foreach(System.out::println)).run(materializer);
|
||||
probe.send(actorRef, "hello");
|
||||
probe.expectMsg("ack");
|
||||
probe.send(actorRef, "hello");
|
||||
probe.expectMsg("ack");
|
||||
|
||||
// The stream completes successfully with the following message
|
||||
actorRef.tell(new Success(CompletionStrategy.draining()), ActorRef.noSender());
|
||||
// #actor-ref-with-ack
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue