Skip to content

Instantly share code, notes, and snippets.

@debasishg
Last active December 25, 2015 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save debasishg/7056696 to your computer and use it in GitHub Desktop.
Save debasishg/7056696 to your computer and use it in GitHub Desktop.
Sample session with redis pubsub implemented with redisclient
Welcome to Scala version 2.10.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_51).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import com.redis._
import com.redis._
scala> import akka.actor.{ Actor, ActorSystem, Props }
import akka.actor.{Actor, ActorSystem, Props}
scala> val ps = ActorSystem("pub")
ps: akka.actor.ActorSystem = akka://pub
scala> val ss = ActorSystem("sub")
ss: akka.actor.ActorSystem = akka://sub
scala> val p = ps.actorOf(Props(new Pub))
p: akka.actor.ActorRef = Actor[akka://pub/user/$a#2075877062]
scala> starting publishing service ..
scala> val s = ss.actorOf(Props(new Sub))
s: akka.actor.ActorRef = Actor[akka://sub/user/$a#724245975]
scala> starting subscription service ..
Got in Sub true
scala> p ! PublishMessage("a", "hello world")
scala> Got in Pub true
scala> s ! SubscribeMessage(List("a"))
scala> Got in Sub true
subscribed to a and count = 1
scala>
scala> p ! PublishMessage("b", "+c")
scala> Got in Pub true
scala> p ! PublishMessage("b", "+d")
scala> Got in Pub true
scala> p ! PublishMessage("b", "-c")
scala> Got in Pub true
scala> p ! PublishMessage("b", "exit")
scala> Got in Pub true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment