Created
July 26, 2012 19:55
-
-
Save ANorwell/3184152 to your computer and use it in GitHub Desktop.
ZMQ Push/Pull needs sleep
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
package com.test | |
import akka.actor._ | |
import akka.zeromq._ | |
class PullTestActor(val address: String) extends Actor { | |
val pullSocket = context.system.newSocket(SocketType.Pull, | |
Bind(address), Listener(self)) | |
def receive = { | |
case m: ZMQMessage ⇒ | |
val s = new String(m.payload(0)) | |
println("Got pull message: " + s) | |
case x ⇒ println("Got default case: " + x) | |
} | |
} | |
object TestPushPull extends App { | |
val address = "tcp://0.0.0.0:4100" | |
implicit val system = ActorSystem("zmqtest") | |
val pushSocket = system.newSocket(SocketType.Push, Connect(address)) | |
val pull = system.actorOf(Props(new PullTestActor(address)), "PullTestActor") | |
//Try adding/removing this line | |
Thread.sleep(1000) | |
while (true) { | |
println("Pushing msg") | |
pushSocket ! ZMQMessage(Seq(Frame("msg"))) | |
Thread.sleep(1000) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment