Asynchronous HTTP requests with ruby

Eqbal's Avatar

Eqbal

19 Feb, 2012 11:18 AM

I have a rabbitmq queue full of requests and I want to send the requests as an HTTP GET asynchronously, without the need to wait for each request response. now I'm confused of what is better to use, threads or just EM ? The way i'm using it at the moment is something like the following , but it would be great to know if there is any better implementation with better performance here since it is a very crucial part of the program :

AMQP.start(:host => "localhost") do |connection|
  queue = MQ.queue("some_queue")
  queue.subscribe do |body|
    EventMachine::HttpRequest.new('http://localhost:9292/faye').post :body => {:message =>  body.to_json }
  end
end

With the code above, is the system will wait for each request to finish before starting the next one ? and if there any tips here I would highly appreciate it.

Thanks in advance .

  1. Support Staff 1 Posted by Evan Phoenix on 21 Feb, 2012 12:57 AM

    Evan Phoenix's Avatar

    This support system is for the rubygems infrastructure, not for help on individual gems. I'll have to inquire with the authors of the gems you're using.

  2. Evan Phoenix closed this discussion on 21 Feb, 2012 12:57 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

23 Oct, 2014 05:37 PM
21 Oct, 2014 10:47 AM
18 Oct, 2014 08:39 PM
16 Oct, 2014 12:41 PM
06 Oct, 2014 02:30 PM