Created
June 3, 2012 17:24
-
-
Save amscotti/2864270 to your computer and use it in GitHub Desktop.
Amazon's Simple Queue Service with Node.js and Ruby - http://bit.ly/Nwn0Q1
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
aws = require ('aws-lib') | |
access_key_id = "<Your access key id>" | |
secret_access_key = "<Your secret access key>" | |
options = { | |
"path" : "<Your queue URL, just the /accountid/queue_name is needed>" | |
} | |
sqs = aws.createSQSClient(access_key_id, secret_access_key, options) | |
outbound = { | |
MessageBody : JSON.stringify({ | |
data: "Test Message", | |
timestamp: new Date().getTime() | |
}) | |
} | |
sqs.call "SendMessage", outbound, (err, result) -> | |
if err then console.log "SendMessage error: #{err}" |
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
require 'rubygems' | |
require 'aws-sdk' | |
require 'json' | |
sqs = AWS::SQS.new( | |
:access_key_id => '<Your access key id>', | |
:secret_access_key => '<Your secret access key>') | |
url = "<Your queue URL>" | |
receive = sqs.queues[url].receive_message() | |
if receive | |
puts JSON.parse(receive.body) | |
receive.delete | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment