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
data/lib/amqp/rpc.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  $stdout.puts <<-MESSAGE
2
4
  -------------------------------------------------------------------------------------
3
5
  DEPRECATION WARNING!
data/lib/amqp/session.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require "amq/client/adapters/event_machine"
4
+ require "amqp/broker"
4
5
 
5
6
  module AMQP
6
7
  # AMQP session represents connection to the broker. Session objects let you define callbacks for
@@ -33,16 +34,57 @@ module AMQP
33
34
  # API
34
35
  #
35
36
 
37
+ # @group Connecting, reconnecting, disconnecting
38
+
39
+ def initialize(*args, &block)
40
+ super(*args, &block)
41
+
42
+ @client_properties = {
43
+ :platform => ::RUBY_DESCRIPTION,
44
+ :product => "AMQP gem",
45
+ :information => "http://github.com/ruby-amqp/amqp",
46
+ :version => AMQP::VERSION
47
+ }
48
+ end # initialize(*args, &block)
49
+
50
+ # @return [Boolean] true if this AMQP connection is currently open
36
51
  # @api plugin
37
52
  def connected?
38
53
  self.opened?
39
54
  end
40
55
 
56
+ # @return [String] Broker hostname this connection uses
57
+ # @api public
58
+ def hostname
59
+ @settings[:host]
60
+ end
61
+ alias host hostname
62
+
63
+ # @return [String] Broker port this connection uses
64
+ # @api public
65
+ def port
66
+ @settings[:port]
67
+ end
68
+
69
+ # @return [String] Broker endpoint in the form of HOST:PORT/VHOST
70
+ # @api public
71
+ def broker_endpoint
72
+ "#{self.hostname}:#{self.port}/#{self.vhost}"
73
+ end
74
+
75
+ # @return [String] Username used by this connection
76
+ # @api public
77
+ def username
78
+ @settings[:user]
79
+ end # username
80
+ alias user username
81
+
82
+
41
83
  # Reconnect to the broker using current connection settings.
42
84
  #
43
85
  # @param [Boolean] force Enforce immediate connection
44
86
  # @param [Fixnum] period If given, reconnection will be delayed by this period, in seconds.
45
- # @api plugin
87
+ # @api public
46
88
  def reconnect(force = false, period = 2)
47
89
  # we do this to make sure this method shows up in our documentation
48
90
  # this method is too important to leave out and YARD currently does not
@@ -50,6 +92,66 @@ module AMQP
50
92
  super(force, period)
51
93
  end # reconnect(force = false)
52
94
 
95
+ # A version of #reconnect that allows connecting to different endpoints (hosts).
96
+ # @see #reconnect
97
+ # @api public
98
+ def reconnect_to(connection_string_or_options = {}, period = 2)
99
+ opts = case connection_string_or_options
100
+ when String then
101
+ AMQP::Client.parse_connection_uri(connection_string_or_options)
102
+ when Hash then
103
+ connection_string_or_options
104
+ else
105
+ Hash.new
106
+ end
107
+
108
+ super(opts, period)
109
+ end # reconnect_to(connection_string_or_options = {})
110
+
111
+
112
+ # Properly close connection with AMQ broker, as described in
113
+ # section 2.2.4 of the {http://bit.ly/hw2ELX AMQP 0.9.1 specification}.
114
+ #
115
+ # @api plugin
116
+ # @see #close_connection
117
+ def disconnect(reply_code = 200, reply_text = "Goodbye", &block)
118
+ # defined here to make this method appear in YARD documentation. MK.
119
+ super(reply_code, reply_text, &block)
120
+ end
121
+ alias close disconnect
122
+
123
+ # @endgroup
124
+
125
+
126
+
127
+ # @group Broker information
128
+
129
+ # Server properties (product information, platform, et cetera)
130
+ #
131
+ # @return [Hash]
132
+ # @see http://bit.ly/htCzCX AMQP 0.9.1 protocol documentation (Section 1.4.2.1.3)
133
+ attr_reader :server_properties
134
+
135
+ # Server capabilities (usually used to detect AMQP 0.9.1 extensions like basic.nack, publisher
136
+ # confirms and so on)
137
+ #
138
+ # @return [Hash]
139
+ # @see http://bit.ly/htCzCX AMQP 0.9.1 protocol documentation (Section 1.4.2.1.3)
140
+ attr_reader :server_capabilities
141
+
142
+ # Locales server supports
143
+ #
144
+ # @see http://bit.ly/htCzCX AMQP 0.9.1 protocol documentation (Section 1.4.2.1.3)
145
+ attr_reader :server_locales
146
+
147
+ # @return [AMQP::Broker] Broker this connection is established with
148
+ def broker
149
+ @broker ||= AMQP::Broker.new(@server_properties)
150
+ end # broker
151
+
152
+ # @endgroup
153
+
154
+
53
155
 
54
156
  # Defines a callback that will be executed when AMQP connection is considered open:
55
157
  # after client and broker has agreed on max channel identifier and maximum allowed frame
@@ -62,6 +164,9 @@ module AMQP
62
164
  super(&block)
63
165
  end # on_open(&block)
64
166
 
167
+
168
+ # @group Error Handling and Recovery
169
+
65
170
  # Defines a callback that will be run when broker confirms connection termination
66
171
  # (client receives connection.close-ok). You can define more than one callback.
67
172
  #
@@ -99,17 +204,72 @@ module AMQP
99
204
  super(&block)
100
205
  end
101
206
 
207
+ # Defines a callback that will be executed after TCP connection is interrupted (typically because of a network failure).
208
+ # Only one callback can be defined (the one defined last replaces previously added ones).
209
+ #
210
+ # @api public
211
+ def on_connection_interruption(&block)
212
+ super(&block)
213
+ end # on_connection_interruption(&block)
214
+ alias after_connection_interruption on_connection_interruption
102
215
 
103
- # Properly close connection with AMQ broker, as described in
104
- # section 2.2.4 of the {http://bit.ly/hw2ELX AMQP 0.9.1 specification}.
216
+
217
+ # @private
218
+ # @api plugin
219
+ def handle_connection_interruption
220
+ super
221
+ end # handle_connection_interruption
222
+
223
+
224
+ # Defines a callback that will be executed when connection is closed after
225
+ # connection-level exception. Only one callback can be defined (the one defined last
226
+ # replaces previously added ones).
105
227
  #
106
- # @api plugin
107
- # @see #close_connection
108
- def disconnect(reply_code = 200, reply_text = "Goodbye", &block)
109
- # defined here to make this method appear in YARD documentation. MK.
110
- super(reply_code, reply_text, &block)
228
+ # @api public
229
+ def on_error(&block)
230
+ super(&block)
111
231
  end
112
- alias close disconnect
232
+
233
+
234
+ # Defines a callback that will be executed after TCP connection has recovered after a network failure
235
+ # but before AMQP connection is re-opened.
236
+ # Only one callback can be defined (the one defined last replaces previously added ones).
237
+ #
238
+ # @api public
239
+ def before_recovery(&block)
240
+ super(&block)
241
+ end # before_recovery(&block)
242
+
243
+
244
+ # Defines a callback that will be executed after AMQP connection has recovered after a network failure..
245
+ # Only one callback can be defined (the one defined last replaces previously added ones).
246
+ #
247
+ # @api public
248
+ def on_recovery(&block)
249
+ super(&block)
250
+ end # on_recovery(&block)
251
+ alias after_recovery on_recovery
252
+
253
+
254
+ # @return [Boolean] whether connection is in the automatic recovery mode
255
+ # @api public
256
+ def auto_recovering?
257
+ super
258
+ end # auto_recovering?
259
+ alias auto_recovery? auto_recovering?
260
+
261
+
262
+ # Performs recovery of channels that are in the automatic recovery mode.
263
+ #
264
+ # @see Channel#auto_recover
265
+ # @see Queue#auto_recover
266
+ # @see Exchange#auto_recover
267
+ # @api plugin
268
+ def auto_recover
269
+ super
270
+ end # auto_recover
271
+
272
+ # @endgroup
113
273
 
114
274
 
115
275
 
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require "eventmachine"
2
4
  require "amqp/utilities/server_type"
3
5
 
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  # Original version is from Qusion project by Daniel DeLeo.
2
4
  #
3
5
  # Copyright (c) 2009 Daniel DeLeo
data/lib/amqp/version.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module AMQP
4
- # AMQP gem version. Not to be confused with AMQP protocol version
4
+ # amqp gem version. Not to be confused with the AMQP protocol version
5
5
  # it implements. For that, see {AMQ::Protocol::VERSION}
6
6
  #
7
7
  # @see AMQ::Protocol::VERSION
8
8
  # @return [String] AMQP gem version
9
- VERSION = '0.8.0.rc13'
9
+ VERSION = '0.8.0.rc14'
10
10
  end
data/lib/mq.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  $stdout.puts <<-MESSAGE
2
4
  -------------------------------------------------------------------------------------
3
5
  DEPRECATION WARNING!
@@ -20,8 +22,8 @@ MQ should have been called Channel all along). No other AMQP client library we k
20
22
  of invents it's own terminology when it comes to AMQP entities, and amqp gem shouldn't,
21
23
  too.
22
24
 
23
- If you disagree with this really strongly, let us know by opening an issue at
24
- https://github.com/ruby-amqp/amqp/issues
25
+ Learn more at http://bit.ly/amqp-gem-080-migration, all documentation guides are at
26
+ http://bit.ly/amqp-gem-docs.
25
27
 
26
28
  Thank you for understanding. AMQP gem maintainers team.
27
29
 
data/lib/mq/logger.rb CHANGED
@@ -1,2 +1,4 @@
1
+ # encoding: utf-8
2
+
1
3
  require "mq"
2
- require "amqp/logger"
4
+ require "amqp/logger"
data/lib/mq/rpc.rb CHANGED
@@ -1,2 +1,4 @@
1
+ # encoding: utf-8
2
+
1
3
  require "mq"
2
- require "amqp/rpc"
4
+ require "amqp/rpc"
@@ -1,4 +1,5 @@
1
- # -*- coding: utf-8 -*-
1
+ # encoding: utf-8
2
+
2
3
  require "spec_helper"
3
4
 
4
5
  describe "Authentication attempt" do
@@ -10,7 +11,7 @@ describe "Authentication attempt" do
10
11
  include EventedSpec::EMSpec
11
12
  include EventedSpec::SpecHelper
12
13
 
13
- default_timeout 1.0
14
+ default_timeout 7.0
14
15
 
15
16
 
16
17
  describe "with default connection parameters" do
@@ -29,11 +30,8 @@ describe "Authentication attempt" do
29
30
  it "succeeds" do
30
31
  AMQP.connect do |connection|
31
32
  connection.should be_open
32
-
33
33
  connection.close { done }
34
34
  end
35
-
36
- done(0.5)
37
35
  end # it
38
36
  end # context
39
37
  end # describe
@@ -52,15 +50,24 @@ describe "Authentication attempt" do
52
50
  it "succeeds" do
53
51
  connection = AMQP.connect(AMQP_OPTS.merge(:username => "amqp_gem", :password => "amqp_gem_password", :vhost => "amqp_gem_testbed"))
54
52
 
55
- done(0.4) {
53
+ done(3.0) {
56
54
  connection.should be_connected
55
+
56
+ connection.username.should == "amqp_gem"
57
+ connection.user.should == "amqp_gem"
58
+ connection.hostname.should == "localhost"
59
+ connection.host.should == "localhost"
60
+ connection.port.should == 5672
61
+ connection.vhost.should == "amqp_gem_testbed"
62
+ connection.broker_endpoint.should == "localhost:5672/amqp_gem_testbed"
63
+
57
64
  connection.close
58
65
  }
59
66
  end # it
60
67
  end # context
61
68
 
62
69
  context "and provided credentials ARE INCORRECT" do
63
- default_timeout 10
70
+ default_timeout 6
64
71
 
65
72
  after(:all) { done }
66
73
 
@@ -76,7 +83,7 @@ describe "Authentication attempt" do
76
83
 
77
84
 
78
85
  context "and provided vhost DOES NOT EXIST" do
79
- default_timeout 10
86
+ default_timeout 6
80
87
 
81
88
  after(:all) { done }
82
89
 
@@ -106,7 +113,7 @@ describe "Authentication attempt" do
106
113
  it "succeeds" do
107
114
  connection = AMQP.connect "amqp://amqp_gem:amqp_gem_password@localhost/amqp_gem_testbed"
108
115
 
109
- done(0.3) {
116
+ done(3.0) {
110
117
  connection.should be_connected
111
118
  connection.close
112
119
  }
@@ -114,7 +121,7 @@ describe "Authentication attempt" do
114
121
  end # context
115
122
 
116
123
  context "and provided credentials ARE INCORRECT" do
117
- default_timeout 10
124
+ default_timeout 6
118
125
 
119
126
  after(:all) { done }
120
127
 
@@ -1,4 +1,4 @@
1
- # -*- coding: utf-8 -*-
1
+ # encoding: utf-8
2
2
 
3
3
  require 'spec_helper'
4
4
 
@@ -0,0 +1,68 @@
1
+ # encoding: utf-8
2
+
3
+ require "spec_helper"
4
+
5
+ describe AMQP::Channel, "#auto_recovery" do
6
+
7
+ #
8
+ # Environment
9
+ #
10
+
11
+ include EventedSpec::AMQPSpec
12
+ include EventedSpec::SpecHelper
13
+
14
+
15
+ default_options AMQP_OPTS
16
+ default_timeout 2
17
+
18
+
19
+ it "switches automatic recovery mode on" do
20
+ ch = AMQP::Channel.new(AMQP.connection)
21
+ ch.auto_recovery.should be_false
22
+ ch.auto_recovery = true
23
+ ch.auto_recovery.should be_true
24
+ ch.auto_recovery = false
25
+ ch.auto_recovery.should be_false
26
+
27
+ done
28
+ end
29
+ end
30
+
31
+
32
+
33
+
34
+ describe AMQP::Channel, "options hash" do
35
+
36
+ #
37
+ # Environment
38
+ #
39
+
40
+ include EventedSpec::AMQPSpec
41
+ include EventedSpec::SpecHelper
42
+
43
+
44
+ default_options AMQP_OPTS
45
+ default_timeout 2
46
+
47
+
48
+ it "can be passed as the 3rd constructor argument" do
49
+ ch = AMQP::Channel.new(AMQP.connection, AMQP::Channel.next_channel_id, :auto_recovery => true)
50
+ ch.auto_recovery.should be_true
51
+ ch.auto_recovery = false
52
+ ch.auto_recovery.should be_false
53
+
54
+ done
55
+ end
56
+
57
+
58
+ it "can be passed as the 2nd constructor argument" do
59
+ ch = AMQP::Channel.new(AMQP.connection, :auto_recovery => true)
60
+ ch.auto_recovery.should be_true
61
+ ch.should be_auto_recovering
62
+ ch.auto_recovery = false
63
+ ch.auto_recovery.should be_false
64
+ ch.should_not be_auto_recovering
65
+
66
+ done
67
+ end
68
+ end
@@ -1,4 +1,5 @@
1
- # -*- coding: utf-8 -*-
1
+ # encoding: utf-8
2
+
2
3
  require "spec_helper"
3
4
 
4
5
  describe AMQP::Queue, "#pop" do