README.md in insque-0.5.1 vs README.md in insque-0.5.2

- old
+ new

@@ -39,33 +39,70 @@ ### Recieving To start recieving messages you need to: 1. Create handler method in Insque module. First part of handler name is the name of the message sender. -```ruby -def somesender_message_name message - #TODO: Handle message somehow -end -``` + ```ruby + def somesender_message_name message + #TODO: Handle message somehow + end + ``` 2. Call `listen` method in some background process or rake task: -```ruby -Insque.listen -``` + ```ruby + Insque.listen + ``` or just run `bundle exec rake insque:listener` from your console. 3. Call `janitor` method in some background process or rake task. Janitor will reissue failed messages or report error if message fails again. Janitor treats message as failed if it was not processed for an hour after broadcast or reissue. + ```ruby + Insque.janitor + ``` + + or just run `bundle exec rake insque:janitor` from your console. + +### Slow Queue and send_later + +Insque can be used for processing slow tasks in background. Slow tasks created with send_later method call of any ActiveRecord model: ```ruby -Insque.janitor +User.send_later :some_slow_method ``` +and processed by a special slow listener: +```ruby +Insque.slow_listen +``` +there is matching slow janitor as well: +```ruby +Insque.slow_janitor +``` +### insque:run - or just run `bundle exec rake insque:janitor` from your console. +There is a simple way to run all insque workers, both regular and slow in a single multi-threaded process: +```ruby +bundle exec rake insque:run +``` +### RedisCluster support + +To make insque run on Redis Cluster add this line to your application's `Gemfile`: + + gem 'redis_cluster' + +and change `redis.yml` file accordingly: + + production: + - host: cluster_host1 + port: 1234 + - host: cluster_host2 + port: 1234 + - host: cluster_host3 + port: 1234 + ### Daemonizing -If you want to run insque listener as a daemon consider using [foreman](https://github.com/ddollar/foreman) for this. +If you want to run insque as a daemon consider using [foreman](https://github.com/ddollar/foreman) for this. If you deploy with capistrano you may want to try a version of foreman with build in capistrano support. Add foreman to your `Gemfile`: @@ -76,20 +113,20 @@ $ bundle install Create `Procfile`: - listener: bundle exec rake insque:listener - janitor: bundle exec rake insque:janitor + insque: bundle exec rake insque:run + Run foreman from your console: $ bundle exec foreman start For production use modify your capistrano deploy script somewhat like this: set :default_environment, {'PATH' => "/sbin:$PATH"} # Optional. Useful if you get errors because start or restart command not found - set :foreman_concurrency, "\"listener=2,janitor=1\"" # How many processes of each type do you want + set :foreman_concurrency, "\"insque=1\"" # How many processes of each type do you want require 'foreman/capistrano' after "deploy", "foreman:export" # Export Procfile as a set of upstart jobs after "deploy", "foreman:restart" # You will need upstart installed on your server for this to work.