amqp 0.9.8 → 0.9.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +81 -72
- data/amqp.gemspec +5 -13
- data/docs/08Migration.textile +4 -0
- data/docs/AMQP091ModelExplained.textile +5 -0
- data/docs/Bindings.textile +4 -0
- data/docs/Clustering.textile +4 -0
- data/docs/ConnectingToTheBroker.textile +4 -0
- data/docs/ConnectionEncryptionWithTLS.textile +4 -0
- data/docs/DocumentationGuidesIndex.textile +4 -0
- data/docs/Durability.textile +4 -0
- data/docs/ErrorHandling.textile +4 -0
- data/docs/Exchanges.textile +4 -0
- data/docs/GettingStarted.textile +4 -0
- data/docs/PatternsAndUseCases.textile +4 -1
- data/docs/Queues.textile +4 -0
- data/docs/RabbitMQVersions.textile +4 -0
- data/docs/RunningTests.textile +4 -0
- data/docs/TestingWithEventedSpec.textile +4 -0
- data/docs/Troubleshooting.textile +4 -0
- data/docs/VendorSpecificExtensions.textile +4 -0
- data/lib/amqp/channel.rb +13 -12
- data/lib/amqp/client.rb +2 -2
- data/lib/amqp/connection.rb +1 -0
- data/lib/amqp/consumer.rb +2 -2
- data/lib/amqp/exchange.rb +5 -5
- data/lib/amqp/queue.rb +1 -1
- data/lib/amqp/session.rb +4 -4
- data/lib/amqp/version.rb +1 -1
- data/spec/integration/exchange_declaration_spec.rb +71 -102
- data/spec/integration/queue_redeclaration_with_incompatible_attributes_spec.rb +25 -12
- data/spec/integration/remove_individual_binding_spec.rb +51 -0
- metadata +92 -102
data/docs/GettingStarted.textile
CHANGED
data/docs/Queues.textile
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
h1. Ruby amqp gem and RabbitMQ versions compatibility
|
4
4
|
|
5
|
+
h2. This Documentation Has Moved to rubyamqp.info
|
6
|
+
|
7
|
+
amqp gem documentation guides are now hosted on "rubyamqp.info":http://rubyamqp.info.
|
8
|
+
|
5
9
|
h2. About this guide
|
6
10
|
|
7
11
|
This guide covers compatibility of the "Ruby amqp gem":http://github.com/ruby-amqp/amqp with various versions of "RabbitMQ":http://rabbitmq.com messaging broker.
|
data/docs/RunningTests.textile
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
h1. Testing AMQP applications
|
4
4
|
|
5
|
+
h2. This Documentation Has Moved to rubyamqp.info
|
6
|
+
|
7
|
+
amqp gem documentation guides are now hosted on "rubyamqp.info":http://rubyamqp.info.
|
8
|
+
|
5
9
|
h2. About this guide
|
6
10
|
|
7
11
|
This guide covers unit testing of amqp-based applications, primarily using "evented-spec":http://github.com/ruby-amqp/evented-spec.
|
data/lib/amqp/channel.rb
CHANGED
@@ -7,7 +7,7 @@ require "amqp/queue"
|
|
7
7
|
module AMQP
|
8
8
|
# h2. What are AMQP channels
|
9
9
|
#
|
10
|
-
# To quote {http://
|
10
|
+
# To quote {http://files.travis-ci.org/docs/amqp/0.9.1/AMQP091Specification.pdf AMQP 0.9.1 specification}:
|
11
11
|
#
|
12
12
|
# AMQP is a multi-channelled protocol. Channels provide a way to multiplex
|
13
13
|
# a heavyweight TCP/IP connection into several light weight connections.
|
@@ -140,7 +140,7 @@ module AMQP
|
|
140
140
|
# AMQP gem supports several RabbitMQ extensions taht extend Channel functionality.
|
141
141
|
# Learn more in {file:docs/VendorSpecificExtensions.textile}
|
142
142
|
#
|
143
|
-
# @see http://
|
143
|
+
# @see http://files.travis-ci.org/docs/amqp/0.9.1/AMQP091Specification.pdf AMQP 0.9.1 specification (Section 2.2.5)
|
144
144
|
class Channel < AMQ::Client::Channel
|
145
145
|
|
146
146
|
#
|
@@ -373,7 +373,7 @@ module AMQP
|
|
373
373
|
# @see Channel#default_exchange
|
374
374
|
# @see Exchange
|
375
375
|
# @see Exchange#initialize
|
376
|
-
# @see http://
|
376
|
+
# @see http://files.travis-ci.org/docs/amqp/0.9.1/AMQP091Specification.pdf AMQP 0.9.1 specification (Section 3.1.3.1)
|
377
377
|
#
|
378
378
|
# @return [Exchange]
|
379
379
|
# @api public
|
@@ -426,7 +426,7 @@ module AMQP
|
|
426
426
|
#
|
427
427
|
#
|
428
428
|
# @see Exchange
|
429
|
-
# @see http://
|
429
|
+
# @see http://files.travis-ci.org/docs/amqp/0.9.1/AMQP091Specification.pdf AMQP 0.9.1 specification (Section 2.1.2.4)
|
430
430
|
#
|
431
431
|
# @return [Exchange]
|
432
432
|
# @api public
|
@@ -481,7 +481,7 @@ module AMQP
|
|
481
481
|
# @see Exchange
|
482
482
|
# @see Exchange#initialize
|
483
483
|
# @see Channel#default_exchange
|
484
|
-
# @see http://
|
484
|
+
# @see http://files.travis-ci.org/docs/amqp/0.9.1/AMQP091Specification.pdf AMQP 0.9.1 specification (Section 3.1.3.2)
|
485
485
|
#
|
486
486
|
# @return [Exchange]
|
487
487
|
# @api public
|
@@ -597,7 +597,7 @@ module AMQP
|
|
597
597
|
# @see Exchange
|
598
598
|
# @see Exchange#initialize
|
599
599
|
# @see http://www.rabbitmq.com/faq.html#Binding-and-Routing RabbitMQ FAQ on routing & wildcards
|
600
|
-
# @see http://
|
600
|
+
# @see http://files.travis-ci.org/docs/amqp/0.9.1/AMQP091Specification.pdf AMQP 0.9.1 specification (Section 3.1.3.3)
|
601
601
|
#
|
602
602
|
# @return [Exchange]
|
603
603
|
# @api public
|
@@ -703,7 +703,7 @@ module AMQP
|
|
703
703
|
# @see Exchange
|
704
704
|
# @see Exchange#initialize
|
705
705
|
# @see Channel#default_exchange
|
706
|
-
# @see http://
|
706
|
+
# @see http://files.travis-ci.org/docs/amqp/0.9.1/AMQP091Specification.pdf AMQP 0.9.1 specification (Section 3.1.3.3)
|
707
707
|
#
|
708
708
|
# @return [Exchange]
|
709
709
|
# @api public
|
@@ -804,7 +804,7 @@ module AMQP
|
|
804
804
|
#
|
805
805
|
# @see Queue
|
806
806
|
# @see Queue#initialize
|
807
|
-
# @see http://
|
807
|
+
# @see http://files.travis-ci.org/docs/amqp/0.9.1/AMQP091Specification.pdf AMQP 0.9.1 specification (Section 2.1.4)
|
808
808
|
#
|
809
809
|
# @return [Queue]
|
810
810
|
# @api public
|
@@ -957,7 +957,7 @@ module AMQP
|
|
957
957
|
#
|
958
958
|
# @param [Boolean] Desired flow state.
|
959
959
|
#
|
960
|
-
# @see http://
|
960
|
+
# @see http://files.travis-ci.org/docs/amqp/0.9.1/AMQP091Reference.pdf AMQP 0.9.1 protocol documentation (Section 1.5.2.3.)
|
961
961
|
# @api public
|
962
962
|
def flow(active = false, &block)
|
963
963
|
super(active, &block)
|
@@ -998,7 +998,7 @@ module AMQP
|
|
998
998
|
# @api public
|
999
999
|
# @see #reject
|
1000
1000
|
# @see #recover
|
1001
|
-
# @see http://
|
1001
|
+
# @see http://files.travis-ci.org/docs/amqp/0.9.1/AMQP091Reference.pdf AMQP 0.9.1 protocol documentation (Section 1.8.3.13.)
|
1002
1002
|
def acknowledge(delivery_tag, multiple = false)
|
1003
1003
|
super(delivery_tag, multiple)
|
1004
1004
|
end # acknowledge(delivery_tag, multiple = false)
|
@@ -1008,7 +1008,7 @@ module AMQP
|
|
1008
1008
|
# @api public
|
1009
1009
|
# @see #acknowledge
|
1010
1010
|
# @see #recover
|
1011
|
-
# @see http://
|
1011
|
+
# @see http://files.travis-ci.org/docs/amqp/0.9.1/AMQP091Reference.pdf AMQP 0.9.1 protocol documentation (Section 1.8.3.14.)
|
1012
1012
|
def reject(delivery_tag, requeue = true)
|
1013
1013
|
super(delivery_tag, requeue)
|
1014
1014
|
end # reject(delivery_tag, requeue = true)
|
@@ -1019,7 +1019,7 @@ module AMQP
|
|
1019
1019
|
# @return [Channel] self
|
1020
1020
|
#
|
1021
1021
|
# @note RabbitMQ as of 2.3.1 does not support basic.recover with requeue = false.
|
1022
|
-
# @see http://
|
1022
|
+
# @see http://files.travis-ci.org/docs/amqp/0.9.1/AMQP091Reference.pdf AMQP 0.9.1 protocol documentation (Section 1.8.3.16.)
|
1023
1023
|
# @see #acknowledge
|
1024
1024
|
# @api public
|
1025
1025
|
def recover(requeue = true, &block)
|
@@ -1120,6 +1120,7 @@ module AMQP
|
|
1120
1120
|
super(method)
|
1121
1121
|
|
1122
1122
|
self.class.error(method.reply_text)
|
1123
|
+
self.class.release_channel_id(@id)
|
1123
1124
|
end
|
1124
1125
|
|
1125
1126
|
# Overrides AMQ::Client::Channel version to also release the channel id
|
data/lib/amqp/client.rb
CHANGED
@@ -22,7 +22,7 @@ module AMQP
|
|
22
22
|
# @see AMQP.connect
|
23
23
|
# @api plugin
|
24
24
|
#
|
25
|
-
# @see http://
|
25
|
+
# @see http://rubyamqp.info/articles/connecting_to_broker/ Connecting to The Broker documentation guide
|
26
26
|
def self.connect(connection_string_or_options = {}, options = {}, &block)
|
27
27
|
opts = case connection_string_or_options
|
28
28
|
when String then
|
@@ -82,7 +82,7 @@ module AMQP
|
|
82
82
|
#
|
83
83
|
# @raise [ArgumentError] When connection URI schema is not amqp or amqps, or the path contains multiple segments
|
84
84
|
#
|
85
|
-
# @see http://
|
85
|
+
# @see http://rubyamqp.info/articles/connecting_to_broker/ Connecting to The Broker documentation guide
|
86
86
|
# @api public
|
87
87
|
def self.parse_connection_uri(connection_string)
|
88
88
|
AMQ::Client::Settings.parse_amqp_url(connection_string)
|
data/lib/amqp/connection.rb
CHANGED
@@ -192,6 +192,7 @@ module AMQP
|
|
192
192
|
# @option connection_options_or_string [String] :username ("guest") Username to use. Also can be specified as :user.
|
193
193
|
# @option connection_options_or_string [String] :password ("guest") Password to use. Also can be specified as :pass.
|
194
194
|
# @option connection_options_or_string [Hash] :ssl TLS (SSL) parameters to use.
|
195
|
+
# @option connection_options_or_string [Fixnum] :heartbeat (0) Connection heartbeat, in seconds. 0 means no heartbeat. Can also be configured server-side starting with RabbitMQ 3.0.
|
195
196
|
# @option connection_options_or_string [#call] :on_tcp_connection_failure A callable object that will be run if connection to server fails
|
196
197
|
# @option connection_options_or_string [#call] :on_possible_authentication_failure A callable object that will be run if authentication fails (see Authentication failure section)
|
197
198
|
#
|
data/lib/amqp/consumer.rb
CHANGED
@@ -139,7 +139,7 @@ module AMQP
|
|
139
139
|
# @return [Consumer] self
|
140
140
|
#
|
141
141
|
# @api public
|
142
|
-
# @see http://
|
142
|
+
# @see http://files.travis-ci.org/docs/amqp/0.9.1/AMQP091Reference.pdf AMQP 0.9.1 protocol documentation (Section 1.8.3.13.)
|
143
143
|
def acknowledge(delivery_tag)
|
144
144
|
super(delivery_tag)
|
145
145
|
end # acknowledge(delivery_tag)
|
@@ -148,7 +148,7 @@ module AMQP
|
|
148
148
|
# @return [Consumer] self
|
149
149
|
#
|
150
150
|
# @api public
|
151
|
-
# @see http://
|
151
|
+
# @see http://files.travis-ci.org/docs/amqp/0.9.1/AMQP091Reference.pdf AMQP 0.9.1 protocol documentation (Section 1.8.3.14.)
|
152
152
|
def reject(delivery_tag, requeue = true)
|
153
153
|
super(delivery_tag, requeue)
|
154
154
|
end # reject(delivery_tag, requeue = true)
|
data/lib/amqp/exchange.rb
CHANGED
@@ -134,9 +134,9 @@ module AMQP
|
|
134
134
|
# @see Channel#topic
|
135
135
|
# @see Channel#headers
|
136
136
|
# @see Queue
|
137
|
-
# @see http://
|
138
|
-
# @see http://
|
139
|
-
# @see http://
|
137
|
+
# @see http://files.travis-ci.org/docs/amqp/0.9.1/AMQP091Specification.pdf AMQP 0.9.1 specification (Section 2.1.1)
|
138
|
+
# @see http://files.travis-ci.org/docs/amqp/0.9.1/AMQP091Specification.pdf AMQP 0.9.1 specification (Section 2.1.5)
|
139
|
+
# @see http://files.travis-ci.org/docs/amqp/0.9.1/AMQP091Specification.pdf AMQP 0.9.1 specification (Section 3.1.3)
|
140
140
|
class Exchange < AMQ::Client::Exchange
|
141
141
|
|
142
142
|
#
|
@@ -162,7 +162,7 @@ module AMQP
|
|
162
162
|
# AMQP::Exchange.default(channel).publish("make clean", routing_key => "tasks")
|
163
163
|
#
|
164
164
|
# @see Exchange
|
165
|
-
# @see http://
|
165
|
+
# @see http://files.travis-ci.org/docs/amqp/0.9.1/AMQP091Specification.pdf AMQP 0.9.1 specification (Section 2.1.2.4)
|
166
166
|
# @note Do not confuse default exchange with amq.direct: amq.direct is a pre-defined direct
|
167
167
|
# exchange that doesn't have any special routing semantics.
|
168
168
|
# @return [Exchange] An instance that corresponds to the default exchange (of type direct).
|
@@ -292,7 +292,7 @@ module AMQP
|
|
292
292
|
# @see Channel#topic
|
293
293
|
# @see Channel#headers
|
294
294
|
# @see Queue
|
295
|
-
# @see http://
|
295
|
+
# @see http://files.travis-ci.org/docs/amqp/0.9.1/AMQP091Specification.pdf AMQP 0.9.1 specification (Section 3.1.3)
|
296
296
|
#
|
297
297
|
# @return [Exchange]
|
298
298
|
# @api public
|
data/lib/amqp/queue.rb
CHANGED
@@ -116,7 +116,7 @@ module AMQP
|
|
116
116
|
# persistence.
|
117
117
|
#
|
118
118
|
#
|
119
|
-
# @see http://
|
119
|
+
# @see http://files.travis-ci.org/docs/amqp/0.9.1/AMQP091Specification.pdf AMQP 0.9.1 specification (Section 2.1.1)
|
120
120
|
# @see AMQP::Exchange
|
121
121
|
class Queue < AMQ::Client::Queue
|
122
122
|
|
data/lib/amqp/session.rb
CHANGED
@@ -110,7 +110,7 @@ module AMQP
|
|
110
110
|
|
111
111
|
|
112
112
|
# Properly close connection with AMQ broker, as described in
|
113
|
-
# section 2.2.4 of the {http://
|
113
|
+
# section 2.2.4 of the {http://files.travis-ci.org/docs/amqp/0.9.1/AMQP091Specification.pdf AMQP 0.9.1 specification}.
|
114
114
|
#
|
115
115
|
# @api plugin
|
116
116
|
# @see #close_connection
|
@@ -129,19 +129,19 @@ module AMQP
|
|
129
129
|
# Server properties (product information, platform, et cetera)
|
130
130
|
#
|
131
131
|
# @return [Hash]
|
132
|
-
# @see http://
|
132
|
+
# @see http://files.travis-ci.org/docs/amqp/0.9.1/AMQP091Reference.pdf AMQP 0.9.1 protocol documentation (Section 1.4.2.1.3)
|
133
133
|
attr_reader :server_properties
|
134
134
|
|
135
135
|
# Server capabilities (usually used to detect AMQP 0.9.1 extensions like basic.nack, publisher
|
136
136
|
# confirms and so on)
|
137
137
|
#
|
138
138
|
# @return [Hash]
|
139
|
-
# @see http://
|
139
|
+
# @see http://files.travis-ci.org/docs/amqp/0.9.1/AMQP091Reference.pdf AMQP 0.9.1 protocol documentation (Section 1.4.2.1.3)
|
140
140
|
attr_reader :server_capabilities
|
141
141
|
|
142
142
|
# Locales server supports
|
143
143
|
#
|
144
|
-
# @see http://
|
144
|
+
# @see http://files.travis-ci.org/docs/amqp/0.9.1/AMQP091Reference.pdf AMQP 0.9.1 protocol documentation (Section 1.4.2.1.3)
|
145
145
|
attr_reader :server_locales
|
146
146
|
|
147
147
|
# @return [AMQP::Broker] Broker this connection is established with
|
data/lib/amqp/version.rb
CHANGED
@@ -127,27 +127,14 @@ describe AMQP::Channel do
|
|
127
127
|
end # context
|
128
128
|
|
129
129
|
|
130
|
-
context "when exchange name was specified as a blank string" do
|
131
|
-
it 'returns direct exchange with server-generated name' do
|
132
|
-
pending <<-EOF
|
133
|
-
This has to be fixed in RabbitMQ first
|
134
|
-
https://bugzilla.rabbitmq.com/show_bug.cgi?id=23509
|
135
|
-
EOF
|
136
|
-
@channel.direct("") do |exchange|
|
137
|
-
exchange.name.should_not be_empty
|
138
|
-
done
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end # context
|
142
|
-
|
143
|
-
|
144
130
|
context "when passive option is used" do
|
145
131
|
context "and exchange with given name already exists" do
|
146
132
|
it "silently returns" do
|
147
|
-
name
|
133
|
+
name = "a_new_direct_exchange declared at #{Time.now.to_i}"
|
134
|
+
channel = AMQP::Channel.new
|
148
135
|
|
149
|
-
original_exchange =
|
150
|
-
exchange =
|
136
|
+
original_exchange = channel.direct(name)
|
137
|
+
exchange = channel.direct(name, :passive => true)
|
151
138
|
|
152
139
|
exchange.should == original_exchange
|
153
140
|
|
@@ -157,13 +144,16 @@ describe AMQP::Channel do
|
|
157
144
|
|
158
145
|
context "and exchange with given name DOES NOT exist" do
|
159
146
|
it "raises an exception" do
|
160
|
-
|
147
|
+
channel = AMQP::Channel.new
|
148
|
+
channel.on_error do |ch, channel_close|
|
149
|
+
@error_code = channel_close.reply_code
|
150
|
+
end
|
161
151
|
|
162
|
-
|
163
|
-
exchange = @channel.direct("direct exchange declared at #{Time.now.to_i}", :passive => true)
|
164
|
-
}.to raise_error
|
152
|
+
exchange = channel.direct("direct exchange declared at #{Time.now.to_i}", :passive => true)
|
165
153
|
|
166
|
-
done
|
154
|
+
done(0.5) {
|
155
|
+
@error_code.should == 404
|
156
|
+
}
|
167
157
|
end # it
|
168
158
|
end # context
|
169
159
|
end # context
|
@@ -223,27 +213,16 @@ describe AMQP::Channel do
|
|
223
213
|
|
224
214
|
context "when exchange is re-declared with parameters different from original declaration" do
|
225
215
|
it "raises an exception" do
|
226
|
-
|
216
|
+
channel = AMQP::Channel.new
|
217
|
+
channel.direct("previously.declared.durable.direct.exchange", :durable => true)
|
227
218
|
|
228
219
|
expect {
|
229
|
-
|
220
|
+
channel.direct("previously.declared.durable.direct.exchange", :durable => false)
|
230
221
|
}.to raise_error(AMQP::IncompatibleOptionsError)
|
231
222
|
|
232
223
|
done
|
233
224
|
end # it
|
234
225
|
end # context
|
235
|
-
|
236
|
-
context "when exchange is re-declared with irrelevent parameters different from original declaration" do
|
237
|
-
it "doesn't raise an exception" do
|
238
|
-
@channel.direct("previously.declared.durable.direct.exchange", :durable => true)
|
239
|
-
|
240
|
-
expect {
|
241
|
-
@channel.direct("previously.declared.durable.direct.exchange", :durable => true, :header => {:random => 'stuff' })
|
242
|
-
}.to_not raise_error(AMQP::IncompatibleOptionsError)
|
243
|
-
|
244
|
-
done
|
245
|
-
end # it
|
246
|
-
end # context
|
247
226
|
end # describe
|
248
227
|
|
249
228
|
|
@@ -287,12 +266,17 @@ describe AMQP::Channel do
|
|
287
266
|
end
|
288
267
|
|
289
268
|
context "and exchange with given name DOES NOT exist" do
|
290
|
-
it "
|
291
|
-
|
269
|
+
it "results in a channel exception" do
|
270
|
+
channel = AMQP::Channel.new
|
271
|
+
channel.on_error do |ch, channel_close|
|
272
|
+
@error_code = channel_close.reply_code
|
273
|
+
end
|
292
274
|
|
293
|
-
|
294
|
-
|
295
|
-
|
275
|
+
exchange = channel.fanout("fanout exchange declared at #{Time.now.to_i}", :passive => true)
|
276
|
+
|
277
|
+
done(0.5) {
|
278
|
+
@error_code.should == 404
|
279
|
+
}
|
296
280
|
|
297
281
|
done
|
298
282
|
end # it
|
@@ -354,10 +338,11 @@ describe AMQP::Channel do
|
|
354
338
|
|
355
339
|
context "when exchange is re-declared with parameters different from original declaration" do
|
356
340
|
it "raises an exception" do
|
357
|
-
|
341
|
+
channel = AMQP::Channel.new
|
342
|
+
channel.fanout("previously.declared.durable.topic.exchange", :durable => true)
|
358
343
|
|
359
344
|
expect {
|
360
|
-
|
345
|
+
channel.fanout("previously.declared.durable.topic.exchange", :durable => false)
|
361
346
|
}.to raise_error(AMQP::IncompatibleOptionsError)
|
362
347
|
|
363
348
|
done
|
@@ -377,7 +362,7 @@ describe AMQP::Channel do
|
|
377
362
|
exchange.name.should == name
|
378
363
|
|
379
364
|
done
|
380
|
-
end
|
365
|
+
end # it
|
381
366
|
end # context
|
382
367
|
|
383
368
|
context "when exchange name is omitted" do
|
@@ -387,7 +372,7 @@ describe AMQP::Channel do
|
|
387
372
|
exchange.name.should_not == "amq.topic2"
|
388
373
|
|
389
374
|
done
|
390
|
-
end
|
375
|
+
end # it
|
391
376
|
end # context
|
392
377
|
|
393
378
|
context "when passive option is used" do
|
@@ -402,20 +387,23 @@ describe AMQP::Channel do
|
|
402
387
|
|
403
388
|
done
|
404
389
|
end # it
|
405
|
-
end
|
390
|
+
end # context
|
406
391
|
|
407
392
|
context "and exchange with given name DOES NOT exist" do
|
408
|
-
it "
|
409
|
-
|
393
|
+
it "results in a channel exception" do
|
394
|
+
channel = AMQP::Channel.new
|
395
|
+
channel.on_error do |ch, channel_close|
|
396
|
+
@error_code = channel_close.reply_code
|
397
|
+
end
|
410
398
|
|
411
|
-
|
412
|
-
exchange = @channel.topic("topic exchange declared at #{Time.now.to_i}", :passive => true)
|
413
|
-
}.to raise_error
|
399
|
+
exchange = channel.topic("topic exchange declared at #{Time.now.to_i}", :passive => true)
|
414
400
|
|
415
|
-
done
|
401
|
+
done(0.5) {
|
402
|
+
@error_code.should == 404
|
403
|
+
}
|
416
404
|
end # it
|
417
405
|
end # context
|
418
|
-
end
|
406
|
+
end
|
419
407
|
|
420
408
|
|
421
409
|
context "when exchange is declared as durable" do
|
@@ -470,16 +458,14 @@ describe AMQP::Channel do
|
|
470
458
|
end # context
|
471
459
|
|
472
460
|
|
473
|
-
context "when exchange is re-declared with parameters different from original declaration" do
|
461
|
+
context "when exchange is re-declared with parameters different from the original declaration" do
|
474
462
|
amqp_after do
|
475
463
|
done
|
476
464
|
end
|
477
465
|
|
478
466
|
it "raises an exception" do
|
479
467
|
channel = AMQP::Channel.new
|
480
|
-
|
481
468
|
channel.topic("previously.declared.durable.topic.exchange", :durable => true)
|
482
|
-
channel.should be_open
|
483
469
|
|
484
470
|
expect {
|
485
471
|
channel.topic("previously.declared.durable.topic.exchange", :durable => false)
|
@@ -498,7 +484,8 @@ describe AMQP::Channel do
|
|
498
484
|
let(:name) { "new.headers.exchange" }
|
499
485
|
|
500
486
|
it "declares a new headers exchange with that name" do
|
501
|
-
|
487
|
+
channel = AMQP::Channel.new
|
488
|
+
exchange = channel.headers(name)
|
502
489
|
|
503
490
|
exchange.name.should == name
|
504
491
|
|
@@ -512,7 +499,8 @@ describe AMQP::Channel do
|
|
512
499
|
end
|
513
500
|
|
514
501
|
it "uses amq.match" do
|
515
|
-
|
502
|
+
channel = AMQP::Channel.new
|
503
|
+
exchange = channel.headers
|
516
504
|
exchange.name.should == "amq.match"
|
517
505
|
exchange.name.should_not == "amq.headers"
|
518
506
|
|
@@ -523,10 +511,11 @@ describe AMQP::Channel do
|
|
523
511
|
context "when passive option is used" do
|
524
512
|
context "and exchange with given name already exists" do
|
525
513
|
it "silently returns" do
|
526
|
-
name
|
514
|
+
name = "a_new_headers_exchange declared at #{Time.now.to_i}"
|
515
|
+
channel = AMQP::Channel.new
|
527
516
|
|
528
|
-
original_exchange =
|
529
|
-
exchange =
|
517
|
+
original_exchange = channel.headers(name)
|
518
|
+
exchange = channel.headers(name, :passive => true)
|
530
519
|
|
531
520
|
exchange.should == original_exchange
|
532
521
|
|
@@ -536,13 +525,16 @@ describe AMQP::Channel do
|
|
536
525
|
|
537
526
|
context "and exchange with given name DOES NOT exist" do
|
538
527
|
it "raises an exception" do
|
539
|
-
|
528
|
+
channel = AMQP::Channel.new
|
529
|
+
channel.on_error do |ch, channel_close|
|
530
|
+
@error_code = channel_close.reply_code
|
531
|
+
end
|
540
532
|
|
541
|
-
|
542
|
-
exchange = @channel.headers("headers exchange declared at #{Time.now.to_i}", :passive => true)
|
543
|
-
}.to raise_error
|
533
|
+
exchange = channel.headers("headers exchange declared at #{Time.now.to_i}", :passive => true)
|
544
534
|
|
545
|
-
done
|
535
|
+
done(0.5) {
|
536
|
+
@error_code.should == 404
|
537
|
+
}
|
546
538
|
end # it
|
547
539
|
end # context
|
548
540
|
end # context
|
@@ -550,7 +542,8 @@ describe AMQP::Channel do
|
|
550
542
|
|
551
543
|
context "when exchange is declared as durable" do
|
552
544
|
it "returns a new durable headers exchange" do
|
553
|
-
|
545
|
+
channel = AMQP::Channel.new
|
546
|
+
exchange = channel.headers("a_new_durable_headers_exchange", :durable => true)
|
554
547
|
exchange.should be_durable
|
555
548
|
exchange.should_not be_transient
|
556
549
|
|
@@ -561,7 +554,8 @@ describe AMQP::Channel do
|
|
561
554
|
|
562
555
|
context "when exchange is declared as non-durable" do
|
563
556
|
it "returns a new NON-durable headers exchange" do
|
564
|
-
|
557
|
+
channel = AMQP::Channel.new
|
558
|
+
exchange = channel.headers("a_new_non_durable_headers_exchange", :durable => false)
|
565
559
|
exchange.should_not be_durable
|
566
560
|
exchange.should be_transient
|
567
561
|
|
@@ -572,7 +566,8 @@ describe AMQP::Channel do
|
|
572
566
|
|
573
567
|
context "when exchange is declared as auto-deleted" do
|
574
568
|
it "returns a new auto-deleted headers exchange" do
|
575
|
-
|
569
|
+
channel = AMQP::Channel.new
|
570
|
+
exchange = channel.headers("a new auto-deleted headers exchange", :auto_delete => true)
|
576
571
|
|
577
572
|
exchange.should be_auto_deleted
|
578
573
|
done
|
@@ -582,7 +577,8 @@ describe AMQP::Channel do
|
|
582
577
|
|
583
578
|
context "when exchange is declared as auto-deleted" do
|
584
579
|
it "returns a new auto-deleted headers exchange" do
|
585
|
-
|
580
|
+
channel = AMQP::Channel.new
|
581
|
+
exchange = channel.headers("a new non-auto-deleted headers exchange", :auto_delete => false)
|
586
582
|
|
587
583
|
exchange.should_not be_auto_deleted
|
588
584
|
done
|
@@ -592,7 +588,8 @@ describe AMQP::Channel do
|
|
592
588
|
|
593
589
|
context "when exchange is declared without explicit :nowait parameter" do
|
594
590
|
it "is declared with :nowait by default" do
|
595
|
-
|
591
|
+
channel = AMQP::Channel.new
|
592
|
+
exchange = channel.headers("a new non-auto-deleted headers exchange", :auto_delete => false)
|
596
593
|
|
597
594
|
exchange.should_not be_auto_deleted
|
598
595
|
done
|
@@ -606,43 +603,15 @@ describe AMQP::Channel do
|
|
606
603
|
end
|
607
604
|
|
608
605
|
it "raises an exception" do
|
609
|
-
|
606
|
+
channel = AMQP::Channel.new
|
607
|
+
channel.headers("previously.declared.durable.headers.exchange", :durable => true)
|
610
608
|
|
611
609
|
expect {
|
612
|
-
|
610
|
+
channel.headers("previously.declared.durable.headers.exchange", :durable => false)
|
613
611
|
}.to raise_error(AMQP::IncompatibleOptionsError)
|
614
612
|
|
615
613
|
done
|
616
614
|
end # it
|
617
615
|
end # context
|
618
|
-
|
619
|
-
|
620
|
-
context "when exchange is re-declared with parameters different from original declaration on two separate channels" do
|
621
|
-
it "raises an exception" do
|
622
|
-
channel2 = AMQP::Channel.new
|
623
|
-
@channel.headers("previously.declared.durable.headers.exchange", :durable => true)
|
624
|
-
|
625
|
-
channel2.on_error do |ch, channel_close|
|
626
|
-
puts "reply_text: #{channel_close.reply_text}, reply_code: #{channel_close.reply_code}"
|
627
|
-
done
|
628
|
-
end
|
629
|
-
channel2.headers("previously.declared.durable.headers.exchange", :durable => false)
|
630
|
-
end # it
|
631
|
-
end # context
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
context "when exchange is re-declared with type different from original declaration on two separate channels" do
|
636
|
-
it "raises an exception" do
|
637
|
-
channel2 = AMQP::Channel.new
|
638
|
-
@channel.topic("previously.declared.durable.topic.exchange", :durable => true)
|
639
|
-
|
640
|
-
channel2.on_error do |ch, channel_close|
|
641
|
-
puts "reply_text: #{channel_close.reply_text}, reply_code: #{channel_close.reply_code}"
|
642
|
-
done
|
643
|
-
end
|
644
|
-
channel2.headers("previously.declared.durable.topic.exchange", :durable => true)
|
645
|
-
end # it
|
646
|
-
end # context
|
647
616
|
end # describe
|
648
617
|
end # describe AMQP
|