Skip to content

Commit

Permalink
sample queue device for N to N, decoupled communication and routing
Browse files Browse the repository at this point in the history
  • Loading branch information
igrigorik committed May 4, 2011
1 parent 8062b8d commit 45d82bc
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions queue-device.rb
@@ -0,0 +1,22 @@
require 'rubygems'
require 'ffi-rzmq'

#
# Simple router which allows multiple frontends to distribute
# requests to many workers, without knowing where or how many
# of the workers there are. To do so, you can run this process
# and 'connect' to port 8001 on each of your frontends (HTTP
# routers).
#
# In other words N to N communication
#.

ctx = ZMQ::Context.new 1

q_front = ctx.socket(ZMQ::XREP)
q_back = ctx.socket(ZMQ::XREQ)

q_front.bind('tcp://127.0.0.1:8001')
q_back.bind('tcp://127.0.0.1:8000')

ZMQ::Device.new(ZMQ::QUEUE, q_front, q_back)

0 comments on commit 45d82bc

Please sign in to comment.