Created
March 20, 2014 10:28
-
-
Save 2m/9660966 to your computer and use it in GitHub Desktop.
akka receive implementation using scala and java lamda
This file contains hidden or 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
// scala | |
def receive = { | |
case Counter.Inc(by) => count += by | |
case Counter.Current => sender ! Counter.CurrentReply(count) | |
} | |
// java lamda | |
@Override | |
public PartialFunction<Object, BoxedUnit> receive() { | |
return ReceiveBuilder. | |
match(Inc.class, inc -> { | |
count += inc.by; | |
}). | |
match(Current.class, current -> { | |
sender().tell(new CurrentReply(count), self()); | |
}). | |
build(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment