Skip to content

Instantly share code, notes, and snippets.

@frommww
frommww / page_processor_get_msgs.rb
Created September 13, 2012 02:12
Getting messages from IronMQ
def get_list_of_messages
#100 pages per worker at max
max_number_of_urls = 100
puts "Getting messages from IronMQ"
messages = @iron_mq_client.messages.get(:n => max_number_of_urls, :timeout => 100)
puts "Got messages from queue - #{messages.count}"
messages
end
#getting list of urls
@frommww
frommww / gist:2925809
Created June 13, 2012 19:02
Scheduling a worker to run once a day
client = IronWorkerNG::Client.new
params = {
# include the params the scheduled job needs
}
client.schedules.create("notification_scheduler", params,
:start_at => Time.now, :run_every => 60*60*24)
users = User.all
users.each_slice(100) do |users_slice|
client = IronWorkerNG::Client.new
params = {# include the params the worker needs
}
client.tasks.create("notification_worker", params)
end