Basic zeroMQ Ruby example

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!

Tagged ,

4 thoughts on “Basic zeroMQ Ruby example

  1. Jake says:

    This of course implies you have 0mq binaries installed already. nice demo.

  2. Will says:

    Jake, indeed it does, updated the post with installation instructions.

  3. junior says:

    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.

  4. 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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.