Skip to content

Instantly share code, notes, and snippets.

@vhazrati
Created December 21, 2011 11:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vhazrati/1505697 to your computer and use it in GitHub Desktop.
Save vhazrati/1505697 to your computer and use it in GitHub Desktop.
Code changed as per Viktors recommendations
object PullApplicationActorLess extends App {
var context: ZMQ.Context = null
var pullSocket: ZMQ.Socket = null
context = ZMQ.context(5)
pullSocket = context.socket(ZMQ.PULL)
pullSocket.connect("tcp://127.0.0.1:5555")
println("Starting consumer ...")
while (true) {
val request = pullSocket.recv(0)
val requestString = new String(request)
println(System.currentTimeMillis())
}
}
object PushApplicationActorLess extends App {
val TOTAL_MESSAGES = 1000000
val xmlString = XML.load("src/test/resources/benchmarks/message/message-one-s1.xml").toString.getBytes
var context: ZMQ.Context = null
var pushSocket: ZMQ.Socket = null
context = ZMQ.context(5)
pushSocket = context.socket(ZMQ.PUSH)
pushSocket.bind("tcp://127.0.0.1:5555")
Thread.sleep(10)
val startTime = System.currentTimeMillis
println("Start time - " + startTime)
var i = 0
while (i < TOTAL_MESSAGES) {
pushSocket.send(xmlString, 0)
i += 1
}
val endTime = System.currentTimeMillis
println("Publisher elapsed time " + (endTime - startTime))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment