Laboristo implements a simple way to use Amazon SQS messaging and run plain ruby workers.

Monthly Downloads: 112
Programming language: Ruby
License: MIT License
Tags: Queue     Background Jobs     Message Queue    

Laboristo alternatives and similar gems

Based on the "Queue" category.
Alternatively, view Laboristo alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of Laboristo or a related project?

Add another 'Queue' Gem



Gem Version Dependency Status Code Climate Build Status

Laboristo is an attempt to port Ost simplicity to AWS SQS.

enter image description here


Simply run:

$ gem install laboristo

Using Bundler?

Add this line to your application's Gemfile:

gem 'laboristo'

And then execute:

$ bundle


Before using Laboristo, you will need to set some environment variables:


Please, refer to [AWS documentation](%28http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSGettingStartedGuide/AWSCredentials.html%29) to obtain the corresponding values for your account.


First of all, if you are not familiar with AWS SQS I hardly recommend that you begin reading the AWS SQS Getting Started Guide.

Here are some considerations that you need to know when using Laboristo and SQS:

  • Laboristo does not create queues. You will have to set them up before sending messages to it (pretty obvious, right?). For instance, you can use AWS Console to create quehes.
  • When creating queues, you can set up queue attributes such as DelaySeconds, MaximumMessageSize, MessageRetentionPeriod, Policy, ReceiveMessageWaitTimeSeconds and VisibilityTimeout. Tune this settings according to your needs to efficiently use the service, and keep usage costs at a minimum level.
  • Laboristo retrieves the message, yields the process to your code, and then deletes the message from the queue. If something fails in between, the message will go back to the queue. I encourage you to consider using Dead Letter Queues to prevent eternal processing of invalid/wrong messages.


To refer to a particular queue, you will need the corresponding queue url, an attribute defined by AWS SQS when you create a queue. You can check the queue url in the AWS SQS Console. In the following examples, we will assume a queue having an url like this:


To push a message to the queue:

require 'laboristo'

Laboristo['https://sqs.us-east-1.amazonaws.com/123456789/my_queue'] << 'some message'

And get messages from a queue:

require 'laboristo'
Laboristo['https://sqs.us-east-1.amazonaws.com/123456789/my_queue'].each do |msg|
  # Do something with msg...


Workers can be as simple as this:

  require 'my_app'

  Laboristo['https://sqs.us-east-1.amazonaws.com/123456789/my_queue'].each do |message|
    # Do some magic stuff with the message

For instance, you can place your worker at ./workers/my_worker.rb and run this code to run worker in foreground:

  $ laboristo workers/my_worker

To run it in background you can use -d flag to daemonize the process:

  $ laboristo workers/my_worker -d

And, to stop a worker running in background, you can confidently kill the process:

  $ kill $$(cat /tmp/my_worker.pid)

Keep in mind that, because of how SQS works, unprocessed messages will go back to the queue. So, if you kill the worker process, unprocessed messages will go back to queue.


Delete all messages from a queue:


Because of AWS SQS restrictions, you can purge a queue only once every 60 seconds.


After cloning repository install dependencies using dep:

  $ dep install

Set environment variables as explained before in this document, and run the tests:

  $ make


First of all, help me adding more tests! This gem stated as an experiment, so you can expect bugs.

Feel free to report bugs, open issues, comments and pull requests. Only keep in mind that I just want to keep this gem neat and simple.


Most of the credit for this gem goes to @soveran and @djanowski, who created the code this gem is based on. Kudos to them!


Laboristo is released under the MIT License.

*Note that all licence references and agreements mentioned in the Laboristo README section above are relevant to that project's source code only.