+act add getEventStream to ActorSystem #25870
This commit is contained in:
parent
f66ee1cbe8
commit
e847ce016a
6 changed files with 26 additions and 21 deletions
|
|
@ -159,7 +159,7 @@ public class FaultHandlingTest extends AbstractJavaTest {
|
|||
EventFilter ex3 = new ErrorFilter(IllegalArgumentException.class);
|
||||
EventFilter ex4 = new ErrorFilter(Exception.class);
|
||||
EventFilter[] ignoreExceptions = { ex1, ex2, ex3, ex4 };
|
||||
system.eventStream().publish(new TestEvent.Mute(immutableSeq(ignoreExceptions)));
|
||||
system.getEventStream().publish(new TestEvent.Mute(immutableSeq(ignoreExceptions)));
|
||||
|
||||
//#create
|
||||
Props superprops = Props.create(Supervisor.class);
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public class LoggingDocTest extends AbstractJavaTest {
|
|||
//#deadletters
|
||||
final ActorSystem system = ActorSystem.create("DeadLetters");
|
||||
final ActorRef actor = system.actorOf(Props.create(DeadLetterActor.class));
|
||||
system.eventStream().subscribe(actor, DeadLetter.class);
|
||||
system.getEventStream().subscribe(actor, DeadLetter.class);
|
||||
//#deadletters
|
||||
TestKit.shutdownActorSystem(system);
|
||||
}
|
||||
|
|
@ -84,10 +84,10 @@ public class LoggingDocTest extends AbstractJavaTest {
|
|||
@Override
|
||||
public Receive createReceive() {
|
||||
return receiveBuilder()
|
||||
.match(Jazz.class, msg ->
|
||||
.match(Jazz.class, msg ->
|
||||
System.out.printf("%s is listening to: %s%n", getSelf().path().name(), msg)
|
||||
)
|
||||
.match(Electronic.class, msg ->
|
||||
.match(Electronic.class, msg ->
|
||||
System.out.printf("%s is listening to: %s%n", getSelf().path().name(), msg)
|
||||
)
|
||||
.build();
|
||||
|
|
@ -100,18 +100,18 @@ public class LoggingDocTest extends AbstractJavaTest {
|
|||
final ActorSystem system = ActorSystem.create("DeadLetters");
|
||||
//#superclass-subscription-eventstream
|
||||
final ActorRef actor = system.actorOf(Props.create(DeadLetterActor.class));
|
||||
system.eventStream().subscribe(actor, DeadLetter.class);
|
||||
system.getEventStream().subscribe(actor, DeadLetter.class);
|
||||
|
||||
final ActorRef jazzListener = system.actorOf(Props.create(Listener.class));
|
||||
final ActorRef musicListener = system.actorOf(Props.create(Listener.class));
|
||||
system.eventStream().subscribe(jazzListener, Jazz.class);
|
||||
system.eventStream().subscribe(musicListener, AllKindsOfMusic.class);
|
||||
system.getEventStream().subscribe(jazzListener, Jazz.class);
|
||||
system.getEventStream().subscribe(musicListener, AllKindsOfMusic.class);
|
||||
|
||||
// only musicListener gets this message, since it listens to *all* kinds of music:
|
||||
system.eventStream().publish(new Electronic("Parov Stelar"));
|
||||
system.getEventStream().publish(new Electronic("Parov Stelar"));
|
||||
|
||||
// jazzListener and musicListener will be notified about Jazz:
|
||||
system.eventStream().publish(new Jazz("Sonny Rollins"));
|
||||
system.getEventStream().publish(new Jazz("Sonny Rollins"));
|
||||
|
||||
//#superclass-subscription-eventstream
|
||||
TestKit.shutdownActorSystem(system);
|
||||
|
|
@ -123,7 +123,7 @@ public class LoggingDocTest extends AbstractJavaTest {
|
|||
final ActorRef actor = system.actorOf(Props.create(DeadLetterActor.class));
|
||||
|
||||
//#suppressed-deadletters
|
||||
system.eventStream().subscribe(actor, SuppressedDeadLetter.class);
|
||||
system.getEventStream().subscribe(actor, SuppressedDeadLetter.class);
|
||||
//#suppressed-deadletters
|
||||
|
||||
TestKit.shutdownActorSystem(system);
|
||||
|
|
@ -134,7 +134,7 @@ public class LoggingDocTest extends AbstractJavaTest {
|
|||
final ActorRef actor = system.actorOf(Props.create(DeadLetterActor.class));
|
||||
|
||||
//#all-deadletters
|
||||
system.eventStream().subscribe(actor, AllDeadLetters.class);
|
||||
system.getEventStream().subscribe(actor, AllDeadLetters.class);
|
||||
//#all-deadletters
|
||||
|
||||
TestKit.shutdownActorSystem(system);
|
||||
|
|
@ -217,10 +217,10 @@ public class LoggingDocTest extends AbstractJavaTest {
|
|||
// ...
|
||||
})
|
||||
.match(Warning.class, msg -> {
|
||||
// ...
|
||||
// ...
|
||||
})
|
||||
.match(Info.class, msg -> {
|
||||
// ...
|
||||
// ...
|
||||
})
|
||||
.match(Debug.class, msg -> {
|
||||
// ...
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ class ExamplePersistentActor extends AbstractPersistentActor {
|
|||
final Evt evt = new Evt(data + "-" + getNumEvents());
|
||||
persist(evt, (Evt e) -> {
|
||||
state.update(e);
|
||||
getContext().getSystem().eventStream().publish(e);
|
||||
getContext().getSystem().getEventStream().publish(e);
|
||||
if (lastSequenceNr() % snapShotInterval == 0 && lastSequenceNr() != 0)
|
||||
// IMPORTANT: create a copy of snapshot because ExampleState is mutable
|
||||
saveSnapshot(state.copy());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue