Consuming a SOAP WebService with sleep time between requests

128 views
Skip to first unread message

Mauro Nidola

unread,
Jul 8, 2013, 3:41:29 AM7/8/13
to typh...@googlegroups.com
Hi guys,
I'm currently using Savon (http://rubygems.org/gems/savon) in a rubyonrails 3.2 application running on a server with apache 2 + passenger (free version, without threads) to consume a SOAP WebService.
My application needs to fetch paged data (almost 400 pages => 400 requests) an there is a constraint on the use of the webservice: 2 seconds between each request. 
Is it possible to do that with typhoeus (Hydra module)?

Many thanks in advance for your reply.
Mauro

Hans Hasselberg

unread,
Jul 10, 2013, 3:52:57 AM7/10/13
to typh...@googlegroups.com

Hey Mauro,

There is no building mechanism to do that but it's quite easy to do that
with plain ruby:

requests.each {|req| req.run; sleep 2 }

Does that help?

--
You received this message because you are subscribed to the Google Groups "Typhoeus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to typhoeus+u...@googlegroups.com.
To post to this group, send email to typh...@googlegroups.com.
Visit this group at http://groups.google.com/group/typhoeus.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Mauro Nidola

unread,
Jul 10, 2013, 11:47:32 AM7/10/13
to typh...@googlegroups.com
I use the "sleep approach" in my current implementation (based on the HTTParty gem), but it takes a lot of time to fetch the ~400 pages of data.
I'd like to save time running requests in parallel using the Hydra module, but I don't know how to force the pause of 2 seconds between parallel requests.

Mauro

Hans Hasselberg

unread,
Jul 11, 2013, 3:39:12 AM7/11/13
to typh...@googlegroups.com

If you are only allowed to do one request every 2seconds you cannot do
parallel requests, or am I wrong? Running two requests in parallel is
almost the same as starting two threads and run a request in each of them.
Which would also exceed the limit.

But you can use Typhoeus nevertheless. Typhoeus keeps the connection open
even for single requests which goes a long way if you request the same
server over and over again.

Reply all
Reply to author
Forward
0 new messages