Skip to content

Instantly share code, notes, and snippets.

@mndoci
Forked from seratch/config.yml
Created February 5, 2013 13:49
Show Gist options
  • Save mndoci/4714562 to your computer and use it in GitHub Desktop.
Save mndoci/4714562 to your computer and use it in GitHub Desktop.
access_key_id: xxx
secret_access_key: yyy
#!/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
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment