* Deprecates status message based api #27503 * Deprecates actorRefWithAck for actorRefWithBackpressure
This commit is contained in:
parent
aee0152da2
commit
751918e84c
34 changed files with 618 additions and 195 deletions
|
|
@ -320,7 +320,7 @@ public class IntegrationDocTest extends AbstractJavaTest {
|
|||
}
|
||||
// #ask-actor
|
||||
|
||||
// #actorRefWithAck-actor
|
||||
// #actorRefWithBackpressure-actor
|
||||
enum Ack {
|
||||
INSTANCE;
|
||||
}
|
||||
|
|
@ -381,7 +381,7 @@ public class IntegrationDocTest extends AbstractJavaTest {
|
|||
.build();
|
||||
}
|
||||
}
|
||||
// #actorRefWithAck-actor
|
||||
// #actorRefWithBackpressure-actor
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
|
|
@ -399,8 +399,8 @@ public class IntegrationDocTest extends AbstractJavaTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void actorRefWithAckExample() throws Exception {
|
||||
// #actorRefWithAck
|
||||
public void actorRefWithBackpressure() throws Exception {
|
||||
// #actorRefWithBackpressure
|
||||
Source<String, NotUsed> words = Source.from(Arrays.asList("hello", "hi"));
|
||||
|
||||
final TestKit probe = new TestKit(system);
|
||||
|
|
@ -408,7 +408,7 @@ public class IntegrationDocTest extends AbstractJavaTest {
|
|||
ActorRef receiver = system.actorOf(Props.create(AckingReceiver.class, probe.getRef()));
|
||||
|
||||
Sink<String, NotUsed> sink =
|
||||
Sink.<String>actorRefWithAck(
|
||||
Sink.<String>actorRefWithBackpressure(
|
||||
receiver,
|
||||
new StreamInitialized(),
|
||||
Ack.INSTANCE,
|
||||
|
|
@ -421,7 +421,7 @@ public class IntegrationDocTest extends AbstractJavaTest {
|
|||
probe.expectMsg("hello");
|
||||
probe.expectMsg("hi");
|
||||
probe.expectMsg("Stream completed");
|
||||
// #actorRefWithAck
|
||||
// #actorRefWithBackpressure
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import akka.testkit.TestProbe;
|
|||
// #actor-ref-imports
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
// #imports
|
||||
|
||||
|
|
@ -86,13 +87,20 @@ public class SourceDocExamples {
|
|||
// #actor-ref
|
||||
}
|
||||
|
||||
static void actorRefWithAck() {
|
||||
static void actorRefWithBackpressure() {
|
||||
final TestProbe probe = null;
|
||||
|
||||
// #actor-ref-with-ack
|
||||
// #actorRefWithBackpressure
|
||||
final ActorSystem system = ActorSystem.create();
|
||||
|
||||
Source<Object, ActorRef> source = Source.actorRefWithAck("ack");
|
||||
Source<Object, ActorRef> source =
|
||||
Source.actorRefWithBackpressure(
|
||||
"ack",
|
||||
o -> {
|
||||
if (o == "complete") return Optional.of(CompletionStrategy.draining());
|
||||
else return Optional.empty();
|
||||
},
|
||||
o -> Optional.empty());
|
||||
|
||||
ActorRef actorRef = source.to(Sink.foreach(System.out::println)).run(system);
|
||||
probe.send(actorRef, "hello");
|
||||
|
|
@ -101,7 +109,7 @@ public class SourceDocExamples {
|
|||
probe.expectMsg("ack");
|
||||
|
||||
// The stream completes successfully with the following message
|
||||
actorRef.tell(new Success(CompletionStrategy.draining()), ActorRef.noSender());
|
||||
// #actor-ref-with-ack
|
||||
actorRef.tell("complete", ActorRef.noSender());
|
||||
// #actorRefWithBackpressure
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue