[zeromq-dev] req-rep with max delay, in Ruby

Chuck Remes lists at chuckremes.com
Fri Apr 20 14:36:12 CEST 2012

On Apr 20, 2012, at 2:53 AM, Raphael Bauduin wrote:

> Hi,
> I need a process to send a request to a server, and wait a maximum of
> (let's say) 300 milliseconds. If no reply comes in this time span, a
> default action should be taken.
> Is using a poller the only solution to this? I'm using the ruby
> bindings (rbzmq), and didn't see any reference to pollers in the rdoc.

Yes, you need to use zmq_poll. Take a look at the Ruby FFI bindings (ffi-rzmq gem) and look at the examples. There is at least one showing how to use the poller.

And don't worry about FFI being slow. It has gotten a lot of optimization attention from both the JRuby and Rubinius projects. The maintainer of the 'ffi' gem for JRuby also maintains it for MRI. In my benchmarking, FFI adds about 1 microsecond of overhead on each call.


More information about the zeromq-dev mailing list