I am unable to find any example on how to Use Amazon AWS SQS service in conjunction with Ruby on Rails.
Please could someone provide a simple, barebones example of using SQS to send email.
You may check Shoryuken, it's integrated with SQS and Rails (ActiveJob). But you can also use it without Rails, in a standalone Ruby app.
You may look into these examples. I have taken this from the GitHub GIST - AWS SQS Example.
#!/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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With