README.md in songkick_queue-0.1.0 vs README.md in songkick_queue-0.2.0
- old
+ new
@@ -1,9 +1,10 @@
# SongkickQueue
A gem for processing tasks asynchronously, powered by RabbitMQ.
+[![Rubygems](https://badge.fury.io/rb/songkick_queue.svg)](https://rubygems.org/gems/songkick_queue)
[![Build status](https://travis-ci.org/songkick/queue.svg?branch=master)](https://travis-ci.org/songkick/queue)
## Dependencies
* Ruby 2.0+
@@ -31,22 +32,27 @@
You must define both the AMQP URL and a logger instance:
```ruby
SongkickQueue.configure do |config|
- config.amqp = 'amqp://localhost:5672'
- config.logger = Logger.new(STDOUT)
+ config.amqp = 'amqp://localhost:5672' # required
+ config.logger = Logger.new(STDOUT) # required
+ config.queue_namespace = ENV['RACK_ENV'] # optional
end
```
+You can also optionally define a namespace to apply to your queue names automatically when
+publishing and consuming. This can be useful to isolate environments that share the same RabbitMQ
+instance.
+
### Creating consumers
To create a consumer simply construct a new class and include the `SongkickQueue::Consumer`
module.
Consumers must declare a queue name to consume from (by calling `consume_from_queue`) and
-and define a `#process` method which receives a message.
+define a `#process` method which receives a message.
For example:
```ruby
class TweetConsumer
@@ -102,13 +108,13 @@
### Publishing messages
To publish messages for consumers, call the `#publish` method on `SongkickQueue`, passing in the
name of the queue to publish to and the message to send.
-The queue name must match one declared in a consumer by calling `consume_from_queue`.
+The queue name must match one declared by `consume_from_queue` in a consumer.
The message can be any primitive Ruby object that can be serialized into JSON. Messages are
-serialized whilst enqueued and deserialized for being passed to the `#process` method in your
+serialized whilst enqueued and deserialized before being passed to the `#process` method in your
consumer.
```ruby
SongkickQueue.publish('notifications-service.tweets', { text: 'Hello world', user_id: 57237722 })
```