Publish UnhandledMessage to EventStream
This commit is contained in:
parent
e82ea3c8b0
commit
2adb042bf7
2 changed files with 8 additions and 3 deletions
|
|
@ -103,6 +103,11 @@ case class UnhandledMessageException(msg: Any, ref: ActorRef = null) extends Run
|
||||||
override def fillInStackTrace() = this //Don't waste cycles generating stack trace
|
override def fillInStackTrace() = this //Don't waste cycles generating stack trace
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This message is published to the EventStream whenever an Actor receives a message it doesn't understand
|
||||||
|
*/
|
||||||
|
case class UnhandledMessage(@BeanProperty message: Any, @BeanProperty recipient: ActorRef)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Classes for passing status back to the sender.
|
* Classes for passing status back to the sender.
|
||||||
* Used for internal ACKing protocol. But exposed as utility class for user-specific ACKing protocols as well.
|
* Used for internal ACKing protocol. But exposed as utility class for user-specific ACKing protocols as well.
|
||||||
|
|
@ -272,7 +277,7 @@ trait Actor {
|
||||||
def unhandled(message: Any) {
|
def unhandled(message: Any) {
|
||||||
message match {
|
message match {
|
||||||
case Terminated(dead) ⇒ throw new DeathPactException(dead)
|
case Terminated(dead) ⇒ throw new DeathPactException(dead)
|
||||||
case _ ⇒ throw new UnhandledMessageException(message, self)
|
case _ ⇒ context.system.eventStream.publish(UnhandledMessage(message, self))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,8 @@ Please note that the Akka Actor ``receive`` message loop is exhaustive, which is
|
||||||
different compared to Erlang and Scala Actors. This means that you need to
|
different compared to Erlang and Scala Actors. This means that you need to
|
||||||
provide a pattern match for all messages that it can accept and if you want to
|
provide a pattern match for all messages that it can accept and if you want to
|
||||||
be able to handle unknown messages then you need to have a default case as in
|
be able to handle unknown messages then you need to have a default case as in
|
||||||
the example above. Otherwise an ``UnhandledMessageException`` will be
|
the example above. Otherwise an ``akka.actor.UnhandledMessage(message, actor)`` will be
|
||||||
thrown and the actor is restarted when an unknown message is received.
|
published to the ``ActorSystem``'s ``EventStream``.
|
||||||
|
|
||||||
Creating Actors with default constructor
|
Creating Actors with default constructor
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue