Skip to content

Instantly share code, notes, and snippets.

@vhutov
Created March 12, 2018 22:56
Show Gist options
  • Save vhutov/6a1f6c9bb9a95c67e538306dffc8abd5 to your computer and use it in GitHub Desktop.
Save vhutov/6a1f6c9bb9a95c67e538306dffc8abd5 to your computer and use it in GitHub Desktop.
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