Created
July 5, 2013 06:33
-
-
Save patriknw/5932409 to your computer and use it in GitHub Desktop.
Pub/Sub Spotlight
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 Publisher extends Actor { | |
import DistributedPubSubMediator.Publish | |
// activate the extension | |
val mediator = DistributedPubSubExtension(context.system).mediator | |
def receive = { | |
case in: String ⇒ | |
val out = in.toUpperCase | |
mediator ! Publish("content", out) | |
} | |
} |
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 Subscriber extends Actor with ActorLogging { | |
import DistributedPubSubMediator.Subscribe | |
val mediator = DistributedPubSubExtension(context.system).mediator | |
// subscribe to the topic named "content" | |
mediator ! Subscribe("content", self) | |
def receive = { | |
case s: String => log.info("Got {}", s) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment