How can I check if a message has a
sender other than
Actor.noSender is simply and alias for null, but on the receiving side
sender() is then the
deadLetter actor. Hence
sender is always unequal to
Actor.noSender, even if there is no sender.
The best I’ve come up with is the following test based on the actor path, but I’m not sure that I can rely on this to work in all cases and future changes, Akka cluster etc.
if(sender.path.elements != "deadLetters" :: Nil) ...
I don’t want to reply to messages that have been intentionally sent without a sender, because in my system I am treating undelivered messages as a warning that something is wrong. If the sender is absent, it indicates that the (actual) sender is not interested in a response.