-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathREADME
More file actions
51 lines (38 loc) · 1.21 KB
/
README
File metadata and controls
51 lines (38 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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
queue.bind(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
end
# Subscribe to a queue in a loop. (Polling)
queue.loop_subscribe do |message|
# do something with message
end
Installing RabbitMQ on OS X
===========================
1. Install MacPorts
2. sudo port install rabbitmq-server
To run RabbitMQ
3. sudo rabbitmq-server