Laboristo implements a simple way to use Amazon SQS messaging and run plain ruby workers.
Laboristo alternatives and similar gems
Based on the "Queue" category.
Alternatively, view Laboristo alternatives based on common mentions on social networks and blogs.
9.7 6.7 L5 Laboristo VS ResqueResque is a Redis-backed Ruby library for creating background jobs, placing them on multiple queues, and processing them later.
9.2 1.9 L5 Laboristo VS Delayed::JobDatabase based asynchronous priority queue system -- Extracted from Shopify
7.5 1.1 L5 Laboristo VS QueA Ruby job queue that uses PostgreSQL's advisory locks for speed and reliability.
7.5 7.5 L5 Laboristo VS ShoryukenA super efficient Amazon SQS thread based message processor for Ruby
7.0 7.1 L5 Laboristo VS BunnyBunny is a popular, easy to use, mature Ruby client for RabbitMQ
6.4 7.9 Laboristo VS KarafkaFramework for Apache Kafka based Ruby and Rails applications development.
2.4 2.8 L5 Laboristo VS March HareIdiomatic, fast and well-maintained JRuby client for RabbitMQ
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Laboristo or a related project?
Laboristo is an attempt to port Ost simplicity to AWS SQS.
$ gem install laboristo
Add this line to your application's Gemfile:
And then execute:
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... end
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 end
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:
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.
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.