I'm looking at some Scala code in the Akka codebase, and this code snippet below is responsible for handling an Exception.
override val supervisorStrategy =
OneForOneStrategy(loggingEnabled = false) {
case e @ InvalidAssociation(localAddress, remoteAddress, reason) ⇒
log.warning("Tried to associate with unreachable remote address [{}]. " +
"Address is now gated for {} ms, all messages to this address will be delivered to dead letters. Reason: {}",
remoteAddress, settings.RetryGateClosedFor.toMillis, reason.getMessage)
endpoints.markAsFailed(sender(), Deadline.now + settings.RetryGateClosedFor)
AddressTerminatedTopic(context.system).publish(AddressTerminated(remoteAddress))
Stop
case ShutDownAssociation(localAddress, remoteAddress, _) ⇒
log.debug("Remote system with address [{}] has shut down. " +
"Address is now gated for {} ms, all messages to this address will be delivered to dead letters.",
remoteAddress, settings.RetryGateClosedFor.toMillis)
endpoints.markAsFailed(sender(), Deadline.now + settings.RetryGateClosedFor)
AddressTerminatedTopic(context.system).publish(AddressTerminated(remoteAddress))
Stop
The code on line 3, case e @ InvalidAssociation
- InvalidAssociation is indeed an exception type, but why is the e @
necessary and what does it do?