right_amqp 0.7.0 → 0.8.3

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.
@@ -56,7 +56,7 @@ module AMQP
56
56
  # The 'connected' status callback happens before the handshake is done and if it results in
57
57
  # a lot of activity it might prevent EM from being able to call the code handling the
58
58
  # incoming handshake packet in a timely fashion causing the broker to close the connection
59
- @connection_status.call(:ready) if @connection_status && frame.payload.is_a?(AMQP::Protocol::Connection::Start)
59
+ @connection_status.call(:ready) if @connection_status && frame.payload.is_a?(AMQP::Protocol::Connection::OpenOk)
60
60
  end
61
61
  end
62
62
 
@@ -99,6 +99,7 @@ module AMQP
99
99
  end
100
100
 
101
101
  @connected = true
102
+ logger.debug("[amqp] Connected to broker #{@settings[:identity]}")
102
103
  @connection_status.call(:connected) if @connection_status
103
104
 
104
105
  @buf = Buffer.new
@@ -130,8 +131,13 @@ module AMQP
130
131
  begin
131
132
  if connected?
132
133
  now = Time.now
133
- if @last_data_received < (now - (@settings[:heartbeat] * timeout_factor))
134
- data_received = (now - @last_data_received).to_i if @last_data_received
134
+ if @last_data_received.nil?
135
+ # This is something of an anomaly; not clear how this condition is reached
136
+ logger.info("[amqp] Reconnecting to broker #{@settings[:identity]} due to heartbeat timeout " +
137
+ "with no data having been received")
138
+ close_connection # which results in an unbind and an automatic reconnect
139
+ elsif @last_data_received < (now - (@settings[:heartbeat] * timeout_factor))
140
+ data_received = (now - @last_data_received).to_i
135
141
  heartbeat_received = (now - @last_heartbeat_received).to_i if @last_heartbeat_received
136
142
  heartbeat_sent = (now - @last_heartbeat_sent).to_i if @last_heartbeat_sent
137
143
  logger.info("[amqp] Reconnecting to broker #{@settings[:identity]} due to heartbeat timeout: " +
@@ -164,6 +170,7 @@ module AMQP
164
170
  def unbind
165
171
  log 'disconnected'
166
172
  @connected = false
173
+ logger.debug("[amqp] Disconnected from broker #{@settings[:identity]}")
167
174
  EM.next_tick{ @on_disconnect.call }
168
175
  end
169
176
 
@@ -273,7 +280,7 @@ module AMQP
273
280
  end
274
281
 
275
282
  log 'reconnecting'
276
- logger.info("[amqp] Attempting to reconnect to #{@settings[:identity]}")
283
+ logger.info("[amqp] Attempting to reconnect to broker #{@settings[:identity]}")
277
284
  EM.reconnect(@settings[:host], @settings[:port], self)
278
285
  rescue Exception => e
279
286
  logger.exception("[amqp] Failed to reconnect", e, :trace)
@@ -1,9 +1,9 @@
1
1
 
2
2
  #:stopdoc:
3
- # this file was autogenerated on Mon Jan 23 15:55:36 -0800 2012
4
- # using amqp-0.8.json (mtime: Mon Jan 23 15:30:40 -0800 2012)
3
+ # this file was autogenerated on 2014-02-19 18:35:45 -0500
4
+ # using amqp-0.8.json (mtime: 2013-11-07 17:14:52 -0500)
5
5
  #
6
- # DO NOT EDIT! (edit protocol/codegen.rb instead, and run `rake codegen`)
6
+ # DO NOT EDIT! (edit protocol/codegen.rb instead, and run `rake spec:codegen`)
7
7
 
8
8
  module AMQP
9
9
  HEADER = "AMQP".freeze
@@ -79,8 +79,8 @@ module AMQP
79
79
 
80
80
  def properties() @properties ||= [] end
81
81
 
82
- def id() self::ID end
83
- def name() self::NAME end
82
+ def id() defined?(self::ID) ? self::ID : nil end
83
+ def name() defined?(self::NAME) ? self::NAME : super end
84
84
  end
85
85
 
86
86
  class Method
@@ -97,8 +97,8 @@ module AMQP
97
97
  def arguments() @arguments ||= [] end
98
98
 
99
99
  def section() Protocol.const_get(self.to_s[/Protocol::(.+?)::/,1]) end
100
- def id() self::ID end
101
- def name() self::NAME end
100
+ def id() defined?(self::ID) ? self::ID : nil end
101
+ def name() defined?(self::NAME) ? self::NAME : super end
102
102
  end
103
103
 
104
104
  def == b
@@ -264,10 +264,7 @@ module RightAMQP
264
264
  else
265
265
  receive(queue[:name], header, message, options, &block)
266
266
  end
267
- rescue SystemExit
268
- # Do not want to track exit exception that could occur during serialization
269
- raise
270
- rescue Exception => e
267
+ rescue StandardError => e
271
268
  header.ack if options[:ack]
272
269
  logger.exception("Failed setting up to receive message from queue #{queue.inspect} " +
273
270
  "on broker #{@alias}", e, :trace)
@@ -275,7 +272,7 @@ module RightAMQP
275
272
  @non_delivery_stats.update("receive failure")
276
273
  end
277
274
  end
278
- rescue Exception => e
275
+ rescue StandardError => e
279
276
  logger.exception("Failed subscribing queue #{queue.inspect}#{to_exchange} on broker #{@alias}", e, :trace)
280
277
  @exception_stats.track("subscribe", e)
281
278
  false
@@ -294,17 +291,20 @@ module RightAMQP
294
291
  # === Return
295
292
  # true:: Always return true
296
293
  def unsubscribe(queue_names, &block)
297
- if usable?
298
- @queues.each do |q|
294
+ unless failed?
295
+ @queues.reject! do |q|
299
296
  if queue_names.include?(q.name)
300
297
  begin
301
298
  logger.info("[stop] Unsubscribing queue #{q.name} on broker #{@alias}")
302
299
  q.unsubscribe { block.call if block }
303
- rescue Exception => e
300
+ rescue StandardError => e
304
301
  logger.exception("Failed unsubscribing queue #{q.name} on broker #{@alias}", e, :trace)
305
302
  @exception_stats.track("unsubscribe", e)
306
303
  block.call if block
307
304
  end
305
+ true
306
+ else
307
+ false
308
308
  end
309
309
  end
310
310
  end
@@ -327,7 +327,7 @@ module RightAMQP
327
327
  delete_amqp_resources(:queue, name)
328
328
  @channel.__send__(type, name, options)
329
329
  true
330
- rescue Exception => e
330
+ rescue StandardError => e
331
331
  logger.exception("Failed declaring #{type.to_s} #{name} on broker #{@alias}", e, :trace)
332
332
  @exception_stats.track("declare", e)
333
333
  false
@@ -356,7 +356,7 @@ module RightAMQP
356
356
  if queue_names.include?(q.name)
357
357
  begin
358
358
  q.status { |messages, consumers| block.call(q.name, messages, consumers) if block }
359
- rescue Exception => e
359
+ rescue StandardError => e
360
360
  logger.exception("Failed checking status of queue #{q.name} on broker #{@alias}", e, :trace)
361
361
  @exception_stats.track("queue_status", e)
362
362
  block.call(q.name, nil, nil) if block
@@ -409,7 +409,7 @@ module RightAMQP
409
409
  delete_amqp_resources(exchange[:type], exchange[:name]) if exchange_options[:declare]
410
410
  @channel.__send__(exchange[:type], exchange[:name], exchange_options).publish(message, options)
411
411
  true
412
- rescue Exception => e
412
+ rescue StandardError => e
413
413
  logger.exception("Failed publishing to exchange #{exchange.inspect} on broker #{@alias}", e, :trace)
414
414
  @exception_stats.track("publish", e)
415
415
  @non_delivery_stats.update("publish failure")
@@ -441,7 +441,7 @@ module RightAMQP
441
441
  @channel.queue(name, options).delete
442
442
  deleted = true
443
443
  end
444
- rescue Exception => e
444
+ rescue StandardError => e
445
445
  logger.exception("Failed deleting queue #{name.inspect} on broker #{@alias}", e, :trace)
446
446
  @exception_stats.track("delete", e)
447
447
  end
@@ -484,7 +484,7 @@ module RightAMQP
484
484
  @status = final_status
485
485
  yield if block_given?
486
486
  end
487
- rescue Exception => e
487
+ rescue StandardError => e
488
488
  logger.exception("Failed to close broker #{@alias}", e, :trace)
489
489
  @exception_stats.track("close", e)
490
490
  @status = final_status
@@ -610,7 +610,7 @@ module RightAMQP
610
610
  @channel.__send__(:connection).connection_status { |status| update_status(status) }
611
611
  @channel.prefetch(@options[:prefetch]) if @options[:prefetch]
612
612
  @channel.return_message { |header, message| handle_return(header, message) }
613
- rescue Exception => e
613
+ rescue StandardError => e
614
614
  @status = :failed
615
615
  @failure_stats.update
616
616
  logger.exception("Failed connecting to broker #{@alias}", e, :trace)
@@ -656,10 +656,7 @@ module RightAMQP
656
656
  header.ack
657
657
  end
658
658
  true
659
- rescue SystemExit
660
- # Do not want to track exit exception that could occur during serialization
661
- raise
662
- rescue Exception => e
659
+ rescue StandardError => e
663
660
  header.ack if options[:ack]
664
661
  logger.exception("Failed receiving message from queue #{queue.inspect} on broker #{@alias}", e, :trace)
665
662
  @exception_stats.track("receive", e)
@@ -698,10 +695,7 @@ module RightAMQP
698
695
  logger.error("Received invalid #{category}packet type from queue #{queue} on broker #{@alias}: #{packet.class}\n" + caller.join("\n"))
699
696
  nil
700
697
  end
701
- rescue SystemExit
702
- # Do not want to track exit exception that could occur during serialization
703
- raise
704
- rescue Exception => e
698
+ rescue StandardError => e
705
699
  # TODO Taking advantage of Serializer knowledge here even though out of scope
706
700
  trace = e.class.name =~ /SerializationError/ ? :caller : :trace
707
701
  logger.exception("Failed unserializing message from queue #{queue.inspect} on broker #{@alias}", e, trace)
@@ -28,9 +28,9 @@ module RightAMQP
28
28
 
29
29
  include RightSupport::Log::Mixin
30
30
 
31
- class NoUserData < Exception; end
32
- class NoBrokerHosts < Exception; end
33
- class NoConnectedBrokers < Exception; end
31
+ class NoUserData < StandardError; end
32
+ class NoBrokerHosts < StandardError; end
33
+ class NoConnectedBrokers < StandardError; end
34
34
 
35
35
  # Message publishing context
36
36
  class Context
@@ -122,6 +122,8 @@ module RightAMQP
122
122
  # if the agent crashes. Value 0 means unlimited prefetch.
123
123
  # :order(Symbol):: Broker selection order when publishing a message: :random or :priority,
124
124
  # defaults to :priority, value can be overridden on publish call
125
+ # :exception_stats(RightSupport::Stats::Exceptions):: Exception statistics container to be used
126
+ # instead of internally created one
125
127
  # :exception_callback(Proc):: Callback activated on exception events with parameters
126
128
  # exception(Exception):: Exception
127
129
  # message(Packet):: Message being processed
@@ -171,19 +173,24 @@ module RightAMQP
171
173
  raise NoUserData.new("User data is missing") if user_data.nil? || user_data.empty?
172
174
  hosts = ""
173
175
  ports = nil
176
+ parsed = {}
174
177
  user_data.split("&").each do |data|
175
178
  name, value = data.split("=")
176
- if name == "RS_rn_url"
177
- h = value.split("@").last.split("/").first
178
- # Translate host name used by very old agents using only one broker
179
- h = "broker1-1.rightscale.com" if h == "broker.rightscale.com"
180
- hosts = h + hosts
181
- end
182
- if name == "RS_rn_host"
183
- hosts << value
184
- end
185
- if name == "RS_rn_port"
186
- ports = value
179
+ # Guard against repeats
180
+ unless parsed[name]
181
+ if name == "RS_rn_url"
182
+ h = value.split("@").last.split("/").first
183
+ # Translate host name used by very old agents using only one broker
184
+ h = "broker1-1.rightscale.com" if h == "broker.rightscale.com"
185
+ hosts = h + hosts
186
+ end
187
+ if name == "RS_rn_host"
188
+ hosts << value
189
+ end
190
+ if name == "RS_rn_port"
191
+ ports = value
192
+ end
193
+ parsed[name] = true
187
194
  end
188
195
  end
189
196
  raise NoBrokerHosts.new("No brokers found in user data") if hosts.empty?
@@ -757,7 +764,7 @@ module RightAMQP
757
764
  @brokers.each do |b|
758
765
  begin
759
766
  b.close(propagate = false) { handler.completed_one }
760
- rescue Exception => e
767
+ rescue StandardError => e
761
768
  handler.completed_one
762
769
  logger.exception("Failed to close broker #{b.alias}", e, :trace)
763
770
  @exception_stats.track("close", e)
@@ -857,11 +864,11 @@ module RightAMQP
857
864
  def stats(reset = false)
858
865
  stats = {
859
866
  "brokers" => @brokers.map { |b| b.stats },
860
- "exceptions" => @exception_stats.stats,
861
867
  "heartbeat" => @options[:heartbeat],
862
868
  "non-deliveries" => @non_delivery_stats.all,
863
869
  "returns" => @return_stats.all
864
870
  }
871
+ stats["exceptions"] = @exception_stats.stats unless @options[:exception_stats]
865
872
  reset_stats if reset
866
873
  stats
867
874
  end
@@ -875,7 +882,7 @@ module RightAMQP
875
882
  def reset_stats
876
883
  @return_stats = RightSupport::Stats::Activity.new
877
884
  @non_delivery_stats = RightSupport::Stats::Activity.new
878
- @exception_stats = RightSupport::Stats::Exceptions.new(self, @options[:exception_callback])
885
+ @exception_stats = @options[:exception_stats] || RightSupport::Stats::Exceptions.new(self, @options[:exception_callback])
879
886
  true
880
887
  end
881
888
 
@@ -24,8 +24,8 @@ require 'rubygems'
24
24
 
25
25
  Gem::Specification.new do |spec|
26
26
  spec.name = 'right_amqp'
27
- spec.version = '0.7.0'
28
- spec.date = '2013-08-04'
27
+ spec.version = '0.8.3'
28
+ spec.date = '2014-05-22'
29
29
  spec.authors = ['Lee Kirchhoff']
30
30
  spec.email = 'lee@rightscale.com'
31
31
  spec.homepage = 'https://github.com/rightscale/right_amqp'
@@ -0,0 +1,52 @@
1
+ #
2
+ # Copyright (c) 2009-2012 RightScale Inc
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
24
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'right_amqp'))
25
+
26
+ describe AMQP::Protocol::Class do
27
+ context ".name" do
28
+ it "returns a value" do
29
+ AMQP::Protocol::Class.name.should == "AMQP::Protocol::Class"
30
+ end
31
+ end
32
+
33
+ context ".id" do
34
+ it "returns a value" do
35
+ AMQP::Protocol::Class.id.should == nil
36
+ end
37
+ end
38
+ end
39
+
40
+ describe AMQP::Protocol::Class::Method do
41
+ context ".name" do
42
+ it "returns a value" do
43
+ AMQP::Protocol::Class::Method.name.should == "AMQP::Protocol::Class::Method"
44
+ end
45
+ end
46
+
47
+ context ".id" do
48
+ it "returns a value" do
49
+ AMQP::Protocol::Class::Method.id.should == nil
50
+ end
51
+ end
52
+ end
@@ -100,7 +100,7 @@ describe RightAMQP::BrokerClient do
100
100
  @connection.should_receive(:close).once
101
101
  @logger.should_receive(:info).once
102
102
  @logger.should_receive(:error).with(/Failed connecting/).once
103
- flexmock(MQ).should_receive(:new).with(@connection).and_raise(Exception)
103
+ flexmock(MQ).should_receive(:new).with(@connection).and_raise(StandardError)
104
104
  broker = RightAMQP::BrokerClient.new(@identity, @address, @serializer, @exceptions, @non_deliveries, @options)
105
105
  broker.summary.should == {:alias => "b0", :identity => @identity, :status => :failed,
106
106
  :disconnects => 0, :failures => 1, :retries => 0}
@@ -443,7 +443,7 @@ describe RightAMQP::BrokerClient do
443
443
 
444
444
  it "should log an error if exception prevents normal logging and should then return nil" do
445
445
  @logger.should_receive(:error).with(/Failed unserializing message from queue/).once
446
- @serializer.should_receive(:load).with(@message).and_raise(Exception).once
446
+ @serializer.should_receive(:load).with(@message).and_raise(StandardError).once
447
447
  @exceptions.should_receive(:track).once
448
448
  @non_deliveries.should_receive(:update).once
449
449
  broker = RightAMQP::BrokerClient.new(@identity, @address, @serializer, @exceptions, @non_deliveries, @options)
@@ -452,7 +452,7 @@ describe RightAMQP::BrokerClient do
452
452
 
453
453
  it "should make callback when there is a receive failure" do
454
454
  @logger.should_receive(:error).with(/Failed unserializing message from queue/).once
455
- @serializer.should_receive(:load).with(@message).and_raise(Exception).once
455
+ @serializer.should_receive(:load).with(@message).and_raise(StandardError).once
456
456
  @exceptions.should_receive(:track).once
457
457
  @non_deliveries.should_receive(:update).once
458
458
  called = 0
@@ -491,6 +491,16 @@ describe RightAMQP::BrokerClient do
491
491
  broker.unsubscribe(["queue1"])
492
492
  end
493
493
 
494
+ it "should remove unsubscribed queue from list of queues" do
495
+ @queue.should_receive(:unsubscribe).once
496
+ broker = RightAMQP::BrokerClient.new(@identity, @address, @serializer, @exceptions, @non_deliveries, @options)
497
+ broker.subscribe({:name => "queue1"}, {:type => :direct, :name => "exchange"}) {|_, _|}
498
+ broker.queues.size.should == 1
499
+ broker.queues[0].name.should == "queue1"
500
+ broker.unsubscribe(["queue1"])
501
+ broker.queues.should be_empty
502
+ end
503
+
494
504
  it "should ignore unsubscribe if queue unknown" do
495
505
  @queue.should_receive(:unsubscribe).never
496
506
  broker = RightAMQP::BrokerClient.new(@identity, @address, @serializer, @exceptions, @non_deliveries, @options)
@@ -507,17 +517,18 @@ describe RightAMQP::BrokerClient do
507
517
  called.should == 1
508
518
  end
509
519
 
510
- it "should ignore the request if client not usable" do
520
+ it "should ignore the request if client is failed" do
511
521
  @queue.should_receive(:unsubscribe).and_yield.never
512
522
  broker = RightAMQP::BrokerClient.new(@identity, @address, @serializer, @exceptions, @non_deliveries, @options)
513
523
  broker.subscribe({:name => "queue1"}, {:type => :direct, :name => "exchange"}) {|_, _|}
514
- broker.__send__(:update_status, :disconnected)
524
+ @logger.should_receive(:error).with(/Failed to connect to broker b0/).once
525
+ broker.__send__(:update_status, :failed)
515
526
  broker.unsubscribe(["queue1"])
516
527
  end
517
528
 
518
529
  it "should log an error if unsubscribe raises an exception and activate block if provided" do
519
530
  @logger.should_receive(:error).with(/Failed unsubscribing/).once
520
- @queue.should_receive(:unsubscribe).and_raise(Exception).once
531
+ @queue.should_receive(:unsubscribe).and_raise(StandardError).once
521
532
  @exceptions.should_receive(:track).once
522
533
  broker = RightAMQP::BrokerClient.new(@identity, @address, @serializer, @exceptions, @non_deliveries, @options)
523
534
  broker.subscribe({:name => "queue1"}, {:type => :direct, :name => "exchange"}) {|_, _|}
@@ -570,7 +581,7 @@ describe RightAMQP::BrokerClient do
570
581
  @logger.should_receive(:info).with(/Declaring/).once
571
582
  @logger.should_receive(:error).with(/Failed declaring/).once
572
583
  @exceptions.should_receive(:track).once
573
- @channel.should_receive(:queue).and_raise(Exception).once
584
+ @channel.should_receive(:queue).and_raise(StandardError).once
574
585
  broker = RightAMQP::BrokerClient.new(@identity, @address, @serializer, @exceptions, @non_deliveries, @options)
575
586
  broker.declare(:queue, "q").should be_false
576
587
  end
@@ -616,7 +627,7 @@ describe RightAMQP::BrokerClient do
616
627
  it "should log unexpected exceptions and call block with nil status" do
617
628
  @logger.should_receive(:error).with(/Failed checking status of queue/).once
618
629
  @exceptions.should_receive(:track).once
619
- @queue.should_receive(:status).and_raise(Exception).once
630
+ @queue.should_receive(:status).and_raise(StandardError).once
620
631
  called = 0
621
632
  @broker.queue_status(["queue1"]) do |name, messages, consumers|
622
633
  name.should == "queue1"
@@ -667,7 +678,7 @@ describe RightAMQP::BrokerClient do
667
678
  @logger.should_receive(:error).with(/Failed publishing/).once
668
679
  @exceptions.should_receive(:track).once
669
680
  @non_deliveries.should_receive(:update).once
670
- @channel.should_receive(:direct).and_raise(Exception)
681
+ @channel.should_receive(:direct).and_raise(StandardError)
671
682
  @direct.should_receive(:publish).with(@message, {}).never
672
683
  broker = RightAMQP::BrokerClient.new(@identity, @address, @serializer, @exceptions, @non_deliveries, @options)
673
684
  broker.__send__(:update_status, :ready)
@@ -863,7 +874,7 @@ describe RightAMQP::BrokerClient do
863
874
  it "should log an error and return false if the delete fails" do
864
875
  @logger.should_receive(:error).with(/Failed deleting queue/).once
865
876
  @exceptions.should_receive(:track).once
866
- @queue.should_receive(:delete).and_raise(Exception)
877
+ @queue.should_receive(:delete).and_raise(StandardError)
867
878
  broker = RightAMQP::BrokerClient.new(@identity, @address, @serializer, @exceptions, @non_deliveries, @options)
868
879
  broker.subscribe({:name => "queue1"}, {:type => :direct, :name => "exchange"}) {|_, _|}
869
880
  broker.queues.should == [@queue]
@@ -1049,7 +1060,7 @@ describe RightAMQP::BrokerClient do
1049
1060
  it "should log an error if closing connection fails but still set status to :closed" do
1050
1061
  @logger.should_receive(:error).with(/Failed to close broker b0/).once
1051
1062
  @exceptions.should_receive(:track).once
1052
- @connection.should_receive(:close).and_raise(Exception)
1063
+ @connection.should_receive(:close).and_raise(StandardError)
1053
1064
  broker = RightAMQP::BrokerClient.new(@identity, @address, @serializer, @exceptions, @non_deliveries, @options)
1054
1065
  broker.close
1055
1066
  broker.status.should == :closed
@@ -239,6 +239,12 @@ describe RightAMQP::HABrokerClient do
239
239
  ["broker1-1.rightscale.com", nil]
240
240
  end
241
241
 
242
+ it "should ignore repeated variables in the user data" do
243
+ user_data = "RS_rn_url=amqp://49c7a840eb:5c9c0823cb@broker4-2.rightscale.com/right_net&RS_rn_id=6067794001&RS_server=my.rightscale.com&RS_sketchy=sketchy12-13.rightscale.com&RS_rn_host=:1,broker4-1.rightscale.com:0&RS_rn_url=amqp://49c7a840eb:5c9c0823cb@broker4-1.rightscale.com/right_net&RS_rn_id=6067770001&RS_server=my.rightscale.com&RS_sketchy=sketchy12-13.rightscale.com&RS_rn_host=:0,broker4-2.rightscale.com:1"
244
+ RightAMQP::HABrokerClient.parse_user_data(user_data).should ==
245
+ ["broker4-2.rightscale.com:1,broker4-1.rightscale.com:0", nil]
246
+ end
247
+
242
248
  end # when parsing user_data
243
249
 
244
250
  context "when addressing" do
@@ -1127,6 +1133,18 @@ describe RightAMQP::HABrokerClient do
1127
1133
  "returns" => nil}
1128
1134
  end
1129
1135
 
1136
+ it "should omit exceptions from client statistics if accumulated usin :exception_stats option" do
1137
+ stats = RightSupport::Stats::Exceptions.new
1138
+ ha = RightAMQP::HABrokerClient.new(@serializer, :host => "first, second, third", :exception_stats => stats)
1139
+ @broker1.should_receive(:stats).and_return("stats1")
1140
+ @broker2.should_receive(:stats).and_return("stats2")
1141
+ @broker3.should_receive(:stats).and_return("stats3")
1142
+ ha.stats.should == {"brokers" => ["stats1", "stats2", "stats3"],
1143
+ "heartbeat" => nil,
1144
+ "non-deliveries" => nil,
1145
+ "returns" => nil}
1146
+ end
1147
+
1130
1148
  it "should log broker client status update if there is a change" do
1131
1149
  @logger.should_receive(:info).with(/Broker b0 is now connected/).once
1132
1150
  ha = RightAMQP::HABrokerClient.new(@serializer, :host => "first, second, third")
@@ -1443,7 +1461,7 @@ describe RightAMQP::HABrokerClient do
1443
1461
  it "should close all broker connections even if encounter an exception" do
1444
1462
  @logger.should_receive(:error).with(/Failed to close/).once
1445
1463
  @broker1.should_receive(:close).and_return(true).and_yield.once
1446
- @broker2.should_receive(:close).and_raise(Exception).once
1464
+ @broker2.should_receive(:close).and_raise(StandardError).once
1447
1465
  @broker3.should_receive(:close).and_return(true).and_yield.once
1448
1466
  ha = RightAMQP::HABrokerClient.new(@serializer, :host => "first, second, third")
1449
1467
  called = 0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_amqp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-04 00:00:00.000000000Z
12
+ date: 2014-05-22 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: right_support
16
- requirement: &2157007400 !ruby/object:Gem::Requirement
16
+ requirement: &2169048940 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -24,10 +24,10 @@ dependencies:
24
24
  version: '3.0'
25
25
  type: :runtime
26
26
  prerelease: false
27
- version_requirements: *2157007400
27
+ version_requirements: *2169048940
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: eventmachine
30
- requirement: &2156993280 !ruby/object:Gem::Requirement
30
+ requirement: &2169047520 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ! '>='
@@ -38,7 +38,7 @@ dependencies:
38
38
  version: '2.0'
39
39
  type: :runtime
40
40
  prerelease: false
41
- version_requirements: *2156993280
41
+ version_requirements: *2169047520
42
42
  description: ! 'RightAMQP provides a high availability client for interfacing with
43
43
  the
44
44
 
@@ -91,6 +91,7 @@ files:
91
91
  - lib/right_amqp/mq/rpc.rb
92
92
  - right_amqp.gemspec
93
93
  - spec/amqp/client_extensions_spec.rb
94
+ - spec/amqp/spec_spec.rb
94
95
  - spec/ha_client/broker_client_spec.rb
95
96
  - spec/ha_client/ha_broker_client_spec.rb
96
97
  - spec/spec.opts
@@ -119,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
120
  version: '0'
120
121
  segments:
121
122
  - 0
122
- hash: -2424550966493205520
123
+ hash: -1878767415152357998
123
124
  requirements: []
124
125
  rubyforge_project:
125
126
  rubygems_version: 1.8.10