Created
October 25, 2012 09:37
-
-
Save seratch/3951664 to your computer and use it in GitHub Desktop.
Revisions
-
seratch created this gist
Oct 25, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ access_key_id: xxx secret_access_key: yyy This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ #!/usr/bin/env ruby require 'yaml' require 'aws-sdk' config_file = File.join(File.dirname(__FILE__),"config.yml") config = YAML.load(File.read(config_file)) AWS.config(config) sqs = AWS::SQS.new queue = sqs.queues.create("my_queue") queue.poll do |msg| puts msg.body end This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ #!/usr/bin/env ruby require 'yaml' require 'aws-sdk' config_file = File.join(File.dirname(__FILE__),"config.yml") config = YAML.load(File.read(config_file)) AWS.config(config) # http://rubydoc.info/github/amazonwebservices/aws-sdk-for-ruby/master/AWS/SQS sqs = AWS::SQS.new queue = sqs.queues.create("my_queue") # http://rubydoc.info/github/amazonwebservices/aws-sdk-for-ruby/master/AWS/SQS/Queue send = lambda { |name, queue| while true do queue.send_message("#{name}:#{Time.now.to_s}") sleep 1 end } Thread.new { send.call("t1", queue) } Thread.new { send.call("t2", queue) } Thread.new { send.call("t3", queue) } sleep 1000