Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Async job queuing and execution via Amazon SQS - Ruby Gem

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 examples
Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 Gemfile
Octocat-spinner-32 LICENSE.txt
Octocat-spinner-32 Rakefile
Octocat-spinner-32 sqser.gemspec

Build Status


SQSer is a library to perform simple job queuing and execution via an Amazon SQS Queue.

It provides a class which can be used as a parent to job classes which can be queued.

The job class and instance variables are converted to YAML and queued. When the job is processed, the object is created and variables loaded from the message.


gem install sqser



Set your AWS Secret and Access Keys:

export AWS_ACCESS_KEY_ID='...'

Queuing Jobs

Require sqser and set the queue_url

require 'sqser'
Sqser::Queue.queue_url = ''

Create a Job Class which inherits from Sqser::Job with attr_accesors for instance variables to be persisted in SQS.

class TestJob < Sqser::Job
  attr_accessor :value

  def run
    puts "My value: #{@value}."

Create a new job from this class and set the instance values.

job =
job.value = 'testing 123'

Queue the job in SQS.


You can pass the following options to queue_job.

  • :delay_seconds - The number of seconds to delay the message.
  • :secret - Secret to encrypt message.

For example

job.queue_job :delay_seconds => 60

Running Jobs

To process jobs, create a new Sqser::Queue instance and call process.

queue =

You can pass the following options to process.

  • :limit - The maximum number of messages to receive.
  • :secret - Secret to decrypt messages processed from queue.
  • :visibility_timeout - The duration (in seconds) that the received messages are hidden from subsequent retrieve requests.
  • :wait_time_seconds - The number of seconds the service should wait for a response when requesting a new message.

For example

queue.process :visibility_timeout => 180


Messages can be encrypted before being placed in SQS.

If the :secret option is specified, the message will be symetrically encrypted with the given secret before the job is queued.

For example:

job.queue_job :secret => 'this-is-a-secret'

Messages can then be retrieved from the queue and decrypted by specifying :secret option to process.

queue.process :secret => 'this-is-a-secret'

Currently only a single secret can be used per SQS Queue.

See examples for examples leveraging encryption.


Checkout the examples for working code.


Thanks to @bradly and @vsomayaji for providing original inspiration.


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Something went wrong with that request. Please try again.