amq-client 0.7.0.alpha27 → 0.7.0.alpha28

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,6 +4,7 @@ rvm:
4
4
  - ree
5
5
  - rbx
6
6
  - 1.9.2
7
+ - jruby
7
8
  gemfile:
8
9
  - Gemfile
9
10
  - gemfiles/eventmachine-pre
@@ -18,10 +18,10 @@ amq_client_example "Set a queue up for message delivery" do |client|
18
18
  end
19
19
 
20
20
  queue.consume do |consumer_tag|
21
- queue.on_delivery do |header, payload, consumer_tag, delivery_tag, redelivered, exchange, routing_key|
22
- puts "Got a delivery: #{payload} (delivery tag: #{delivery_tag}), ack-ing..."
21
+ queue.on_delivery do |method, header, payload|
22
+ puts "Got a delivery: #{payload} (delivery tag: #{method.delivery_tag}), ack-ing..."
23
23
 
24
- queue.acknowledge(delivery_tag)
24
+ queue.acknowledge(method.delivery_tag)
25
25
  end
26
26
 
27
27
  exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout)
@@ -17,7 +17,7 @@ end
17
17
 
18
18
 
19
19
  def amq_client_example(description = "", &block)
20
- AMQ::Client::CoolioClient.connect(:port => 5672, :vhost => "/amq_client_testbed") do |client|
20
+ AMQ::Client::CoolioClient.connect(:port => 5672, :vhost => "amq_client_testbed") do |client|
21
21
  begin
22
22
  puts
23
23
  puts
@@ -34,7 +34,7 @@ amq_client_example "Acknowledge a message using basic.ack" do |client|
34
34
  client.disconnect do
35
35
  puts
36
36
  puts "AMQP connection is now properly closed"
37
- EM.stop
37
+ EventMachine.stop
38
38
  end
39
39
  }
40
40
 
@@ -18,7 +18,7 @@ end
18
18
 
19
19
  def amq_client_example(description = "", &block)
20
20
  EM.run do
21
- AMQ::Client::EventMachineClient.connect(:port => 5672, :vhost => "/amq_client_testbed", :frame_max => 65536, :heartbeat_interval => 1) do |client|
21
+ AMQ::Client::EventMachineClient.connect(:port => 5672, :vhost => "amq_client_testbed", :frame_max => 65536, :heartbeat_interval => 1) do |client|
22
22
  begin
23
23
  puts
24
24
  puts
@@ -203,7 +203,7 @@ module AMQ
203
203
  # ruby-amqp/amqp#66, MK.
204
204
  if self.open?
205
205
  closing!
206
- self.send Protocol::Connection::Close.encode(reply_code, reply_text, class_id, method_id)
206
+ self.send_frame(Protocol::Connection::Close.encode(reply_code, reply_text, class_id, method_id))
207
207
  elsif self.closing?
208
208
  # no-op
209
209
  else
@@ -224,7 +224,7 @@ module AMQ
224
224
  # Sends frame to the peer, checking that connection is open.
225
225
  #
226
226
  # @raise [ConnectionClosedError]
227
- def send(frame)
227
+ def send_frame(frame)
228
228
  if closed?
229
229
  raise ConnectionClosedError.new(frame)
230
230
  else
@@ -236,7 +236,7 @@ module AMQ
236
236
  #
237
237
  # @api public
238
238
  def send_frameset(frames)
239
- frames.each { |frame| self.send(frame) }
239
+ frames.each { |frame| self.send_frame(frame) }
240
240
  end # send_frameset(frames)
241
241
 
242
242
 
@@ -252,6 +252,11 @@ module AMQ
252
252
  end # heartbeat_interval
253
253
 
254
254
 
255
+ # vhost this connection uses. Default is "/", a historically estabilished convention
256
+ # of RabbitMQ and amqp gem.
257
+ #
258
+ # @return [String] vhost this connection uses
259
+ # @api public
255
260
  def vhost
256
261
  @settings.fetch(:vhost, "/")
257
262
  end # vhost
@@ -285,6 +290,7 @@ module AMQ
285
290
  end
286
291
 
287
292
  # Sends connection preamble to the broker.
293
+ # @api plugin
288
294
  def handshake
289
295
  @authenticating = true
290
296
  self.send_preamble
@@ -296,7 +302,7 @@ module AMQ
296
302
  # @api plugin
297
303
  # @see http://bit.ly/htCzCX AMQP 0.9.1 protocol documentation (Section 1.4.2.7)
298
304
  def open(vhost = "/")
299
- self.send Protocol::Connection::Open.encode(vhost)
305
+ self.send_frame(Protocol::Connection::Open.encode(vhost))
300
306
  end
301
307
 
302
308
  # Resets connection state.
@@ -313,6 +319,10 @@ module AMQ
313
319
  end # encode_credentials(username, password)
314
320
 
315
321
 
322
+ # Processes a single frame.
323
+ #
324
+ # @param [AMQ::Protocol::Frame] frame
325
+ # @api plugin
316
326
  def receive_frame(frame)
317
327
  @frames << frame
318
328
  if frameset_complete?(@frames)
@@ -323,20 +333,19 @@ module AMQ
323
333
  end
324
334
  end
325
335
 
326
- # When the adapter receives all the frames related to
327
- # given method frame, it's supposed to call this method.
328
- # It calls handler for method class of the first (method)
329
- # frame with all the other frames as arguments. Handlers
330
- # are defined in amq/client/* by the handle(klass, &block)
331
- # method.
336
+ # Processes a frameset by finding and invoking a suitable handler.
337
+ # Heartbeat frames are treated in a special way: they simply update @last_server_heartbeat
338
+ # value.
339
+ #
340
+ # @param [Array<AMQ::Protocol::Frame>] frames
341
+ # @api plugin
332
342
  def receive_frameset(frames)
333
343
  frame = frames.first
334
344
 
335
345
  if Protocol::HeartbeatFrame === frame
336
346
  @last_server_heartbeat = Time.now
337
347
  else
338
- callable = AMQ::Client::HandlersRegistry.find(frame.method_class)
339
- if callable
348
+ if callable = AMQ::Client::HandlersRegistry.find(frame.method_class)
340
349
  callable.call(self, frames.first, frames[1..-1])
341
350
  else
342
351
  raise MissingHandlerError.new(frames.first)
@@ -344,24 +353,26 @@ module AMQ
344
353
  end
345
354
  end
346
355
 
356
+ # Sends a heartbeat frame if connection is open.
357
+ # @api plugin
347
358
  def send_heartbeat
348
359
  if tcp_connection_established?
349
360
  if @last_server_heartbeat < (Time.now - (self.heartbeat_interval * 2))
350
361
  logger.error "Reconnecting due to missing server heartbeats"
351
362
  # TODO: reconnect
352
363
  end
353
- send(Protocol::HeartbeatFrame)
364
+ send_frame(Protocol::HeartbeatFrame)
354
365
  end
355
366
  end # send_heartbeat
356
367
 
357
368
 
358
369
 
359
- # Handles Connection.Start.
370
+ # Handles connection.start.
360
371
  #
361
372
  # @api plugin
362
373
  # @see http://bit.ly/htCzCX AMQP 0.9.1 protocol documentation (Section 1.4.2.1.)
363
- def start_ok(method)
364
- @server_properties = method.server_properties
374
+ def handle_start(connection_start)
375
+ @server_properties = connection_start.server_properties
365
376
 
366
377
  username = @settings[:user] || @settings[:username]
367
378
  password = @settings[:pass] || @settings[:password]
@@ -371,44 +382,45 @@ module AMQ
371
382
  # @status undefined. So lets do this. MK.
372
383
  opening!
373
384
 
374
- self.send Protocol::Connection::StartOk.encode(@client_properties, @mechanism, self.encode_credentials(username, password), @locale)
385
+ self.send_frame(Protocol::Connection::StartOk.encode(@client_properties, @mechanism, self.encode_credentials(username, password), @locale))
375
386
  end
376
387
 
377
388
 
389
+ # Handles Connection.Tune-Ok.
390
+ #
391
+ # @api plugin
392
+ # @see http://bit.ly/htCzCX AMQP 0.9.1 protocol documentation (Section 1.4.2.6)
393
+ def handle_tune(tune_ok)
394
+ @channel_max = tune_ok.channel_max
395
+ @frame_max = tune_ok.frame_max
396
+ @heartbeat_interval = self.heartbeat_interval || tune_ok.heartbeat
397
+
398
+ self.send_frame(Protocol::Connection::TuneOk.encode(@channel_max, [settings[:frame_max], @frame_max].min, @heartbeat_interval))
399
+ end # handle_tune(method)
400
+
401
+
378
402
  # Handles Connection.Open-Ok.
379
403
  #
380
404
  # @api plugin
381
405
  # @see http://bit.ly/htCzCX AMQP 0.9.1 protocol documentation (Section 1.4.2.8.)
382
- def handle_open_ok(method)
383
- @known_hosts = method.known_hosts
406
+ def handle_open_ok(open_ok)
407
+ @known_hosts = open_ok.known_hosts
384
408
 
385
409
  opened!
386
410
  self.connection_successful if self.respond_to?(:connection_successful)
387
411
  end
388
412
 
389
- # Handles Connection.Tune-Ok.
390
- #
391
- # @api plugin
392
- # @see http://bit.ly/htCzCX AMQP 0.9.1 protocol documentation (Section 1.4.2.6)
393
- def handle_tune(method)
394
- @channel_max = method.channel_max
395
- @frame_max = method.frame_max
396
- @heartbeat_interval = self.heartbeat_interval || method.heartbeat
397
-
398
- self.send Protocol::Connection::TuneOk.encode(@channel_max, [settings[:frame_max], @frame_max].min, @heartbeat_interval)
399
- end # handle_tune(method)
400
-
401
413
 
402
414
  # Handles connection.close. When broker detects a connection level exception, this method is called.
403
415
  #
404
416
  # @api plugin
405
417
  # @see http://bit.ly/htCzCX AMQP 0.9.1 protocol documentation (Section 1.5.2.9)
406
- def handle_close(method)
418
+ def handle_close(conn_close)
407
419
  self.handle_connection_interruption
408
420
 
409
421
  closed!
410
- # TODO: use proper exception class, provide protocol class (we know method.class_id and method.method_id) as well!
411
- error = RuntimeError.new(method.reply_text)
422
+ # TODO: use proper exception class, provide protocol class (we know conn_close.class_id and conn_close.method_id) as well!
423
+ error = RuntimeError.new(conn_close.reply_text)
412
424
  self.error(error)
413
425
  end
414
426
 
@@ -417,10 +429,10 @@ module AMQ
417
429
  #
418
430
  # @api plugin
419
431
  # @see http://bit.ly/htCzCX AMQP 0.9.1 protocol documentation (Section 1.4.2.10)
420
- def handle_close_ok(method)
432
+ def handle_close_ok(close_ok)
421
433
  closed!
422
434
  self.disconnection_successful
423
- end # handle_close_ok(method)
435
+ end # handle_close_ok(close_ok)
424
436
 
425
437
  # @api plugin
426
438
  def handle_connection_interruption
@@ -439,9 +451,9 @@ module AMQ
439
451
  # octet + short
440
452
  offset = 3 # 1 + 2
441
453
  # length
442
- payload_length = @chunk_buffer[offset, 4].unpack('N')[0]
454
+ payload_length = @chunk_buffer[offset, 4].unpack(AMQ::Protocol::PACK_UINT32).first
443
455
  # 4 bytes for long payload length, 1 byte final octet
444
- frame_length = offset + 4 + payload_length + 1
456
+ frame_length = offset + payload_length + 5
445
457
  if frame_length <= @chunk_buffer.size
446
458
  @chunk_buffer.slice!(0, frame_length)
447
459
  else
@@ -210,7 +210,7 @@ module AMQ
210
210
 
211
211
 
212
212
  self.handle(Protocol::Connection::Start) do |connection, frame|
213
- connection.start_ok(frame.decode_payload)
213
+ connection.handle_start(frame.decode_payload)
214
214
  end
215
215
 
216
216
  self.handle(Protocol::Connection::Tune) do |connection, frame|
@@ -19,6 +19,21 @@ module AMQ
19
19
  # API
20
20
  #
21
21
 
22
+ # Initiates connection to AMQP broker. If callback is given, runs it when (and if) AMQP connection
23
+ # succeeds.
24
+ #
25
+ # @option settings [String] :host ("127.0.0.1") Hostname AMQ broker runs on.
26
+ # @option settings [String] :port (5672) Port AMQ broker listens on.
27
+ # @option settings [String] :vhost ("/") Virtual host to use.
28
+ # @option settings [String] :user ("guest") Username to use for authentication.
29
+ # @option settings [String] :pass ("guest") Password to use for authentication.
30
+ # @option settings [String] :ssl (false) Should be use TLS (SSL) for connection?
31
+ # @option settings [String] :timeout (nil) Connection timeout.
32
+ # @option settings [String] :logging (false) Turns logging on or off.
33
+ # @option settings [String] :broker (nil) Broker name (use if you intend to use broker-specific features).
34
+ # @option settings [Fixnum] :frame_max (131072) Maximum frame size to use. If broker cannot support frames this large, broker's maximum value will be used instead.
35
+ #
36
+ # @params [Hash] settings
22
37
  def self.connect(settings = {}, &block)
23
38
  @settings = Settings.configure(settings)
24
39
 
@@ -316,7 +331,7 @@ module AMQ
316
331
 
317
332
 
318
333
  self.handle(Protocol::Connection::Start) do |connection, frame|
319
- connection.start_ok(frame.decode_payload)
334
+ connection.handle_start(frame.decode_payload)
320
335
  end
321
336
 
322
337
  self.handle(Protocol::Connection::Tune) do |connection, frame|
@@ -91,7 +91,7 @@ module AMQ
91
91
  #
92
92
  # @api public
93
93
  def open(&block)
94
- @connection.send Protocol::Channel::Open.encode(@id, AMQ::Protocol::EMPTY_STRING)
94
+ @connection.send_frame(Protocol::Channel::Open.encode(@id, AMQ::Protocol::EMPTY_STRING))
95
95
  @connection.channels[@id] = self
96
96
  self.status = :opening
97
97
 
@@ -102,7 +102,7 @@ module AMQ
102
102
  #
103
103
  # @api public
104
104
  def close(reply_code = 200, reply_text = DEFAULT_REPLY_TEXT, class_id = 0, method_id = 0, &block)
105
- @connection.send Protocol::Channel::Close.encode(@id, reply_code, reply_text, class_id, method_id)
105
+ @connection.send_frame(Protocol::Channel::Close.encode(@id, reply_code, reply_text, class_id, method_id))
106
106
 
107
107
  self.redefine_callback :close, &block
108
108
  end
@@ -113,7 +113,7 @@ module AMQ
113
113
  # @api public
114
114
  # @see http://bit.ly/htCzCX AMQP 0.9.1 protocol documentation (Section 1.8.3.13.)
115
115
  def acknowledge(delivery_tag, multiple = false)
116
- @connection.send(Protocol::Basic::Ack.encode(self.id, delivery_tag, multiple))
116
+ @connection.send_frame(Protocol::Basic::Ack.encode(self.id, delivery_tag, multiple))
117
117
 
118
118
  self
119
119
  end # acknowledge(delivery_tag, multiple = false)
@@ -123,7 +123,7 @@ module AMQ
123
123
  # @api public
124
124
  # @see http://bit.ly/htCzCX AMQP 0.9.1 protocol documentation (Section 1.8.3.14.)
125
125
  def reject(delivery_tag, requeue = true)
126
- @connection.send(Protocol::Basic::Reject.encode(self.id, delivery_tag, requeue))
126
+ @connection.send_frame(Protocol::Basic::Reject.encode(self.id, delivery_tag, requeue))
127
127
 
128
128
  self
129
129
  end # reject(delivery_tag, requeue = true)
@@ -134,7 +134,7 @@ module AMQ
134
134
  # @note RabbitMQ as of 2.3.1 does not support prefetch_size.
135
135
  # @api public
136
136
  def qos(prefetch_size = 0, prefetch_count = 32, global = false, &block)
137
- @connection.send Protocol::Basic::Qos.encode(@id, prefetch_size, prefetch_count, global)
137
+ @connection.send_frame(Protocol::Basic::Qos.encode(@id, prefetch_size, prefetch_count, global))
138
138
 
139
139
  self.redefine_callback :qos, &block
140
140
  self
@@ -149,7 +149,7 @@ module AMQ
149
149
  # @see http://bit.ly/htCzCX AMQP 0.9.1 protocol documentation (Section 1.8.3.16.)
150
150
  # @api public
151
151
  def recover(requeue = true, &block)
152
- @connection.send(Protocol::Basic::Recover.encode(@id, requeue))
152
+ @connection.send_frame(Protocol::Basic::Recover.encode(@id, requeue))
153
153
 
154
154
  self.redefine_callback :recover, &block
155
155
  self
@@ -166,7 +166,7 @@ module AMQ
166
166
  # @see http://bit.ly/htCzCX AMQP 0.9.1 protocol documentation (Section 1.5.2.3.)
167
167
  # @api public
168
168
  def flow(active = false, &block)
169
- @connection.send Protocol::Channel::Flow.encode(@id, active)
169
+ @connection.send_frame(Protocol::Channel::Flow.encode(@id, active))
170
170
 
171
171
  self.redefine_callback :flow, &block
172
172
  self
@@ -178,7 +178,7 @@ module AMQ
178
178
  #
179
179
  # @api public
180
180
  def tx_select(&block)
181
- @connection.send Protocol::Tx::Select.encode(@id)
181
+ @connection.send_frame(Protocol::Tx::Select.encode(@id))
182
182
 
183
183
  self.redefine_callback :tx_select, &block
184
184
  self
@@ -188,7 +188,7 @@ module AMQ
188
188
  #
189
189
  # @api public
190
190
  def tx_commit(&block)
191
- @connection.send Protocol::Tx::Commit.encode(@id)
191
+ @connection.send_frame(Protocol::Tx::Commit.encode(@id))
192
192
 
193
193
  self.redefine_callback :tx_commit, &block
194
194
  self
@@ -198,7 +198,7 @@ module AMQ
198
198
  #
199
199
  # @api public
200
200
  def tx_rollback(&block)
201
- @connection.send Protocol::Tx::Rollback.encode(@id)
201
+ @connection.send_frame(Protocol::Tx::Rollback.encode(@id))
202
202
 
203
203
  self.redefine_callback :tx_rollback, &block
204
204
  self
@@ -68,7 +68,7 @@ module AMQ
68
68
 
69
69
 
70
70
  def declare(passive = false, durable = false, auto_delete = false, nowait = false, arguments = nil, &block)
71
- @connection.send(Protocol::Exchange::Declare.encode(@channel.id, @name, @type.to_s, passive, durable, auto_delete, false, nowait, arguments))
71
+ @connection.send_frame(Protocol::Exchange::Declare.encode(@channel.id, @name, @type.to_s, passive, durable, auto_delete, false, nowait, arguments))
72
72
 
73
73
  unless nowait
74
74
  self.define_callback(:declare, &block)
@@ -80,7 +80,7 @@ module AMQ
80
80
 
81
81
 
82
82
  def delete(if_unused = false, nowait = false, &block)
83
- @connection.send(Protocol::Exchange::Delete.encode(@channel.id, @name, if_unused, nowait))
83
+ @connection.send_frame(Protocol::Exchange::Delete.encode(@channel.id, @name, if_unused, nowait))
84
84
 
85
85
  unless nowait
86
86
  self.define_callback(:delete, &block)
@@ -16,7 +16,7 @@ module AMQ
16
16
  # @see http://www.rabbitmq.com/amqp-0-9-1-quickref.html#basic.nack
17
17
  def reject(delivery_tag, requeue = true, multi = false)
18
18
  if multi
19
- @client.send(Protocol::Basic::Nack.encode(self.id, delivery_tag, multi, requeue))
19
+ @client.send_frame(Protocol::Basic::Nack.encode(self.id, delivery_tag, multi, requeue))
20
20
  else
21
21
  super(delivery_tag, requeue)
22
22
  end
@@ -104,7 +104,7 @@ module AMQ
104
104
 
105
105
  @uses_publisher_confirmations = true
106
106
  self.redefine_callback(:confirm_select, &block)
107
- @client.send(Protocol::Confirm::Select.encode(@id, nowait))
107
+ @client.send_frame(Protocol::Confirm::Select.encode(@id, nowait))
108
108
 
109
109
  self
110
110
  end
@@ -36,6 +36,8 @@ module AMQ
36
36
  # @param [String] Queue name. Please note that AMQP spec does not require brokers to support Unicode for queue names.
37
37
  # @api public
38
38
  def initialize(connection, channel, name = AMQ::Protocol::EMPTY_STRING)
39
+ raise ArgumentError.new("queue name must not be nil; if you want broker to generate queue name for you, pass an empty string") if name.nil?
40
+
39
41
  super(connection)
40
42
 
41
43
  @name = name
@@ -87,7 +89,7 @@ module AMQ
87
89
  @auto_delete = auto_delete
88
90
 
89
91
  nowait = true if !block && !@name.empty?
90
- @connection.send(Protocol::Queue::Declare.encode(@channel.id, @name, passive, durable, exclusive, auto_delete, nowait, arguments))
92
+ @connection.send_frame(Protocol::Queue::Declare.encode(@channel.id, @name, passive, durable, exclusive, auto_delete, nowait, arguments))
91
93
 
92
94
  if !nowait
93
95
  self.append_callback(:declare, &block)
@@ -108,7 +110,7 @@ module AMQ
108
110
  # @see http://bit.ly/htCzCX AMQP 0.9.1 protocol documentation (Section 1.7.2.9.)
109
111
  def delete(if_unused = false, if_empty = false, nowait = false, &block)
110
112
  nowait = true unless block
111
- @connection.send(Protocol::Queue::Delete.encode(@channel.id, @name, if_unused, if_empty, nowait))
113
+ @connection.send_frame(Protocol::Queue::Delete.encode(@channel.id, @name, if_unused, if_empty, nowait))
112
114
 
113
115
  if !nowait
114
116
  self.append_callback(:delete, &block)
@@ -134,7 +136,7 @@ module AMQ
134
136
  exchange
135
137
  end
136
138
 
137
- @connection.send(Protocol::Queue::Bind.encode(@channel.id, @name, exchange_name, routing_key, nowait, arguments))
139
+ @connection.send_frame(Protocol::Queue::Bind.encode(@channel.id, @name, exchange_name, routing_key, nowait, arguments))
138
140
 
139
141
  if !nowait
140
142
  self.append_callback(:bind, &block)
@@ -159,7 +161,7 @@ module AMQ
159
161
  exchange
160
162
  end
161
163
 
162
- @connection.send(Protocol::Queue::Unbind.encode(@channel.id, @name, exchange_name, routing_key, arguments))
164
+ @connection.send_frame(Protocol::Queue::Unbind.encode(@channel.id, @name, exchange_name, routing_key, arguments))
163
165
 
164
166
  self.append_callback(:unbind, &block)
165
167
  # TODO: handle channel & connection-level exceptions
@@ -179,7 +181,7 @@ module AMQ
179
181
 
180
182
  nowait = true unless block
181
183
  @consumer_tag = generate_consumer_tag(name)
182
- @connection.send(Protocol::Basic::Consume.encode(@channel.id, @name, @consumer_tag, no_local, no_ack, exclusive, nowait, arguments))
184
+ @connection.send_frame(Protocol::Basic::Consume.encode(@channel.id, @name, @consumer_tag, no_local, no_ack, exclusive, nowait, arguments))
183
185
 
184
186
  @channel.consumers[@consumer_tag] = self
185
187
 
@@ -220,7 +222,7 @@ module AMQ
220
222
  # @api public
221
223
  # @see http://bit.ly/htCzCX AMQP 0.9.1 protocol documentation (Section 1.8.3.10.)
222
224
  def get(no_ack = false, &block)
223
- @connection.send(Protocol::Basic::Get.encode(@channel.id, @name, no_ack))
225
+ @connection.send_frame(Protocol::Basic::Get.encode(@channel.id, @name, no_ack))
224
226
 
225
227
  # most people only want one callback per #get call. Consider the following example:
226
228
  #
@@ -241,7 +243,7 @@ module AMQ
241
243
  def cancel(nowait = false, &block)
242
244
  raise "There is no consumer tag for this queue. This usually means that you are trying to unsubscribe a queue that never was subscribed for messages in the first place." if @consumer_tag.nil?
243
245
 
244
- @connection.send(Protocol::Basic::Cancel.encode(@channel.id, @consumer_tag, nowait))
246
+ @connection.send_frame(Protocol::Basic::Cancel.encode(@channel.id, @consumer_tag, nowait))
245
247
  @consumer_tag = nil
246
248
  self.clear_callbacks(:delivery)
247
249
  self.clear_callbacks(:consume)
@@ -261,7 +263,7 @@ module AMQ
261
263
  # @see http://bit.ly/htCzCX AMQP 0.9.1 protocol documentation (Section 1.7.2.7.)
262
264
  def purge(nowait = false, &block)
263
265
  nowait = true unless block
264
- @connection.send(Protocol::Queue::Purge.encode(@channel.id, @name, nowait))
266
+ @connection.send_frame(Protocol::Queue::Purge.encode(@channel.id, @name, nowait))
265
267
 
266
268
  if !nowait
267
269
  self.redefine_callback(:purge, &block)
@@ -1,5 +1,5 @@
1
1
  module AMQ
2
2
  module Client
3
- VERSION = "0.7.0.alpha27"
3
+ VERSION = "0.7.0.alpha28"
4
4
  end
5
5
  end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+ require 'integration/eventmachine/spec_helper'
3
+
4
+ describe AMQ::Client::EventMachineClient, "queue.declare" do
5
+
6
+ #
7
+ # Environment
8
+ #
9
+
10
+ include EventedSpec::SpecHelper
11
+ default_timeout 1
12
+
13
+
14
+
15
+ #
16
+ # Examples
17
+ #
18
+
19
+ context "when queue name is nil" do
20
+ it "raises ArgumentError" do
21
+ em_amqp_connect do |connection|
22
+ ch = AMQ::Client::Channel.new(connection, 1)
23
+ ch.open do |ch|
24
+ begin
25
+ AMQ::Client::Queue.new(connection, ch, nil)
26
+ rescue ArgumentError => ae
27
+ ae.message.should =~ /queue name must not be nil/
28
+
29
+ done
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end # context
35
+ end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amq-client
3
3
  version: !ruby/object:Gem::Version
4
- hash: -3702664422
4
+ hash: -3702664428
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
9
  - 0
10
10
  - alpha
11
- - 27
12
- version: 0.7.0.alpha27
11
+ - 28
12
+ version: 0.7.0.alpha28
13
13
  platform: ruby
14
14
  authors:
15
15
  - Jakub Stastny
@@ -20,7 +20,7 @@ autorequire:
20
20
  bindir: bin
21
21
  cert_chain: []
22
22
 
23
- date: 2011-05-24 00:00:00 Z
23
+ date: 2011-05-26 00:00:00 Z
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: eventmachine
@@ -201,6 +201,7 @@ files:
201
201
  - spec/integration/eventmachine/connection_close_spec.rb
202
202
  - spec/integration/eventmachine/connection_start_spec.rb
203
203
  - spec/integration/eventmachine/exchange_declare_spec.rb
204
+ - spec/integration/eventmachine/queue_declare_spec.rb
204
205
  - spec/integration/eventmachine/regressions/amqp_gem_issue66_spec.rb
205
206
  - spec/integration/eventmachine/spec_helper.rb
206
207
  - spec/integration/eventmachine/tx_commit_spec.rb
@@ -254,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
254
255
  requirements: []
255
256
 
256
257
  rubyforge_project: amq-client
257
- rubygems_version: 1.8.3
258
+ rubygems_version: 1.8.4
258
259
  signing_key:
259
260
  specification_version: 3
260
261
  summary: amq-client is a fully-featured, low-level AMQP 0.9.1 client