Skip to content
Snippets Groups Projects
user avatar
Chris Harrison authored
a0c78327
History

sneakers_requeue_on_error

A Sneakers worker handler that will re-queue the message when encountering an error.

Installation

Add this line to your application's Gemfile:

gem 'sneakers_requeue_on_error'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install sneakers_requeue_on_error

Usage

Given a Sneakers worker:

class MyWorker
  include Sneakers::Worker
  
  from_queue :a_queue,
             handler: SneakersRequeueOnError::Handler,
             prefetch: 10,

  def work(message)
    # Do something worthwhile
    ack!
  end
end

Set the handler to be SneakersRequeueOnError::Handler.

From now on, if the work method encounters an error, the message will be place back on the queue.

Note that Sneakers has built in error handling around the work method, so you shouldn't attempt to catch any errors via rescue unless you want to bypass the error handling altogether.

Development

To contribute to this gem, simple clone the repository, run bundle install and run tests:

    bundle exec rspec
    bundle exec rubocop

Releasing

The release process is tied to the git tags. Simply creating a new tag and pushing will trigger a new release to rubygems.