FanSQS is a background job processing engine for Ruby using AWS SQS for message storage.
Add this line to your application's Gemfile:
gem 'FanSQS'
And then execute:
$ bundle
Or install it yourself as:
$ gem install FanSQS
Create a config/initializer.rb file in your application directory and insert this line:
AWS.config( access_key_id: '<your_access_key_id>', secret_access_key: '<your_secret_access_key>')
FanSQS integrates seemlessly with your Rails applications. Just include the module FanSQS::Worker in the class that encapsulates your job logic and define a class method called perform. The method perform should be able to accept any number of parameters of any type.
class MessagePublisher
include FanSQS::Worker
set_fan_sqs_options queue: :message_queue # use the key :queue to define the message queue name
def self.perform(arg1, arg2, ...)
# code to do work
end
end
To push jobs into an SQS queue for processing, simply call:
MessagePublisher.perform_async(arg1, arg2, ...)
To start polling for jobs, simply call either one of the following commands:
> rake FanSQS:start_polling
> bundle exec rake FanSQS:start_polling # alternative
In the command line, run this command to return the number of specs passed & failed. All tests should pass!
> rspec
- Rake task to start polling for specific queues
- Priority queues
- Auto retries on error
- Hook up to Travis
- Fork it ( http://github.com//FanSQS/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Test coverage for your changes. Sorry I will not merge changes without test coverage!
- Push to the branch (
git push origin my-new-feature
) - Create new Pull Request