Skip to content

Commit

Permalink
Added Ruby examples for SQS (chapter 4).
Browse files Browse the repository at this point in the history
  • Loading branch information
Flavia Paganelli authored and Flavia Paganelli committed Feb 25, 2011
1 parent bf5e31f commit 0c36a13
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
17 changes: 17 additions & 0 deletions sqs/example1/receive_message.rb
@@ -0,0 +1,17 @@
require 'rubygems'
require 'right_aws'

sqs = RightAws::SqsGen2.new("AKIAIGKECZXA7AEIJLMQ",
"w2Y3dx82vcY1YSKbJY51GmfFQn3705ftW4uSBrHn")

# create the queue, if it doesn't exist, with a VisibilityTimeout of 120 (seconds)
images_queue = sqs.queue("images", true, 120)

# now get the messages
message = images_queue.receive

# process the message, if any
# the process method is application-specific
if (process(message.body)) then
message.delete
end
13 changes: 13 additions & 0 deletions sqs/example1/send_message.rb
@@ -0,0 +1,13 @@
require 'rubygems'
require 'right_aws'

# get SQS service with AWS credentials
sqs = RightAws::SqsGen2.new("AKIAIGKECZXA7AEIJLMQ",
"w2Y3dx82vcY1YSKbJY51GmfFQn3705ftW4uSBrHn")

# create the queue, if it doesn't exist, with a VisibilityTimeout of 120 (seconds)
images_queue = sqs.queue("images", true, 120)

# the only thing we need to pass is the URL to the image in S3
images_queue.send_message(
"https://s3.amazonaws.com/media.kulitzer.com.production/212/24/replication.jpg")

0 comments on commit 0c36a13

Please sign in to comment.