Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Ruby examples for SQS (chapter 4).
- Loading branch information
Flavia Paganelli
authored and
Flavia Paganelli
committed
Feb 25, 2011
1 parent
bf5e31f
commit 0c36a13
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") |