Skip to content

Instantly share code, notes, and snippets.

@asceth
Created February 19, 2009 17:11
Show Gist options
  • Save asceth/67007 to your computer and use it in GitHub Desktop.
Save asceth/67007 to your computer and use it in GitHub Desktop.
# Publishes a set of pages, allows eventmachine/amqp to send them
# then restarts the process with another set of pages.
modulus = calc_modulus(number_of_pages)
number_of_pages.paged_collect(modulus).each_value do |pages|
AMQP.start do
pages.each do |page|
lclients = Legacy::Client.all(:limit => 100, :offset => page*100)
topic = MQ.new.topic('conversion')
lclients.map do |lclient|
topic.publish(serialize(lclient), :key => 'import.clients')
end
log "published page #{page} of #{number_of_pages} for clients..."
end
AMQP.stop do
EM.stop
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment