I'm building a REQ/REP service with zeromq and the REP part is in Scala and using Akka actors.
Here is the actor
class ReplyActor extends Actor {
println("Listening..")
def receive = {
case m: ZMQMessage =>
sender ! ZMQMessage(Seq(Frame("world")))
case _ =>
sender ! ZMQMessage(Seq(Frame("didn't understand?")))
}
}
And my main function
object Replyer extends App {
val system = ActorSystem("zmq")
val serverSocket = ZeroMQExtension(system).newRepSocket(
Array(
Bind("tcp://127.0.0.1:1234"),
Listener(system.actorOf(Props[ReplyActor]))
)
)
}
My REQ code is in python
import zmq
import time
context = zmq.Context()
socket = context.socket(zmq.REQ)
socket.connect("tcp://127.0.0.1:1234")
startTime = time.time()
for i in range(10):
msg = "msg %s" % i
socket.send("hello")
msg_in = socket.recv()
print 'That took ', time.time()-startTime, 'seconds'
It takes about 1 second for 10 messages, so my question is why is it so slow? If I build the REP in python it is really fast so I'm accusing Akka zeromq binding.
Extra info: I'm using Scala 2.9.2 and the newest Akka 2.0.3 (but also tried with 2.0.2)