amqp 0.8.0.rc5 → 0.8.0.rc6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +6 -45
- data/amqp.gemspec +1 -1
- data/docs/Clustering.textile +25 -0
- data/docs/DocumentationGuidesIndex.textile +2 -1
- data/docs/Durability.textile +49 -3
- data/docs/GettingStarted.textile +12 -5
- data/docs/Queues.textile +1 -1
- data/examples/connection/connect_and_immediately_disconnect.rb +16 -0
- data/examples/guides/queues/09_unsubscribing_a_consumer.rb +2 -1
- data/lib/amqp/exchange.rb +2 -14
- data/lib/amqp/queue.rb +2 -14
- data/lib/amqp/version.rb +1 -1
- data/spec/integration/regressions/issue66_spec.rb +35 -0
- metadata +11 -7
data/README.textile
CHANGED
@@ -103,9 +103,12 @@ end
|
|
103
103
|
|
104
104
|
(see "as a Gist":https://gist.github.com/910211)
|
105
105
|
|
106
|
+
"Getting started guide":http://rdoc.info/github/ruby-amqp/amqp/master/file/docs/GettingStarted.textile explains this and two more examples in detail,
|
107
|
+
and is written in a form of a tutorial.
|
106
108
|
|
107
109
|
|
108
|
-
|
110
|
+
|
111
|
+
h2. Documentation: tutorials, guides & API reference
|
109
112
|
|
110
113
|
We believe that in order to be the best Ruby AMQP client out there, we need to care about documentation as much as
|
111
114
|
code readability, API beauty and autotomated testing across 5 Ruby implementations on 3 operating systems.
|
@@ -140,50 +143,8 @@ h3. API reference
|
|
140
143
|
|
141
144
|
h2. How to use AMQP gem with Ruby on Rails, Merb, Sinatra and other web frameworks
|
142
145
|
|
143
|
-
|
144
|
-
|
145
|
-
you are all set: those two servers use EventMachine under the hood.
|
146
|
-
|
147
|
-
With other web servers, you need to start EventMachine reactor in a separate thread like this:
|
148
|
-
|
149
|
-
<pre>Thread.new { EM.run }</pre>
|
150
|
-
|
151
|
-
Otherwise EventMachine will block current thread.
|
152
|
-
|
153
|
-
|
154
|
-
Then connect to AMQP broker:
|
155
|
-
|
156
|
-
<pre>amqp_connection = AMQP.connect(:host => "localhost", :user => "guest", :pass => "guest", :vhost => "/")</pre>
|
157
|
-
|
158
|
-
In a Ruby on Rails app, probably the best place for this code is initializer
|
159
|
-
(like config/initializers/amqp.rb). For Merb apps, it is config/init.rb. For
|
160
|
-
Sinatra and pure Rack applications, place it next to other configuration
|
161
|
-
code.
|
162
|
-
|
163
|
-
If you want to integrate AMQP with "Thin":http://code.macournoyer.com/thin/, "Goliath":https://github.com/postrank-labs/goliath/ or
|
164
|
-
some other EventMachine-based software which already runs an event loop, you might want to use following code:
|
165
|
-
|
166
|
-
<pre>EM.next_tick { AMQP.connect(...) }</pre>
|
167
|
-
|
168
|
-
So in case EventMachine reactor isn't running yet on server/application boot,
|
169
|
-
connection won't fail but instead wait for reactor to start.
|
170
|
-
|
171
|
-
Same separate thread technique can be used to make EventMachine play nicely with other
|
172
|
-
libraries that would block current thread (like "File::Tail":http://rubygems.org/gems/file-tail).
|
173
|
-
|
174
|
-
|
175
|
-
h2. Using amqp gem in your app/library using Bundler
|
176
|
-
|
177
|
-
With Bundler, add this line to your Gemfile:
|
178
|
-
|
179
|
-
<pre>gem "amqp"</pre>
|
180
|
-
|
181
|
-
If you want to use edge version (usually there is no need to):
|
182
|
-
|
183
|
-
<pre>
|
184
|
-
gem "amqp", :git => "git://github.com/ruby-amqp/amqp.git", :branch => "master"
|
185
|
-
</pre>
|
186
|
-
|
146
|
+
We cover this subject for multiple Ruby application servers in "Connecting to the broker guide":http://bit.ly/kFCVQU, take a look and let us know
|
147
|
+
what wasn't clear.
|
187
148
|
|
188
149
|
|
189
150
|
h2. How does amqp gem relate to amq-client gem, amq-protocol and libraries like bunny?
|
data/amqp.gemspec
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
h1. Clustering
|
2
|
+
|
3
|
+
|
4
|
+
h2. About this guide
|
5
|
+
|
6
|
+
This guide covers clustered AMQP broker setups, with RabbitMQ as example.
|
7
|
+
|
8
|
+
|
9
|
+
h2. Covered versions
|
10
|
+
|
11
|
+
TBD
|
12
|
+
|
13
|
+
|
14
|
+
h2. Clustering
|
15
|
+
|
16
|
+
TBD
|
17
|
+
|
18
|
+
|
19
|
+
h2. Tell us what you think!
|
20
|
+
|
21
|
+
Please take a moment and tell us what you think about this guide on "Ruby AMQP mailing list":http://groups.google.com/group/ruby-amqp:
|
22
|
+
what was unclear? what wasn't covered? maybe you don't like guide style or grammar and spelling are incorrect? Readers feedback is
|
23
|
+
key to making documentation better.
|
24
|
+
|
25
|
+
If mailing list communication is not an option for you for some reason, you can "contact guides author directly":mailto:michael@novemberain.com?subject=amqp%20gem%20documentation
|
@@ -8,9 +8,10 @@ h2. Guide list
|
|
8
8
|
* {file:docs/Exchanges.textile Exchanges}
|
9
9
|
* {file:docs/Bindings.textile Bindings}
|
10
10
|
* {file:docs/Routing.textile Routing}
|
11
|
-
* {file:docs/Durability.textile
|
11
|
+
* {file:docs/Durability.textile Durability and message persistence}
|
12
12
|
* {file:docs/ErrorHandling.textile Error handling}
|
13
13
|
* {file:docs/08Migration.textile Upgrading from version 0.6.x/0.7.x to 0.8.x and above}
|
14
|
+
* {file:docs/Clustering.textile Clustering}
|
14
15
|
* {file:docs/RabbitMQVersions.textile RabbitMQ versions}
|
15
16
|
* {file:docs/ConnectionEncryptionWithTLS.textile Using TLS (SSL)}
|
16
17
|
* {file:docs/VendorSpecificExtensions.textile Vendor-specific extensions to AMQP 0.9.1 spec}
|
data/docs/Durability.textile
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
h1.
|
1
|
+
h1. Durability and related matters
|
2
2
|
|
3
3
|
|
4
4
|
h2. About this guide
|
5
5
|
|
6
|
-
|
6
|
+
This guide covers queue, exchange and message durability, as well as other
|
7
|
+
topics related to durability, for example, durability in cluster environment.
|
7
8
|
|
8
9
|
|
9
10
|
h2. Covered versions
|
@@ -11,12 +12,57 @@ h2. Covered versions
|
|
11
12
|
This guide covers amqp gem v0.8.0 and later.
|
12
13
|
|
13
14
|
|
15
|
+
h2. Entity durability and message persistence
|
16
|
+
|
17
|
+
h3. Durability of exchanges
|
18
|
+
|
19
|
+
AMQP separates concept of durability of entities (queues, exchanges) from messages persistence.
|
20
|
+
Exchanges can be durable or transient. Durable exchanges survive broker restart, transient exchanges don't (they
|
21
|
+
have to be redeclared when broker comes back online). Not all scenarios and use cases mandate exchanges to be
|
22
|
+
durable.
|
23
|
+
|
24
|
+
|
25
|
+
h3. Durability of queues
|
26
|
+
|
27
|
+
Durable queues are persisted to disk and thus survive broker restarts. Queues that are not durable are called transient.
|
28
|
+
Not all scenarios and use cases mandate queues to be durable.
|
29
|
+
|
30
|
+
Note that *only durable queues can be bound to durable exchanges*. This guarantees that it is possible to restore bindings
|
31
|
+
on broker restart.
|
32
|
+
|
33
|
+
Durability of a queue does not make _messages_ that are routed to that queue durable. If broker is taken down and then
|
34
|
+
brought back up, durable queue will be re-declared during broker startup, however, only _persistent_ messages will be recovered.
|
35
|
+
|
36
|
+
|
37
|
+
h3. Persistence of messages
|
14
38
|
|
15
|
-
|
39
|
+
The concept of messages persistence is separate: messages may be published as persistent. That makes
|
40
|
+
AMQP broker persist them to disk. If the server is restarted, the system ensures that received persistent messages
|
41
|
+
are not lost. Simply publishing message to a durable exchange or the fact that queue(s) they are routed to
|
42
|
+
is durable doesn't make messages persistent: it all depends on persistence mode of the messages itself.
|
43
|
+
Publishing messages as persistent affects performance (just like with data stores, durability comes at a certain cost
|
44
|
+
in performance and vise versa). Pass :persistent => true to {Exchange#publish} to publish your message as persistent.
|
45
|
+
|
46
|
+
|
47
|
+
h3. Transactions
|
48
|
+
|
49
|
+
TBD
|
50
|
+
|
51
|
+
|
52
|
+
h3. Publisher confirms
|
16
53
|
|
17
54
|
TBD
|
18
55
|
|
19
56
|
|
57
|
+
h3. Clustering
|
58
|
+
|
59
|
+
To achieve degree of durability critical applications need, it's necessary but not enough to use durable queues,
|
60
|
+
exchanges and persistent messages. You need to use a cluster of brokers because otherwise, a single hardware problem
|
61
|
+
may bring broker down completely.
|
62
|
+
|
63
|
+
See {file:docs/Clustering.textile Clustering guide} for in-depth discussion of this topic.
|
64
|
+
|
65
|
+
|
20
66
|
|
21
67
|
h2. Tell us what you think!
|
22
68
|
|
data/docs/GettingStarted.textile
CHANGED
@@ -55,35 +55,41 @@ This guides assumes you have one of the supported Ruby implementations installed
|
|
55
55
|
h3. With Rubygems
|
56
56
|
|
57
57
|
To get amqp gem 0.8.0
|
58
|
+
<pre>
|
58
59
|
<code>
|
59
60
|
gem install amqp --pre
|
60
61
|
</code>
|
62
|
+
</pre>
|
61
63
|
|
62
64
|
h3. With Bundler
|
63
65
|
|
66
|
+
<pre>
|
64
67
|
<code>
|
65
68
|
gem "amqp", :git => "git://github.com/ruby-amqp/amqp.git", :branch => "master"
|
66
69
|
</code>
|
70
|
+
</pre>
|
67
71
|
|
68
72
|
h3. Verifying your installation
|
69
73
|
|
70
74
|
Lets verify your installation with this quick irb session:
|
71
75
|
|
76
|
+
<pre>
|
72
77
|
<code>
|
73
78
|
irb -rubygems
|
74
79
|
|
75
80
|
:001 > require "amqp"
|
76
|
-
|
77
|
-
|
78
|
-
|
81
|
+
=> true
|
82
|
+
:002 > AMQP::VERSION
|
83
|
+
=> "0.8.0.rc2"
|
79
84
|
</code>
|
80
|
-
|
85
|
+
</pre>
|
81
86
|
|
82
87
|
|
83
88
|
h2. A "Hello, world" example
|
84
89
|
|
85
90
|
Lets begin with a classic Hello, world example. First, here's the code:
|
86
91
|
|
92
|
+
<pre>
|
87
93
|
<code>
|
88
94
|
#!/usr/bin/env ruby
|
89
95
|
# encoding: utf-8
|
@@ -110,6 +116,7 @@ EventMachine.run do
|
|
110
116
|
exchange.publish "Hello, world!", :routing_key => queue.name
|
111
117
|
end
|
112
118
|
</code>
|
119
|
+
</pre>
|
113
120
|
|
114
121
|
This example demonstrates a very common communication scenario: app A wants to publish a message that will end up in
|
115
122
|
a queue that app B listens on. In this example, queue name is "amqpgem.examples.hello". Lets go through this example
|
@@ -376,7 +383,7 @@ demonstrating how one can use AMQP fanout exchanges to do broadcasting.
|
|
376
383
|
h2. Weathr: many-to-many topic routing example
|
377
384
|
|
378
385
|
So far we have seen point-to-point communication and broadcast. These two are possible with many protocols:
|
379
|
-
HTTP handles these scenarios just fine. What differentiates AMQP? Next
|
386
|
+
HTTP handles these scenarios just fine. What differentiates AMQP? Next we are going to introduce you to topic
|
380
387
|
exchanges and routing with patterns, one of the features that makes AMQP very powerful.
|
381
388
|
|
382
389
|
Our third example is weather condition updates. What makes it different from the previous two is that
|
data/docs/Queues.textile
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require "bundler"
|
5
|
+
Bundler.setup
|
6
|
+
|
7
|
+
$:.unshift(File.expand_path("../../../lib", __FILE__))
|
8
|
+
|
9
|
+
require 'amqp'
|
10
|
+
|
11
|
+
EventMachine.run do
|
12
|
+
connection = AMQP.connect(:host => '127.0.0.1')
|
13
|
+
connection.disconnect {
|
14
|
+
EventMachine.stop
|
15
|
+
}
|
16
|
+
end
|
@@ -4,7 +4,8 @@
|
|
4
4
|
require "rubygems"
|
5
5
|
require "amqp"
|
6
6
|
|
7
|
-
AMQP.start("amqp://guest:guest@dev.rabbitmq.com:5672/") do |connection, open_ok|
|
7
|
+
#AMQP.start("amqp://guest:guest@dev.rabbitmq.com:5672/") do |connection, open_ok|
|
8
|
+
AMQP.start do |connection, open_ok|
|
8
9
|
AMQP::Channel.new do |channel, open_ok|
|
9
10
|
exchange = channel.fanout("amq.fanout")
|
10
11
|
|
data/lib/amqp/exchange.rb
CHANGED
@@ -112,19 +112,7 @@ module AMQP
|
|
112
112
|
#
|
113
113
|
# h2. Exchange durability and persistence of messages.
|
114
114
|
#
|
115
|
-
#
|
116
|
-
# Exchanges can be durable or transient. Durable exchanges survive broker restart, transient exchanges don't (they
|
117
|
-
# have to be redeclared when broker comes back online). Not all scenarios and use cases mandate exchanges to be
|
118
|
-
# durable.
|
119
|
-
#
|
120
|
-
# The concept of messages persistence is separate: messages may be published as persistent. That makes
|
121
|
-
# AMQP broker persist them to disk. If the server is restarted, the system ensures that received persistent messages
|
122
|
-
# are not lost. Simply publishing message to a durable exchange or the fact that queue(s) they are routed to
|
123
|
-
# is durable doesn't make messages persistent: it all depends on persistence mode of the messages itself.
|
124
|
-
# Publishing messages as persistent affects performance (just like with data stores, durability comes at a certain cost
|
125
|
-
# in performance and vise versa). Pass :persistent => true to {Exchange#publish} to publish your message as persistent.
|
126
|
-
#
|
127
|
-
# Note that *only durable queues can be bound to durable exchanges*. Learn more in our {file:docs/Durability.textile Durability guide}.
|
115
|
+
# Learn more in our {file:docs/Durability.textile Durability guide}.
|
128
116
|
#
|
129
117
|
#
|
130
118
|
#
|
@@ -429,7 +417,7 @@ module AMQP
|
|
429
417
|
#
|
430
418
|
# @return [Exchange] self
|
431
419
|
#
|
432
|
-
# @note Please make sure you read {
|
420
|
+
# @note Please make sure you read {file:docs/Durability.textile Durability guide} that covers exchanges durability vs. messages
|
433
421
|
# persistence.
|
434
422
|
# @api public
|
435
423
|
def publish(payload, options = {}, &block)
|
data/lib/amqp/queue.rb
CHANGED
@@ -96,19 +96,7 @@ module AMQP
|
|
96
96
|
#
|
97
97
|
# h2. Queue durability and persistence of messages.
|
98
98
|
#
|
99
|
-
#
|
100
|
-
# Queues can be durable or transient. Durable queues survive broker restart, transient queues don't (they
|
101
|
-
# have to be redeclared when broker comes back online). Long-living queues (see Queue life-cycle section above)
|
102
|
-
# are usually durable, short-lived queues don't have to be.
|
103
|
-
#
|
104
|
-
# The concept of messages persistence is separate: messages may be published as persistent. That makes
|
105
|
-
# AMQP broker persist them to disk. If the server is restarted, the system ensures that received persistent messages
|
106
|
-
# are not lost. Simply publishing message to a durable exchange or the fact that queue(s) they are routed to
|
107
|
-
# is durable doesn't make messages persistent: it all depends on persistence mode of the messages itself.
|
108
|
-
# Publishing messages as persistent affects performance (just like with data stores, durability comes at a certain cost
|
109
|
-
# in performance and vise versa). Pass :persistent => true to {Exchange#publish} to publish your message as persistent.
|
110
|
-
#
|
111
|
-
# Note that *only durable queues can be bound to durable exchanges*. Learn more in our {file:docs/Durability.textile Durability guide}.
|
99
|
+
# Learn more in our {file:docs/Durability.textile Durability guide}.
|
112
100
|
#
|
113
101
|
#
|
114
102
|
# h2. Message ordering
|
@@ -123,7 +111,7 @@ module AMQP
|
|
123
111
|
# Learn more in {file:docs/ErrorHandling.textile Error Handling guide}.
|
124
112
|
#
|
125
113
|
#
|
126
|
-
# @note Please make sure you read
|
114
|
+
# @note Please make sure you read {file:docs/Durability.textile Durability guide} that covers exchanges durability vs. messages
|
127
115
|
# persistence.
|
128
116
|
#
|
129
117
|
#
|
data/lib/amqp/version.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe "Authentication attempt" do
|
5
|
+
|
6
|
+
#
|
7
|
+
# Environment
|
8
|
+
#
|
9
|
+
|
10
|
+
include EventedSpec::AMQPSpec
|
11
|
+
include EventedSpec::SpecHelper
|
12
|
+
|
13
|
+
|
14
|
+
describe "with default connection parameters" do
|
15
|
+
|
16
|
+
#
|
17
|
+
# Examples
|
18
|
+
#
|
19
|
+
|
20
|
+
# assuming there is an account guest with password of "guest" that has
|
21
|
+
# access to / (default vhost)
|
22
|
+
context "when guest/guest has access to /" do
|
23
|
+
after :all do
|
24
|
+
done
|
25
|
+
end
|
26
|
+
|
27
|
+
it "succeeds" do
|
28
|
+
c = AMQP.connect
|
29
|
+
c.disconnect
|
30
|
+
|
31
|
+
done
|
32
|
+
end # it
|
33
|
+
end # context
|
34
|
+
end # describe
|
35
|
+
end # describe "Authentication attempt"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amqp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 977940491
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 8
|
9
9
|
- 0
|
10
|
-
-
|
11
|
-
version: 0.8.0.
|
10
|
+
- rc6
|
11
|
+
version: 0.8.0.rc6
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Aman Gupta
|
@@ -17,7 +17,7 @@ authors:
|
|
17
17
|
autorequire:
|
18
18
|
bindir: bin
|
19
19
|
cert_chain:
|
20
|
-
date: 2011-05-
|
20
|
+
date: 2011-05-06 00:00:00 +04:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
@@ -42,13 +42,13 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
45
|
+
hash: 1369027924
|
46
46
|
segments:
|
47
47
|
- 0
|
48
48
|
- 7
|
49
49
|
- 0
|
50
|
-
-
|
51
|
-
version: 0.7.0.
|
50
|
+
- alpha18
|
51
|
+
version: 0.7.0.alpha18
|
52
52
|
type: :runtime
|
53
53
|
version_requirements: *id002
|
54
54
|
description: Widely used, feature-rich asynchronous AMQP 0.9.1 client with batteries included
|
@@ -63,6 +63,7 @@ extra_rdoc_files:
|
|
63
63
|
- README.textile
|
64
64
|
- docs/08Migration.textile
|
65
65
|
- docs/Bindings.textile
|
66
|
+
- docs/Clustering.textile
|
66
67
|
- docs/ConnectingToTheBroker.textile
|
67
68
|
- docs/ConnectionEncryptionWithTLS.textile
|
68
69
|
- docs/DocumentationGuidesIndex.textile
|
@@ -91,6 +92,7 @@ files:
|
|
91
92
|
- bin/set_test_suite_realms_up.sh
|
92
93
|
- docs/08Migration.textile
|
93
94
|
- docs/Bindings.textile
|
95
|
+
- docs/Clustering.textile
|
94
96
|
- docs/ConnectingToTheBroker.textile
|
95
97
|
- docs/ConnectionEncryptionWithTLS.textile
|
96
98
|
- docs/DocumentationGuidesIndex.textile
|
@@ -106,6 +108,7 @@ files:
|
|
106
108
|
- examples/channels/prefetch_as_constructor_argument.rb
|
107
109
|
- examples/channels/qos_aka_prefetch.rb
|
108
110
|
- examples/channels/qos_aka_prefetch_without_callback.rb
|
111
|
+
- examples/connection/connect_and_immediately_disconnect.rb
|
109
112
|
- examples/error_handling/channel_level_exception.rb
|
110
113
|
- examples/error_handling/channel_level_exception_with_multiple_channels_involved.rb
|
111
114
|
- examples/error_handling/connection_loss_handler.rb
|
@@ -204,6 +207,7 @@ files:
|
|
204
207
|
- spec/integration/queue_declaration_spec.rb
|
205
208
|
- spec/integration/queue_exclusivity_spec.rb
|
206
209
|
- spec/integration/queue_redeclaration_with_incompatible_attributes_spec.rb
|
210
|
+
- spec/integration/regressions/issue66_spec.rb
|
207
211
|
- spec/integration/reply_queue_communication_spec.rb
|
208
212
|
- spec/integration/store_and_forward_spec.rb
|
209
213
|
- spec/integration/topic_subscription_spec.rb
|