amqp 0.8.0.rc13 → 0.8.0.rc14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. data/.rspec +2 -1
  2. data/.travis.yml +8 -2
  3. data/.yardopts +1 -0
  4. data/CHANGELOG +9 -0
  5. data/Gemfile +17 -11
  6. data/README.md +26 -16
  7. data/amqp.gemspec +2 -2
  8. data/bin/ci/before_build.sh +21 -0
  9. data/docs/08Migration.textile +199 -5
  10. data/docs/AMQP091ModelExplained.textile +322 -0
  11. data/docs/Bindings.textile +24 -4
  12. data/docs/Clustering.textile +1 -1
  13. data/docs/ConnectingToTheBroker.textile +98 -82
  14. data/docs/ConnectionEncryptionWithTLS.textile +65 -5
  15. data/docs/DocumentationGuidesIndex.textile +93 -13
  16. data/docs/Durability.textile +1 -1
  17. data/docs/ErrorHandling.textile +458 -94
  18. data/docs/Exchanges.textile +901 -87
  19. data/docs/GettingStarted.textile +278 -143
  20. data/docs/PatternsAndUseCases.textile +420 -0
  21. data/docs/Queues.textile +730 -178
  22. data/docs/RabbitMQVersions.textile +18 -3
  23. data/docs/RunningTests.textile +1 -1
  24. data/docs/TestingWithEventedSpec.textile +121 -0
  25. data/docs/Troubleshooting.textile +15 -1
  26. data/docs/VendorSpecificExtensions.textile +1 -1
  27. data/docs/diagrams/001_hello_world_example_routing.png +0 -0
  28. data/docs/diagrams/002_blabbr_example_routing.png +0 -0
  29. data/docs/diagrams/003_weathr_example_routing.png +0 -0
  30. data/docs/diagrams/004_fanout_exchange.png +0 -0
  31. data/docs/diagrams/005_direct_exchange.png +0 -0
  32. data/docs/diagrams/redhat/direct_exchange.png +0 -0
  33. data/docs/diagrams/redhat/fanout_exchange.png +0 -0
  34. data/docs/diagrams/redhat/topic_exchange.png +0 -0
  35. data/examples/error_handling/automatic_recovery_of_channel_and_queues.rb +50 -0
  36. data/examples/error_handling/automatically_recovering_hello_world_consumer.rb +51 -0
  37. data/examples/error_handling/automatically_recovering_hello_world_consumer_that_uses_a_server_named_queue.rb +51 -0
  38. data/examples/error_handling/basic_connection_failover.rb +22 -0
  39. data/examples/error_handling/channel_level_exception.rb +9 -2
  40. data/examples/error_handling/connection_level_exception.rb +8 -1
  41. data/examples/error_handling/connection_level_exception_with_objects.rb +49 -0
  42. data/examples/error_handling/connection_loss_handler.rb +1 -5
  43. data/examples/error_handling/hello_world_producer.rb +43 -0
  44. data/examples/error_handling/insufficient_permissions.rb +54 -0
  45. data/examples/error_handling/manual_connection_and_channel_recovery.rb +71 -0
  46. data/examples/error_handling/queue_exclusivity_violation.rb +41 -0
  47. data/examples/error_handling/queue_name_violation.rb +31 -0
  48. data/examples/exchanges/autodeletion_of_exchanges.rb +1 -4
  49. data/examples/guides/queues/01a_declaring_a_server_named_queue_using_queue_constructor.rb +7 -8
  50. data/examples/guides/queues/01b_declaring_a_queue_using_queue_constructor.rb +7 -8
  51. data/examples/guides/queues/02a_declaring_a_durable_shared_queue.rb +5 -8
  52. data/examples/guides/queues/02b_declaring_a_durable_shared_queue.rb +5 -8
  53. data/examples/guides/queues/03a_declaring_a_temporary_exclusive_queue.rb +7 -8
  54. data/examples/guides/queues/04_bind_a_queue_using_exchange_instance.rb +9 -10
  55. data/examples/guides/queues/05_bind_a_queue_using_exchange_name.rb +8 -10
  56. data/examples/guides/queues/06_subscribe_to_receive_messages.rb +10 -12
  57. data/examples/guides/queues/07_fetch_a_message_from_the_queue.rb +14 -14
  58. data/examples/guides/queues/08_unsubscribing_a_consumer.rb +13 -16
  59. data/examples/guides/queues/09_unbinding_from_exchange.rb +16 -22
  60. data/examples/guides/queues/10_purge_a_queue.rb +13 -18
  61. data/examples/guides/queues/11_deleting_a_queue.rb +14 -19
  62. data/examples/guides/queues/12_objects_that_consume_messages.rb +69 -0
  63. data/examples/guides/queues/13_objects_that_consume_messages_take_two.rb +89 -0
  64. data/examples/hello_world.rb +1 -3
  65. data/examples/hello_world_with_an_empty_string.rb +5 -6
  66. data/examples/inspecting_server_information.rb +45 -0
  67. data/examples/issues/issue_93.rb +23 -0
  68. data/examples/issues/issue_94.rb +23 -0
  69. data/examples/patterns/command/consumer.rb +45 -0
  70. data/examples/patterns/command/producer.rb +26 -0
  71. data/examples/patterns/request_reply/client.rb +29 -0
  72. data/examples/patterns/request_reply/server.rb +26 -0
  73. data/examples/publishing/publishing_a_one_off_message.rb +6 -4
  74. data/examples/publishing/returned_messages.rb +2 -10
  75. data/examples/queues/accessing_message_metadata.rb +15 -13
  76. data/examples/queues/queue_status.rb +12 -15
  77. data/examples/routing/fanout_routing.rb +33 -0
  78. data/examples/routing/headers_routing.rb +17 -15
  79. data/examples/routing/round_robin_with_direct_exchange.rb +39 -0
  80. data/examples/routing/round_robin_with_the_default_exchange.rb +38 -0
  81. data/examples/routing/unroutable_mandatory_message_is_returned.rb +33 -0
  82. data/examples/routing/weather_updates.rb +15 -20
  83. data/examples/tls/using_tls.rb +41 -0
  84. data/lib/amqp/bit_set.rb +80 -0
  85. data/lib/amqp/broker.rb +72 -0
  86. data/lib/amqp/channel.rb +93 -13
  87. data/lib/amqp/client.rb +11 -22
  88. data/lib/amqp/compatibility/ruby187_patchlevel_check.rb +2 -0
  89. data/lib/amqp/connection.rb +2 -3
  90. data/lib/amqp/consumer.rb +208 -0
  91. data/lib/amqp/deprecated/fork.rb +2 -0
  92. data/lib/amqp/deprecated/mq.rb +2 -0
  93. data/lib/amqp/exchange.rb +6 -4
  94. data/lib/amqp/extensions/rabbitmq.rb +3 -1
  95. data/lib/amqp/header.rb +76 -14
  96. data/lib/amqp/int_allocator.rb +96 -0
  97. data/lib/amqp/logger.rb +2 -0
  98. data/lib/amqp/queue.rb +242 -86
  99. data/lib/amqp/rpc.rb +2 -0
  100. data/lib/amqp/session.rb +169 -9
  101. data/lib/amqp/utilities/event_loop_helper.rb +2 -0
  102. data/lib/amqp/utilities/server_type.rb +2 -0
  103. data/lib/amqp/version.rb +2 -2
  104. data/lib/mq.rb +4 -2
  105. data/lib/mq/logger.rb +3 -1
  106. data/lib/mq/rpc.rb +3 -1
  107. data/spec/integration/authentication_spec.rb +17 -10
  108. data/spec/integration/automatic_binding_for_default_direct_exchange_spec.rb +1 -1
  109. data/spec/integration/automatic_recovery_predicate_spec.rb +68 -0
  110. data/spec/integration/basic_get_spec.rb +2 -1
  111. data/spec/integration/{extensions/basic_return_spec.rb → basic_return_spec.rb} +2 -1
  112. data/spec/integration/channel_level_exception_handling_spec.rb +53 -0
  113. data/spec/integration/connection_level_exception_handling_spec.rb +49 -0
  114. data/spec/integration/declare_and_immediately_bind_a_server_named_queue_spec.rb +38 -17
  115. data/spec/integration/declare_one_hundred_server_named_queues_spec.rb +44 -0
  116. data/spec/integration/direct_exchange_routing_spec.rb +125 -0
  117. data/spec/integration/exchange_declaration_spec.rb +75 -46
  118. data/spec/integration/extensions/rabbitmq/publisher_confirmations_spec.rb +180 -0
  119. data/spec/integration/{workload_distribution_spec.rb → fanout_exchange_routing_spec.rb} +10 -9
  120. data/spec/integration/headers_exchange_routing_spec.rb +269 -0
  121. data/spec/integration/hello_world_spec.rb +77 -0
  122. data/spec/integration/immediate_messages_spec.rb +59 -0
  123. data/spec/integration/mandatory_messages_spec.rb +52 -0
  124. data/spec/integration/message_metadata_access_spec.rb +106 -0
  125. data/spec/integration/multiple_consumers_per_queue_spec.rb +319 -0
  126. data/spec/integration/ordering_of_published_messages_spec.rb +96 -0
  127. data/spec/integration/queue_declaration_spec.rb +8 -8
  128. data/spec/integration/queue_status_spec.rb +66 -0
  129. data/spec/integration/recovery/per_channel_automatic_recovery_on_graceful_broker_shutdown_spec.rb +76 -0
  130. data/spec/integration/recovery/per_channel_automatic_recovery_spec.rb +72 -0
  131. data/spec/integration/redelivery_of_unacknowledged_messages_spec.rb +96 -0
  132. data/spec/integration/regressions/concurrent_publishing_on_the_same_channel_spec.rb +91 -0
  133. data/spec/integration/regressions/empty_message_body_spec.rb +56 -0
  134. data/spec/integration/regressions/issue66_spec.rb +2 -1
  135. data/spec/integration/reply_queue_communication_spec.rb +2 -1
  136. data/spec/integration/store_and_forward_spec.rb +4 -3
  137. data/spec/integration/topic_subscription_spec.rb +2 -1
  138. data/spec/integration/tx_commit_spec.rb +124 -0
  139. data/spec/integration/tx_rollback_spec.rb +167 -0
  140. data/spec/spec_helper.rb +44 -71
  141. data/spec/unit/amqp/bit_set_spec.rb +127 -0
  142. data/spec/unit/amqp/channel_id_allocation_spec.rb +40 -0
  143. data/spec/unit/amqp/connection_spec.rb +4 -2
  144. data/spec/unit/amqp/int_allocator_spec.rb +116 -0
  145. metadata +92 -26
  146. data/CONTRIBUTORS +0 -29
  147. data/docs/Routing.textile +0 -30
  148. data/examples/real-world/task-queue/README.textile +0 -3
  149. data/examples/real-world/task-queue/consumer.rb +0 -27
  150. data/examples/real-world/task-queue/producer.rb +0 -22
  151. data/spec/unit/amqp/basic_spec.rb +0 -39
  152. data/tasks.rb +0 -4
@@ -1,4 +1,5 @@
1
- # -*- coding: utf-8 -*-
1
+ # encoding: utf-8
2
+
2
3
  require "spec_helper"
3
4
 
4
5
 
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe "Channel-level exception" do
6
+
7
+ #
8
+ # Environment
9
+ #
10
+
11
+ include EventedSpec::AMQPSpec
12
+
13
+ default_timeout 2
14
+
15
+ amqp_before do
16
+ @connection = AMQP.connect
17
+ @channel = AMQP::Channel.new(@connection)
18
+ end
19
+
20
+ after(:all) do
21
+ AMQP.cleanup_state
22
+ done
23
+ end
24
+
25
+
26
+ #
27
+ # Examples
28
+ #
29
+
30
+ it "can be handled with Channel#on_error" do
31
+ @channel.on_error do |ch, channel_close|
32
+ channel_close.method_id.should == 10
33
+ channel_close.class_id.should == 50
34
+ channel_close.reply_code.should == 406
35
+ channel_close.reply_text.should_not be_nil
36
+ channel_close.reply_text.should_not be_empty
37
+
38
+ done
39
+ end
40
+
41
+ EventMachine.add_timer(0.4) do
42
+ # these two definitions result in a race condition. For sake of this example,
43
+ # however, it does not matter. Whatever definition succeeds first, 2nd one will
44
+ # cause a channel-level exception (because attributes are not identical)
45
+ #
46
+ # 'a' * 80 makes queue name long enough for complete error message to be longer than 127 charachters.
47
+ # makes it possible to detect signed vs unsigned integer issues in amq-protocol. MK.
48
+ AMQP::Queue.new(@channel, "amqpgem.examples.channel_exception.#{'a' * 80}", :auto_delete => true, :durable => false)
49
+
50
+ AMQP::Queue.new(@channel, "amqpgem.examples.channel_exception.#{'a' * 80}", :auto_delete => true, :durable => true)
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe "Connection-level exception" do
6
+
7
+ #
8
+ # Environment
9
+ #
10
+
11
+ include EventedSpec::AMQPSpec
12
+
13
+ default_timeout 2
14
+
15
+ amqp_before do
16
+ @connection = AMQP.connect
17
+ @channel = AMQP::Channel.new(@connection)
18
+ end
19
+
20
+ after(:all) do
21
+ AMQP.cleanup_state
22
+ done
23
+ end
24
+
25
+
26
+ #
27
+ # Examples
28
+ #
29
+
30
+ it "can be handled with Session#on_error" do
31
+ @connection.on_error do |conn, connection_close|
32
+ conn.should == @connection
33
+
34
+ connection_close.method_id.should == 31
35
+ connection_close.class_id.should == 10
36
+ connection_close.reply_code.should == 504
37
+ connection_close.reply_text.should_not be_nil
38
+ connection_close.reply_text.should_not be_empty
39
+
40
+ done
41
+ end
42
+
43
+ EventMachine.add_timer(0.3) do
44
+ # send_frame is NOT part of the public API, but it is public for entities like AMQ::Client::Channel
45
+ # and we use it here to trigger a connection-level exception. MK.
46
+ @connection.send_frame(AMQ::Protocol::Connection::TuneOk.encode(1000, 1024 * 128 * 1024, 10))
47
+ end
48
+ end
49
+ end
@@ -10,11 +10,7 @@ describe "Server-named", AMQP::Queue do
10
10
 
11
11
  include EventedSpec::AMQPSpec
12
12
 
13
- default_timeout 5
14
-
15
- amqp_before do
16
- @channel = AMQP::Channel.new
17
- end
13
+ default_timeout 2
18
14
 
19
15
 
20
16
  #
@@ -22,21 +18,46 @@ describe "Server-named", AMQP::Queue do
22
18
  #
23
19
 
24
20
 
25
- it "delays binding until after queue.declare-ok arrives" do
26
- mailbox = []
27
- exchange = @channel.fanout("amq.fanout")
28
- input = "Independencia de resolución, ¿una realidad en Mac OS X Lion?"
21
+ context "bound to a pre-defined exchange" do
22
+ it "delays binding until after queue.declare-ok arrives" do
23
+ mailbox = []
24
+ channel = AMQP::Channel.new
25
+ exchange = channel.fanout("amq.fanout")
26
+ input = "Independencia de resolución, ¿una realidad en Mac OS X Lion?"
27
+
28
+ channel.queue("", :auto_delete => true).bind(exchange).subscribe do |header, body|
29
+ mailbox << body
30
+ end
29
31
 
30
- @channel.queue("", :auto_delete => true).bind(exchange).subscribe do |header, body|
31
- mailbox << body
32
+ delayed(0.5) {
33
+ exchange.publish(input)
34
+ }
35
+
36
+ done(1.0) {
37
+ mailbox.size.should == 1
38
+ }
32
39
  end
40
+ end
33
41
 
34
- delayed(0.3) {
35
- exchange.publish(input)
36
- }
37
42
 
38
- done(0.5) {
39
- mailbox.size.should == 1
40
- }
43
+ context "bound to a pre-defined exchange" do
44
+ it "delays binding until after queue.declare-ok arrives" do
45
+ mailbox = []
46
+ channel = AMQP::Channel.new
47
+ exchange = channel.fanout("amqpgem.examples.exchanges.fanout", :durable => false)
48
+ input = "Just send me already"
49
+
50
+ channel.queue("", :auto_delete => true).bind(exchange).subscribe do |header, body|
51
+ mailbox << body
52
+ end
53
+
54
+ delayed(0.5) {
55
+ exchange.publish(input)
56
+ }
57
+
58
+ done(1.0) {
59
+ mailbox.size.should == 1
60
+ }
61
+ end
41
62
  end
42
63
  end
@@ -0,0 +1,44 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe "Server-named", AMQP::Queue do
6
+
7
+ #
8
+ # Environment
9
+ #
10
+
11
+ include EventedSpec::AMQPSpec
12
+
13
+ default_timeout 5
14
+
15
+ amqp_before do
16
+ @channel = AMQP::Channel.new
17
+ end
18
+
19
+
20
+ #
21
+ # Examples
22
+ #
23
+
24
+
25
+ it "can be declared en masse" do
26
+ n = 100
27
+ queues = []
28
+
29
+ n.times do
30
+ queues << @channel.queue("", :auto_delete => true)
31
+ end
32
+
33
+ done(2.5) {
34
+ queues.size.should == n
35
+ # this is RabbitMQ-specific. But it is OK for now. MK.
36
+ queues.all? { |q| q.name =~ /^amq.*/ }.should be_true
37
+
38
+ # no duplicates. MK.
39
+ names = queues.map { |q| q.name }
40
+ names.uniq.size.should == n
41
+ names.uniq.should == names
42
+ }
43
+ end
44
+ end
@@ -0,0 +1,125 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe "Multiple consumers bound to a queue with the same routing key" do
6
+
7
+ #
8
+ # Environment
9
+ #
10
+
11
+ include EventedSpec::AMQPSpec
12
+ default_options AMQP_OPTS
13
+ default_timeout 5
14
+
15
+ amqp_before do
16
+ @channel = AMQP::Channel.new
17
+ @channel.on_error do |ch, close|
18
+ raise "Channel-level error!: #{close.inspect}"
19
+ end
20
+
21
+ @queue = @channel.queue("", :auto_delete => true)
22
+ @exchange = @channel.direct("amqpgem.tests.integration.direct.exchange", :auto_delete => true)
23
+
24
+ @queue.bind(@exchange, :routing_key => "builds.all")
25
+ end
26
+
27
+
28
+
29
+ it "get messages distributed to them in a round-robin manner" do
30
+ mailbox1 = Array.new
31
+ mailbox2 = Array.new
32
+
33
+ consumer1 = AMQP::Consumer.new(@channel, @queue).consume
34
+ consumer2 = AMQP::Consumer.new(@channel, @queue).consume
35
+
36
+
37
+ consumer1.on_delivery do |metadata, payload|
38
+ mailbox1 << payload
39
+ end
40
+ consumer2.on_delivery do |metadata, payload|
41
+ mailbox2 << payload
42
+ end
43
+
44
+
45
+ EventMachine.add_timer(0.5) do
46
+ 12.times { @exchange.publish(".", :routing_key => "builds.all") }
47
+ 12.times { @exchange.publish(".", :routing_key => "all.builds") }
48
+ end
49
+
50
+ done(2.5) {
51
+ mailbox1.size.should == 6
52
+ mailbox2.size.should == 6
53
+ }
54
+ end
55
+ end
56
+
57
+
58
+
59
+
60
+ describe "Multiple queues bound to a direct exchange with the same routing key" do
61
+
62
+ #
63
+ # Environment
64
+ #
65
+
66
+ include EventedSpec::AMQPSpec
67
+ default_options AMQP_OPTS
68
+ default_timeout 5
69
+
70
+
71
+ amqp_before do
72
+ @channel = AMQP::Channel.new
73
+ @channel.on_error do |ch, close|
74
+ raise "Channel-level error!: #{close.inspect}"
75
+ end
76
+
77
+ @queue1 = @channel.queue("", :auto_delete => true)
78
+ @queue2 = @channel.queue("", :auto_delete => true)
79
+ @exchange = @channel.direct("amqpgem.tests.integration.direct.exchange", :auto_delete => true)
80
+
81
+ @queue1.bind(@exchange, :routing_key => "builds.all")
82
+ @queue2.bind(@exchange, :routing_key => "builds.all")
83
+ end
84
+
85
+
86
+ it "all get a copy of messages with that routing key" do
87
+ mailbox1 = Array.new
88
+ mailbox2 = Array.new
89
+ mailbox3 = Array.new
90
+ mailbox4 = Array.new
91
+
92
+
93
+ consumer1 = AMQP::Consumer.new(@channel, @queue1).consume
94
+ consumer2 = AMQP::Consumer.new(@channel, @queue1).consume
95
+ consumer3 = AMQP::Consumer.new(@channel, @queue2).consume
96
+ consumer4 = AMQP::Consumer.new(@channel, @queue2).consume
97
+
98
+
99
+ consumer1.on_delivery do |metadata, payload|
100
+ mailbox1 << payload
101
+ end
102
+ consumer2.on_delivery do |metadata, payload|
103
+ mailbox2 << payload
104
+ end
105
+ consumer3.on_delivery do |metadata, payload|
106
+ mailbox3 << payload
107
+ end
108
+ consumer4.on_delivery do |metadata, payload|
109
+ mailbox4 << payload
110
+ end
111
+
112
+
113
+ EventMachine.add_timer(0.5) do
114
+ 13.times { @exchange.publish(".", :routing_key => "builds.all") }
115
+ 13.times { @exchange.publish(".", :routing_key => "all.builds") }
116
+ end
117
+
118
+ done(3.5) {
119
+ mailbox1.size.should == 7
120
+ mailbox2.size.should == 6
121
+ mailbox3.size.should == 7
122
+ mailbox4.size.should == 6
123
+ }
124
+ end
125
+ end
@@ -28,7 +28,7 @@ describe AMQP::Channel do
28
28
  it 'declares a new direct exchange with that name' do
29
29
  @channel.direct('name').name.should == 'name'
30
30
 
31
- done(0.3)
31
+ done
32
32
  end
33
33
 
34
34
  it "declares direct exchange as transient (non-durable)" do
@@ -37,7 +37,7 @@ describe AMQP::Channel do
37
37
  exchange.should_not be_durable
38
38
  exchange.should be_transient
39
39
 
40
- done(0.3)
40
+ done
41
41
  end
42
42
 
43
43
  it "declares direct exchange as non-auto-deleted" do
@@ -45,7 +45,7 @@ describe AMQP::Channel do
45
45
 
46
46
  exchange.should_not be_auto_deleted
47
47
 
48
- done(0.3)
48
+ done
49
49
  end
50
50
  end
51
51
 
@@ -53,7 +53,7 @@ describe AMQP::Channel do
53
53
  context "when exchange name is omitted" do
54
54
  it 'uses amq.direct' do
55
55
  @channel.direct.name.should == 'amq.direct'
56
- done(0.3)
56
+ done
57
57
  end # it
58
58
  end # context
59
59
 
@@ -66,7 +66,7 @@ describe AMQP::Channel do
66
66
  EOF
67
67
  @channel.direct("") do |exchange|
68
68
  exchange.name.should_not be_empty
69
- done(0.3)
69
+ done
70
70
  end
71
71
  end
72
72
  end # context
@@ -82,7 +82,7 @@ describe AMQP::Channel do
82
82
 
83
83
  exchange.should == original_exchange
84
84
 
85
- done(0.3)
85
+ done
86
86
  end # it
87
87
  end
88
88
 
@@ -94,7 +94,7 @@ describe AMQP::Channel do
94
94
  exchange = @channel.direct("direct exchange declared at #{Time.now.to_i}", :passive => true)
95
95
  }.to raise_error
96
96
 
97
- done(0.3)
97
+ done
98
98
  end # it
99
99
  end # context
100
100
  end # context
@@ -106,7 +106,7 @@ describe AMQP::Channel do
106
106
  exchange.should be_durable
107
107
  exchange.should_not be_transient
108
108
 
109
- done(0.3)
109
+ done
110
110
  end # it
111
111
  end # context
112
112
 
@@ -117,7 +117,7 @@ describe AMQP::Channel do
117
117
  exchange.should_not be_durable
118
118
  exchange.should be_transient
119
119
 
120
- done(0.3)
120
+ done
121
121
  end # it
122
122
  end # context
123
123
 
@@ -127,7 +127,7 @@ describe AMQP::Channel do
127
127
  exchange = @channel.direct("a new auto-deleted direct exchange", :auto_delete => true)
128
128
 
129
129
  exchange.should be_auto_deleted
130
- done(0.3)
130
+ done
131
131
  end # it
132
132
  end # context
133
133
 
@@ -137,7 +137,7 @@ describe AMQP::Channel do
137
137
  exchange = @channel.direct("a new non-auto-deleted direct exchange", :auto_delete => false)
138
138
 
139
139
  exchange.should_not be_auto_deleted
140
- done(0.3)
140
+ done
141
141
  end # it
142
142
  end # context
143
143
 
@@ -147,7 +147,7 @@ describe AMQP::Channel do
147
147
  exchange = @channel.direct("a new non-auto-deleted direct exchange", :auto_delete => false)
148
148
 
149
149
  exchange.should_not be_auto_deleted
150
- done(0.3)
150
+ done
151
151
  end # it
152
152
  end # context
153
153
 
@@ -160,7 +160,7 @@ describe AMQP::Channel do
160
160
  @channel.direct("previously.declared.durable.direct.exchange", :durable => false)
161
161
  }.to raise_error(AMQP::IncompatibleOptionsError)
162
162
 
163
- done(0.3)
163
+ done
164
164
  end # it
165
165
  end # context
166
166
  end # describe
@@ -177,7 +177,7 @@ describe AMQP::Channel do
177
177
 
178
178
  exchange.name.should == name
179
179
 
180
- done(0.3)
180
+ done
181
181
  end
182
182
  end # context
183
183
 
@@ -187,7 +187,7 @@ describe AMQP::Channel do
187
187
  exchange.name.should == "amq.fanout"
188
188
  exchange.name.should_not == "amq.fanout2"
189
189
 
190
- done(0.3)
190
+ done
191
191
  end
192
192
  end # context
193
193
 
@@ -201,7 +201,7 @@ describe AMQP::Channel do
201
201
 
202
202
  exchange.should == original_exchange
203
203
 
204
- done(0.3)
204
+ done
205
205
  end # it
206
206
  end
207
207
 
@@ -213,7 +213,7 @@ describe AMQP::Channel do
213
213
  exchange = @channel.fanout("fanout exchange declared at #{Time.now.to_i}", :passive => true)
214
214
  }.to raise_error
215
215
 
216
- done(0.3)
216
+ done
217
217
  end # it
218
218
  end # context
219
219
  end # context
@@ -225,7 +225,7 @@ describe AMQP::Channel do
225
225
  exchange.should be_durable
226
226
  exchange.should_not be_transient
227
227
 
228
- done(0.3)
228
+ done
229
229
  end # it
230
230
  end # context
231
231
 
@@ -236,7 +236,7 @@ describe AMQP::Channel do
236
236
  exchange.should_not be_durable
237
237
  exchange.should be_transient
238
238
 
239
- done(0.3)
239
+ done
240
240
  end # it
241
241
  end # context
242
242
 
@@ -246,7 +246,7 @@ describe AMQP::Channel do
246
246
  exchange = @channel.fanout("a new auto-deleted fanout exchange", :auto_delete => true)
247
247
 
248
248
  exchange.should be_auto_deleted
249
- done(0.3)
249
+ done
250
250
  end # it
251
251
  end # context
252
252
 
@@ -256,7 +256,7 @@ describe AMQP::Channel do
256
256
  exchange = @channel.fanout("a new non-auto-deleted fanout exchange", :auto_delete => false)
257
257
 
258
258
  exchange.should_not be_auto_deleted
259
- done(0.3)
259
+ done
260
260
  end # it
261
261
  end # context
262
262
 
@@ -266,7 +266,7 @@ describe AMQP::Channel do
266
266
  exchange = @channel.fanout("a new non-auto-deleted fanout exchange", :auto_delete => false)
267
267
 
268
268
  exchange.should_not be_auto_deleted
269
- done(0.3)
269
+ done
270
270
  end # it
271
271
  end # context
272
272
 
@@ -279,7 +279,7 @@ describe AMQP::Channel do
279
279
  @channel.fanout("previously.declared.durable.topic.exchange", :durable => false)
280
280
  }.to raise_error(AMQP::IncompatibleOptionsError)
281
281
 
282
- done(0.3)
282
+ done
283
283
  end # it
284
284
  end # context
285
285
  end # describe
@@ -295,7 +295,7 @@ describe AMQP::Channel do
295
295
  exchange = @channel.topic(name)
296
296
  exchange.name.should == name
297
297
 
298
- done(0.3)
298
+ done
299
299
  end
300
300
  end # context
301
301
 
@@ -305,7 +305,7 @@ describe AMQP::Channel do
305
305
  exchange.name.should == "amq.topic"
306
306
  exchange.name.should_not == "amq.topic2"
307
307
 
308
- done(0.3)
308
+ done
309
309
  end
310
310
  end # context
311
311
 
@@ -319,7 +319,7 @@ describe AMQP::Channel do
319
319
 
320
320
  exchange.should == original_exchange
321
321
 
322
- done(0.3)
322
+ done
323
323
  end # it
324
324
  end
325
325
 
@@ -331,7 +331,7 @@ describe AMQP::Channel do
331
331
  exchange = @channel.topic("topic exchange declared at #{Time.now.to_i}", :passive => true)
332
332
  }.to raise_error
333
333
 
334
- done(0.3)
334
+ done
335
335
  end # it
336
336
  end # context
337
337
  end # context
@@ -343,7 +343,7 @@ describe AMQP::Channel do
343
343
  exchange.should be_durable
344
344
  exchange.should_not be_transient
345
345
 
346
- done(0.3)
346
+ done
347
347
  end # it
348
348
  end # context
349
349
 
@@ -354,7 +354,7 @@ describe AMQP::Channel do
354
354
  exchange.should_not be_durable
355
355
  exchange.should be_transient
356
356
 
357
- done(0.3)
357
+ done
358
358
  end # it
359
359
  end # context
360
360
 
@@ -364,7 +364,7 @@ describe AMQP::Channel do
364
364
  exchange = @channel.topic("a new auto-deleted topic exchange", :auto_delete => true)
365
365
 
366
366
  exchange.should be_auto_deleted
367
- done(0.3)
367
+ done
368
368
  end # it
369
369
  end # context
370
370
 
@@ -374,7 +374,7 @@ describe AMQP::Channel do
374
374
  exchange = @channel.topic("a new non-auto-deleted topic exchange", :auto_delete => false)
375
375
 
376
376
  exchange.should_not be_auto_deleted
377
- done(0.3)
377
+ done
378
378
  end # it
379
379
  end # context
380
380
 
@@ -384,7 +384,7 @@ describe AMQP::Channel do
384
384
  exchange = @channel.topic("a new non-auto-deleted topic exchange", :auto_delete => false)
385
385
 
386
386
  exchange.should_not be_auto_deleted
387
- done(0.3)
387
+ done
388
388
  end # it
389
389
  end # context
390
390
 
@@ -404,7 +404,7 @@ describe AMQP::Channel do
404
404
  channel.topic("previously.declared.durable.topic.exchange", :durable => false)
405
405
  }.to raise_error(AMQP::IncompatibleOptionsError)
406
406
 
407
- done(0.3)
407
+ done
408
408
  end # it
409
409
  end # context
410
410
  end # describe
@@ -421,7 +421,7 @@ describe AMQP::Channel do
421
421
 
422
422
  exchange.name.should == name
423
423
 
424
- done(0.3)
424
+ done
425
425
  end
426
426
  end # context
427
427
 
@@ -435,7 +435,7 @@ describe AMQP::Channel do
435
435
  exchange.name.should == "amq.match"
436
436
  exchange.name.should_not == "amq.headers"
437
437
 
438
- done(0.3)
438
+ done
439
439
  end
440
440
  end # context
441
441
 
@@ -449,7 +449,7 @@ describe AMQP::Channel do
449
449
 
450
450
  exchange.should == original_exchange
451
451
 
452
- done(0.3)
452
+ done
453
453
  end # it
454
454
  end
455
455
 
@@ -461,7 +461,7 @@ describe AMQP::Channel do
461
461
  exchange = @channel.headers("headers exchange declared at #{Time.now.to_i}", :passive => true)
462
462
  }.to raise_error
463
463
 
464
- done(0.3)
464
+ done
465
465
  end # it
466
466
  end # context
467
467
  end # context
@@ -473,7 +473,7 @@ describe AMQP::Channel do
473
473
  exchange.should be_durable
474
474
  exchange.should_not be_transient
475
475
 
476
- done(0.3)
476
+ done
477
477
  end # it
478
478
  end # context
479
479
 
@@ -484,7 +484,7 @@ describe AMQP::Channel do
484
484
  exchange.should_not be_durable
485
485
  exchange.should be_transient
486
486
 
487
- done(0.3)
487
+ done
488
488
  end # it
489
489
  end # context
490
490
 
@@ -494,7 +494,7 @@ describe AMQP::Channel do
494
494
  exchange = @channel.headers("a new auto-deleted headers exchange", :auto_delete => true)
495
495
 
496
496
  exchange.should be_auto_deleted
497
- done(0.3)
497
+ done
498
498
  end # it
499
499
  end # context
500
500
 
@@ -504,7 +504,7 @@ describe AMQP::Channel do
504
504
  exchange = @channel.headers("a new non-auto-deleted headers exchange", :auto_delete => false)
505
505
 
506
506
  exchange.should_not be_auto_deleted
507
- done(0.3)
507
+ done
508
508
  end # it
509
509
  end # context
510
510
 
@@ -514,24 +514,53 @@ describe AMQP::Channel do
514
514
  exchange = @channel.headers("a new non-auto-deleted headers exchange", :auto_delete => false)
515
515
 
516
516
  exchange.should_not be_auto_deleted
517
- done(0.3)
517
+ done
518
518
  end # it
519
519
  end # context
520
520
 
521
521
 
522
- context "when exchange is re-declared with parameters different from original declaration" do
522
+ context "when exchange is re-declared with parameters different from original declaration on the same channel" do
523
523
  amqp_after do
524
524
  done
525
525
  end
526
526
 
527
527
  it "raises an exception" do
528
- @channel.headers("previously.declared.durable.topic.exchange", :durable => true)
528
+ @channel.headers("previously.declared.durable.headers.exchange", :durable => true)
529
529
 
530
530
  expect {
531
- @channel.headers("previously.declared.durable.topic.exchange", :durable => false)
531
+ @channel.headers("previously.declared.durable.headers.exchange", :durable => false)
532
532
  }.to raise_error(AMQP::IncompatibleOptionsError)
533
533
 
534
- done(0.3)
534
+ done
535
+ end # it
536
+ end # context
537
+
538
+
539
+ context "when exchange is re-declared with parameters different from original declaration on two separate channels" do
540
+ it "raises an exception" do
541
+ channel2 = AMQP::Channel.new
542
+ @channel.headers("previously.declared.durable.headers.exchange", :durable => true)
543
+
544
+ channel2.on_error do |ch, channel_close|
545
+ puts "reply_text: #{channel_close.reply_text}, reply_code: #{channel_close.reply_code}"
546
+ done
547
+ end
548
+ channel2.headers("previously.declared.durable.headers.exchange", :durable => false)
549
+ end # it
550
+ end # context
551
+
552
+
553
+
554
+ context "when exchange is re-declared with type different from original declaration on two separate channels" do
555
+ it "raises an exception" do
556
+ channel2 = AMQP::Channel.new
557
+ @channel.topic("previously.declared.durable.topic.exchange", :durable => true)
558
+
559
+ channel2.on_error do |ch, channel_close|
560
+ puts "reply_text: #{channel_close.reply_text}, reply_code: #{channel_close.reply_code}"
561
+ done
562
+ end
563
+ channel2.headers("previously.declared.durable.topic.exchange", :durable => true)
535
564
  end # it
536
565
  end # context
537
566
  end # describe