What happens to unhandled(message)?

173 views
Skip to first unread message

Harit Himanshu

unread,
Apr 25, 2015, 8:56:38 PM4/25/15
to akka...@googlegroups.com
If an Actor does not handle a message is executes unhanded(message) as  
if (message instanceof DiskMonitorMessage) {
// do something
} else {
unhandled(message);
}

- What happens now? where does this message go?
- Does it stays in Actor's mailbox? What if Actor never changes behavior (no become/unbecome), how to remove these messages from mailbox the?

Thanks

Adam

unread,
Apr 26, 2015, 2:17:05 AM4/26/15
to akka...@googlegroups.com
Unhandled is mainly useful for troubleshooting. Akka won't check if you actually did something with the message or not. It also doesn't force you to call unhandled and probably (never tried this) does't prevent you from calling unhandled multiple times. The documentation goes into detail regarding what exactly happens when you call unhandled.

Akka likewise has no "black magic" that checks your logic (e.g. through byte code injection). If you've failed to call become or do anything else you should have done, the you have a bug and Akka provides the tools to help you track it down. For example, calls to unhandled can be translated to debug messages via configuration.

Konrad Malawski

unread,
Apr 27, 2015, 6:04:30 AM4/27/15
to Akka User List

Excellent answer Adam.

An interesting point to add here is that when using Scala there is no need to call unhandled() explicitly, because Scala’s PartialFunction allows us to inspect if the function is able to handle a message or not. If not (no case x => matches the message), we call unhandled() right away.
In case of Java calling unhandled must be performed manually - for reasons Adam explained.

The setting to log debug messages when unhandled messages appear is:
akka.actor.debug.unhandled btw.


On Sun, Apr 26, 2015 at 8:17 AM, Adam <adam...@gmail.com> wrote:
Unhandled is mainly useful for troubleshooting. Akka won't check if you actually did something with the message or not. It also doesn't force you to call unhandled and probably (never tried this) does't prevent you from calling unhandled multiple times. The documentation goes into detail regarding what exactly happens when you call unhandled.

Akka likewise has no "black magic" that checks your logic (e.g. through byte code injection). If you've failed to call become or do anything else you should have done, the you have a bug and Akka provides the tools to help you track it down. For example, calls to unhandled can be translated to debug messages via configuration.

--
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.



--
Cheers,
Konrad 'ktoso' Malawski

Harit Himanshu

unread,
Apr 27, 2015, 10:54:48 AM4/27/15
to akka...@googlegroups.com
Thanks a lot. This is ver helpful.
I was curious to see if I can still see unhandled messages

You received this message because you are subscribed to a topic in the Google Groups "Akka User List" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/akka-user/3zwkjLPLq_k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to akka-user+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages