Update: As Jake pointed out in the comments you obviously need zero MQ installed for this example to work. Just ‘brew install zeromq’ or ‘port install zmq’ on OS X, or use your Linux package manager.
I couldn’t find may examples of zeroMQ usage in Ruby so here is a basic sender/consumer I made to test it. First install the ‘zmq’ gem:
gem install zmq --no-ri --no-rdoc
Now start a worker, you can start as many as you want:
Now stick some messages on the queue:
You should get messages distributed to all the worker processes you started up. Pretty simple!
This of course implies you have 0mq binaries installed already. nice demo.
Jake, indeed it does, updated the post with installation instructions.
thanks! i had to follow all these instruction in order to get ruby 1.9.2 zeromq ruby binding installed properly and now i can follow your sample.
install rvm on ubuntu 10.04
http://www.christopherirish.com/2010/08/25/how-to-install-rvm-on-ubuntu-10-04/
install zeromq
http://gist.github.com/574656
if you get error after zeromq is installed, try this one to update the library
http://www.apparatusproject.org/blog/tag/zeromq/
now you are set to run the samples mentioned in this blog post.
You might also be interested in the ruby zeromq tutorials I’ve been making. They do use ffi-rzmq rather than zmq however (there are only a few minor differences). You can find them at: http://github.com/andrewvc/learn-ruby-zeromq