Skip to content

Instantly share code, notes, and snippets.

@felipecruz
Created March 21, 2012 21:21
Show Gist options
  • Save felipecruz/2152946 to your computer and use it in GitHub Desktop.
Save felipecruz/2152946 to your computer and use it in GitHub Desktop.
require 'zmq'
require 'msgpack'
context = ZMQ::Context.new
worker_socket = context.socket ZMQ::REP
worker_socket.connect "tcp://127.0.0.1:5555"
count = 0
while true
req = MessagePack.unpack worker_socket.recv
count += 1
id = req[0]
uri = req[2]
rep = MessagePack.pack([id, "<html><h1>RubyWorker #{count}</h1></html>"])
worker_socket.send rep
puts count
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment