forked from akka/akka
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+act akka#15163 allows to suppress certain messages from being dead-l…
…etter-ed Conflicts: akka-actor/src/main/scala/akka/actor/ActorRef.scala
- Loading branch information
Showing
6 changed files
with
181 additions
and
2 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
akka-actor-tests/src/test/scala/akka/actor/DeadLetterSupressionSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/** | ||
* Copyright (C) 2014 Typesafe Inc. <http://www.typesafe.com> | ||
*/ | ||
package akka.actor | ||
|
||
import akka.event.Logging | ||
import akka.testkit.AkkaSpec | ||
import akka.testkit.ImplicitSender | ||
import akka.testkit.TestActors | ||
import akka.testkit.TestProbe | ||
|
||
import scala.concurrent.duration._ | ||
|
||
object DeadLetterSupressionSpec { | ||
|
||
case object NormalMsg | ||
|
||
case object SuppressedMsg extends DeadLetterSuppression | ||
|
||
} | ||
|
||
class DeadLetterSupressionSpec extends AkkaSpec with ImplicitSender { | ||
import DeadLetterSupressionSpec._ | ||
|
||
val deadActor = system.actorOf(TestActors.echoActorProps) | ||
watch(deadActor) | ||
deadActor ! PoisonPill | ||
expectTerminated(deadActor) | ||
|
||
s"must suppress message from default dead-letters logging (sent to dead: ${Logging.simpleName(deadActor)})" in { | ||
val deadListener = TestProbe() | ||
system.eventStream.subscribe(deadListener.ref, classOf[DeadLetter]) | ||
|
||
val suppressedListener = TestProbe() | ||
system.eventStream.subscribe(suppressedListener.ref, classOf[SuppressedDeadLetter]) | ||
|
||
val allListener = TestProbe() | ||
system.eventStream.subscribe(allListener.ref, classOf[AllDeadLetters]) | ||
|
||
deadActor ! SuppressedMsg | ||
deadActor ! NormalMsg | ||
|
||
deadListener.expectMsg(DeadLetter(NormalMsg, testActor, deadActor)) | ||
deadListener.expectNoMsg(200.millis) | ||
|
||
suppressedListener.expectMsg(SuppressedDeadLetter(SuppressedMsg, testActor, system.deadLetters)) | ||
suppressedListener.expectNoMsg(200.millis) | ||
|
||
allListener.expectMsg(SuppressedDeadLetter(SuppressedMsg, testActor, system.deadLetters)) | ||
allListener.expectMsg(DeadLetter(NormalMsg, testActor, deadActor)) | ||
allListener.expectNoMsg(200.millis) | ||
} | ||
|
||
s"must suppress message from default dead-letters logging (sent to dead: ${Logging.simpleName(system.deadLetters)})" in { | ||
val deadListener = TestProbe() | ||
system.eventStream.subscribe(deadListener.ref, classOf[DeadLetter]) | ||
|
||
val suppressedListener = TestProbe() | ||
system.eventStream.subscribe(suppressedListener.ref, classOf[SuppressedDeadLetter]) | ||
|
||
val allListener = TestProbe() | ||
system.eventStream.subscribe(allListener.ref, classOf[AllDeadLetters]) | ||
|
||
system.deadLetters ! SuppressedMsg | ||
system.deadLetters ! NormalMsg | ||
|
||
deadListener.expectMsg(200.millis, DeadLetter(NormalMsg, testActor, system.deadLetters)) | ||
|
||
suppressedListener.expectMsg(200.millis, SuppressedDeadLetter(SuppressedMsg, testActor, system.deadLetters)) | ||
|
||
allListener.expectMsg(200.millis, SuppressedDeadLetter(SuppressedMsg, testActor, system.deadLetters)) | ||
allListener.expectMsg(200.millis, DeadLetter(NormalMsg, testActor, system.deadLetters)) | ||
|
||
Thread.sleep(200) | ||
deadListener.expectNoMsg(Duration.Zero) | ||
suppressedListener.expectNoMsg(Duration.Zero) | ||
allListener.expectNoMsg(Duration.Zero) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters