RSQS

Description

A ruby implementation of the Amazon SQS API.

Installation

sudo gem install rsqs

Pre-Requirements

First, RSQS expects that you have the following environmental variables set:

  1. AMAZON_ACCESS_KEY – Your amazon web services access key which you can find under “Access Identifiers” in your AWS account.
  2. AMAZON_SECRET_ACCESS_KEY – Your AWS secret access key which is found in in the same place as the access key.

The easiest way to do this is to setup a file in your home directory and add the following lines:

export AMAZON_ACCESS_KEY=1848101948W18189491 export AMAZON_SECRET_ACCESS_KEY=10198DKLDSL101/W31019D/10X

And then, assuming this file was called “.amazon_keys” you can load them:

source ~/.amazon_keys

Usage

Creating a New Queue

q = RSQS::Queue.create :new_queue

Putting New Messages

Note: This will assume that :new_queue exists to save you requests to SQS service. A QueueDoesNotExistError will be raised if the queue doesn’t exist.

RSQS::Queue.find :new_queue { send_message ‘My New Message’ }

OR

q = RSQS::Queue.find :new_queue q.send_message ‘My New Message’

NOTE: If you want RSQS to automatically create queues which do not exist, use the find_or_create method instead!

Getting Messages

q = RSQS::Queue.find :new_queue m = q.receive m #

License

(The MIT License)

Copyright © 2008 FIX

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.