RabbitMQ JRuby Client using Java RabbitMQ client
Pull request Compare This branch is 43 commits ahead of nickbourner:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


RabbitMQ JRuby Client
rabbitmq-jruby-client allows you to use RabbitMQ Client from JRuby using the official Java RabbitMQ client from Rabbit Technologies
See more at http://www.rabbitmq.com

Getting Started
1. Install and start RabbitMQ (see below)
2. Install JRuby RabbitMQ Client: jruby -S gem install rabbitmq-jruby-client

Example Usage
gem 'rabbitmq-jruby-client'
require 'rabbitmq_client'

# Initializes the new client and connect to the server
client = RabbitMQClient.new

# Initializes a new queue
queue = client.queue('queue_name')

# Initializes a new exchange
exchange = client.exchange('exchange_name')

# Connects queue with the exchange

# Publish a message to the queue
queue.publish('message body')

# Retrieve a message from the queue
message = queue.retrieve

# Subscribe to a queue with callback. (Event-driven)
queue.subscribe do |message|
  # do something with message

# Subscribe to a queue in a loop. (Polling)
queue.loop_subscribe do |message|
  # do something with message

Installing RabbitMQ on OS X
1. Install MacPorts
2. sudo port install rabbitmq-server

To run RabbitMQ
3. sudo rabbitmq-server

By default standard ruby marshalling is used to serialise data but this can be overridden by using a marshalling class
which responds to two method calls:
1) load takes an array of java bytes and returns whatever you desrialise from this
2) dump takes a message and must produce an array of java bytes, a RabbitMQClientError is raised if the output is not 
a suitable array

The marshalling class can be set in several ways:
1. By instantiating a RabbitMQClient with a option of :marshaller set to the class you wish use as your default marshaller
2. By setting the 3rd argument of RabbitMQClient#queue to the class you wish to use for this queue
3. By instantiating a RabbitMQClient::QueueConsumer with a 3rd argument of the class you wish to use
4. By using RabbitMQClient#marshaller=
5. By using RabbitMQClient::Queue#marshaller=