Created
March 12, 2018 22:56
-
-
Save vhutov/6a1f6c9bb9a95c67e538306dffc8abd5 to your computer and use it in GitHub Desktop.
This file contains 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
class JmsManagerActor(messageParser: MessageParser) extends Actor { | |
def receive: Receive = { | |
case SubscribeForMessage(id) if isAlreadyReceived(id) => | |
msgsBuffer.remove(id) | |
sender ! Ack | |
case SubscribeForMessage(id) => | |
subscriptionMap.update(id, sender()) | |
case NewMessage(message) => | |
val id = messageParser.parse(message) | |
if (isSomeOneWaiting(id)) { | |
val waiter = subscriptionMap.remove(id).get | |
waiter ! Ack | |
} else { | |
msgsBuffer += id | |
} | |
} | |
//... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment