Created
February 19, 2009 17:11
-
-
Save asceth/67007 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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