right_amqp 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -334,6 +334,38 @@ module RightAMQP
|
|
334
334
|
end
|
335
335
|
end
|
336
336
|
|
337
|
+
# Check status of specified queues
|
338
|
+
# Silently ignore unknown queues
|
339
|
+
# If a queue whose status is being checked does not exist in the broker,
|
340
|
+
# this broker connection will fail and become unusable
|
341
|
+
#
|
342
|
+
# === Parameters
|
343
|
+
# queue_names(Array):: Names of queues previously subscribed to
|
344
|
+
#
|
345
|
+
# === Block
|
346
|
+
# Optional block to be called each time that status for a queue is retrieved with
|
347
|
+
# parameters queue name, message count, and consumer count; the counts are nil
|
348
|
+
# if there was a failure while trying to retrieve them; the block is not called
|
349
|
+
# for queues to which this client is not currently subscribed
|
350
|
+
#
|
351
|
+
# === Return
|
352
|
+
# (Boolean):: true if connected, otherwise false, in which case block never gets called
|
353
|
+
def queue_status(queue_names, &block)
|
354
|
+
return false unless connected?
|
355
|
+
@queues.each do |q|
|
356
|
+
if queue_names.include?(q.name)
|
357
|
+
begin
|
358
|
+
q.status { |messages, consumers| block.call(q.name, messages, consumers) if block }
|
359
|
+
rescue Exception => e
|
360
|
+
logger.exception("Failed checking status of queue #{q.name} on broker #{@alias}", e, :trace)
|
361
|
+
@exception_stats.track("queue_status", e)
|
362
|
+
block.call(q.name, nil, nil) if block
|
363
|
+
end
|
364
|
+
end
|
365
|
+
end
|
366
|
+
true
|
367
|
+
end
|
368
|
+
|
337
369
|
# Publish message to AMQP exchange
|
338
370
|
#
|
339
371
|
# === Parameters
|
@@ -352,7 +352,7 @@ module RightAMQP
|
|
352
352
|
# === Return
|
353
353
|
# (Array):: Serialized identity of usable brokers
|
354
354
|
def usable
|
355
|
-
|
355
|
+
each(:usable).map { |b| b.identity }
|
356
356
|
end
|
357
357
|
|
358
358
|
# Get serialized identity of unusable brokers
|
@@ -490,9 +490,9 @@ module RightAMQP
|
|
490
490
|
def subscribe(queue, exchange = nil, options = {}, &blk)
|
491
491
|
identities = []
|
492
492
|
brokers = options.delete(:brokers)
|
493
|
-
|
493
|
+
each(:usable, brokers) { |b| identities << b.identity if b.subscribe(queue, exchange, options, &blk) }
|
494
494
|
logger.info("Could not subscribe to queue #{queue.inspect} on exchange #{exchange.inspect} " +
|
495
|
-
"on brokers #{
|
495
|
+
"on brokers #{each(:usable, brokers).inspect} when selected #{brokers.inspect} " +
|
496
496
|
"from usable #{usable.inspect}") if identities.empty?
|
497
497
|
identities
|
498
498
|
end
|
@@ -510,7 +510,7 @@ module RightAMQP
|
|
510
510
|
# === Return
|
511
511
|
# true:: Always return true
|
512
512
|
def unsubscribe(queue_names, timeout = nil, &blk)
|
513
|
-
count =
|
513
|
+
count = each(:usable).inject(0) do |c, b|
|
514
514
|
c + b.queues.inject(0) { |c, q| c + (queue_names.include?(q.name) ? 1 : 0) }
|
515
515
|
end
|
516
516
|
if count == 0
|
@@ -518,7 +518,7 @@ module RightAMQP
|
|
518
518
|
else
|
519
519
|
handler = CountedDeferrable.new(count, timeout)
|
520
520
|
handler.callback { blk.call if blk }
|
521
|
-
|
521
|
+
each(:usable) { |b| b.unsubscribe(queue_names) { handler.completed_one } }
|
522
522
|
end
|
523
523
|
true
|
524
524
|
end
|
@@ -536,12 +536,51 @@ module RightAMQP
|
|
536
536
|
def declare(type, name, options = {})
|
537
537
|
identities = []
|
538
538
|
brokers = options.delete(:brokers)
|
539
|
-
|
540
|
-
logger.info("Could not declare #{type.to_s} #{name.inspect} on brokers #{
|
539
|
+
each(:usable, brokers) { |b| identities << b.identity if b.declare(type, name, options) }
|
540
|
+
logger.info("Could not declare #{type.to_s} #{name.inspect} on brokers #{each(:usable, brokers).inspect} " +
|
541
541
|
"when selected #{brokers.inspect} from usable #{usable.inspect}") if identities.empty?
|
542
542
|
identities
|
543
543
|
end
|
544
544
|
|
545
|
+
# Check status of specified queues for connected brokers
|
546
|
+
# Silently ignore unknown queues
|
547
|
+
# If a queue whose status is being checked does not exist,
|
548
|
+
# the associated broker connection will fail and be unusable
|
549
|
+
#
|
550
|
+
# === Parameters
|
551
|
+
# queue_names(Array):: Names of queues previously subscribed to that are to be checked
|
552
|
+
# timeout(Integer):: Number of seconds to wait for all status checks, defaults to no timeout
|
553
|
+
#
|
554
|
+
# === Block
|
555
|
+
# Optional block to be called after all queue statuses are obtained with hash parameter
|
556
|
+
# containing statuses with queue name as key and value that is a hash with broker identity
|
557
|
+
# as key and hash of :messages and :consumers as value; the :messages and :consumers
|
558
|
+
# values are nil if there is a failure retrieving them for the given queue
|
559
|
+
#
|
560
|
+
# === Return
|
561
|
+
# true:: Always return true
|
562
|
+
def queue_status(queue_names, timeout = nil, &blk)
|
563
|
+
count = 0
|
564
|
+
status = {}
|
565
|
+
each(:connected) { |b| b.queues.each { |q| count += 1 if queue_names.include?(q.name) } }
|
566
|
+
if count == 0
|
567
|
+
blk.call(status) if blk
|
568
|
+
else
|
569
|
+
handler = CountedDeferrable.new(count, timeout)
|
570
|
+
handler.callback { blk.call(status) if blk }
|
571
|
+
each(:connected) do |b|
|
572
|
+
if b.queue_status(queue_names) do |name, messages, consumers|
|
573
|
+
(status[name] ||= {})[b.identity] = {:messages => messages, :consumers => consumers}
|
574
|
+
handler.completed_one
|
575
|
+
end
|
576
|
+
else
|
577
|
+
b.queues.each { |q| handler.completed_one if queue_names.include?(q.name) }
|
578
|
+
end
|
579
|
+
end
|
580
|
+
end
|
581
|
+
true
|
582
|
+
end
|
583
|
+
|
545
584
|
# Publish message to AMQP exchange of first connected broker
|
546
585
|
#
|
547
586
|
# === Parameters
|
@@ -559,7 +598,7 @@ module RightAMQP
|
|
559
598
|
# :immediate(Boolean):: Return message for the same reasons as :mandatory plus if all
|
560
599
|
# of the queues associated with the exchange are not immediately ready to consume the message
|
561
600
|
# :fanout(Boolean):: true means publish to all connected brokers
|
562
|
-
# :brokers(Array):: Identity of brokers selected for use, defaults to all
|
601
|
+
# :brokers(Array):: Identity of brokers selected for use, defaults to all brokers
|
563
602
|
# if nil or empty
|
564
603
|
# :order(Symbol):: Broker selection order: :random or :priority,
|
565
604
|
# defaults to @select if :brokers is nil, otherwise defaults to :priority
|
@@ -881,25 +920,26 @@ module RightAMQP
|
|
881
920
|
bytes.unpack('H*')[0]
|
882
921
|
end
|
883
922
|
|
884
|
-
# Iterate over clients that
|
923
|
+
# Iterate over clients that have the specified status
|
885
924
|
#
|
886
925
|
# === Parameters
|
926
|
+
# status(String):: Status for selecting: :usable, :connected, :failed
|
887
927
|
# identities(Array):: Identity of brokers to be considered, nil or empty array means all brokers
|
888
928
|
#
|
889
929
|
# === Block
|
890
|
-
# Optional block with following parameters to be called for each
|
930
|
+
# Optional block with following parameters to be called for each broker client selected
|
891
931
|
# broker(BrokerClient):: Broker client
|
892
932
|
#
|
893
933
|
# === Return
|
894
|
-
# (Array)::
|
895
|
-
def
|
934
|
+
# (Array):: Selected broker clients
|
935
|
+
def each(status, identities = nil)
|
896
936
|
choices = if identities && !identities.empty?
|
897
|
-
|
937
|
+
identities.inject([]) { |c, i| if b = @brokers_hash[i] then c << b else c end }
|
898
938
|
else
|
899
939
|
@brokers
|
900
940
|
end
|
901
941
|
choices.select do |b|
|
902
|
-
if b.
|
942
|
+
if b.send("#{status}?".to_sym)
|
903
943
|
yield(b) if block_given?
|
904
944
|
true
|
905
945
|
end
|
@@ -910,7 +950,7 @@ module RightAMQP
|
|
910
950
|
#
|
911
951
|
# === Parameters
|
912
952
|
# options(Hash):: Selection options:
|
913
|
-
# :brokers(Array):: Identity of brokers selected for use, defaults to all
|
953
|
+
# :brokers(Array):: Identity of brokers selected for use, defaults to all brokers if nil or empty
|
914
954
|
# :order(Symbol):: Broker selection order: :random or :priority,
|
915
955
|
# defaults to @select if :brokers is nil, otherwise defaults to :priority
|
916
956
|
#
|
@@ -968,18 +1008,18 @@ module RightAMQP
|
|
968
1008
|
update = if v[:boundary] == :all
|
969
1009
|
if b.size < n && a.size == n
|
970
1010
|
:connected
|
971
|
-
elsif b.size == n && a.size < n
|
972
|
-
:disconnected
|
973
1011
|
elsif (f - failed).empty?
|
974
1012
|
:failed
|
1013
|
+
elsif b.size == n && a.size < n
|
1014
|
+
:disconnected
|
975
1015
|
end
|
976
1016
|
else
|
977
1017
|
if b.size == 0 && a.size > 0
|
978
1018
|
:connected
|
979
|
-
elsif b.size > 0 && a.size == 0
|
980
|
-
:disconnected
|
981
1019
|
elsif (f - failed).empty?
|
982
1020
|
:failed
|
1021
|
+
elsif b.size > 0 && a.size == 0
|
1022
|
+
:disconnected
|
983
1023
|
end
|
984
1024
|
end
|
985
1025
|
if update
|
data/right_amqp.gemspec
CHANGED
@@ -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.
|
28
|
-
spec.date = '2013-
|
27
|
+
spec.version = '0.7.0'
|
28
|
+
spec.date = '2013-08-04'
|
29
29
|
spec.authors = ['Lee Kirchhoff']
|
30
30
|
spec.email = 'lee@rightscale.com'
|
31
31
|
spec.homepage = 'https://github.com/rightscale/right_amqp'
|
@@ -577,6 +577,58 @@ describe RightAMQP::BrokerClient do
|
|
577
577
|
|
578
578
|
end # when declaring
|
579
579
|
|
580
|
+
context "when checking status" do
|
581
|
+
|
582
|
+
before(:each) do
|
583
|
+
@direct = flexmock("direct")
|
584
|
+
@bind = flexmock("bind", :subscribe => true)
|
585
|
+
@queue = flexmock("queue", :bind => @bind, :name => "queue1")
|
586
|
+
@channel.should_receive(:queue).and_return(@queue).by_default
|
587
|
+
@channel.should_receive(:direct).and_return(@direct).by_default
|
588
|
+
flexmock(MQ).should_receive(:new).with(@connection).and_return(@channel).by_default
|
589
|
+
@broker = RightAMQP::BrokerClient.new(@identity, @address, @serializer, @exceptions, @non_deliveries, @options)
|
590
|
+
@broker.subscribe({:name => "queue1"}, {:type => :direct, :name => "exchange"}) {|_, _|}
|
591
|
+
@broker.send(:update_status, :ready)
|
592
|
+
end
|
593
|
+
|
594
|
+
it "should return false if client not connected" do
|
595
|
+
@broker.send(:update_status, :disconnected)
|
596
|
+
@broker.queue_status(["queue1"]).should be_false
|
597
|
+
end
|
598
|
+
|
599
|
+
it "should request the status of each queue and pass it to the supplied block" do
|
600
|
+
@queue.should_receive(:status).and_yield(1, 2).once
|
601
|
+
called = 0
|
602
|
+
@broker.queue_status(["queue1"]) do |name, messages, consumers|
|
603
|
+
name.should == "queue1"
|
604
|
+
messages.should == 1
|
605
|
+
consumers.should == 2
|
606
|
+
called += 1
|
607
|
+
end.should be_true
|
608
|
+
called.should == 1
|
609
|
+
end
|
610
|
+
|
611
|
+
it "should not require a block" do
|
612
|
+
@queue.should_receive(:status).once
|
613
|
+
@broker.queue_status(["queue1"]).should be_true
|
614
|
+
end
|
615
|
+
|
616
|
+
it "should log unexpected exceptions and call block with nil status" do
|
617
|
+
@logger.should_receive(:error).with(/Failed checking status of queue/).once
|
618
|
+
@exceptions.should_receive(:track).once
|
619
|
+
@queue.should_receive(:status).and_raise(Exception).once
|
620
|
+
called = 0
|
621
|
+
@broker.queue_status(["queue1"]) do |name, messages, consumers|
|
622
|
+
name.should == "queue1"
|
623
|
+
messages.should be_nil
|
624
|
+
consumers.should be_nil
|
625
|
+
called += 1
|
626
|
+
end.should be_true
|
627
|
+
called.should == 1
|
628
|
+
end
|
629
|
+
|
630
|
+
end # when checking status
|
631
|
+
|
580
632
|
context "when publishing" do
|
581
633
|
|
582
634
|
before(:each) do
|
@@ -20,6 +20,8 @@
|
|
20
20
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
21
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
22
|
|
23
|
+
require 'json'
|
24
|
+
|
23
25
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
24
26
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'right_amqp'))
|
25
27
|
|
@@ -679,6 +681,59 @@ describe RightAMQP::HABrokerClient do
|
|
679
681
|
|
680
682
|
end # declaring
|
681
683
|
|
684
|
+
context "checking status" do
|
685
|
+
|
686
|
+
before(:each) do
|
687
|
+
@timeout = 10
|
688
|
+
@timer = flexmock("timer", :cancel => true).by_default
|
689
|
+
flexmock(EM::Timer).should_receive(:new).with(@timeout, Proc).and_return(@timer).by_default
|
690
|
+
@queue_name = "my_queue"
|
691
|
+
@queue = flexmock("queue", :name => @queue_name)
|
692
|
+
@queues = [@queue]
|
693
|
+
@broker1.should_receive(:queues).and_return(@queues).by_default
|
694
|
+
@broker1.should_receive(:connected?).and_return(true).by_default
|
695
|
+
@broker1.should_receive(:queue_status).and_return(true).by_default
|
696
|
+
@broker2.should_receive(:queues).and_return(@queues).by_default
|
697
|
+
@broker2.should_receive(:connected?).and_return(true).by_default
|
698
|
+
@broker2.should_receive(:queue_status).and_return(true).by_default
|
699
|
+
@ha = RightAMQP::HABrokerClient.new(@serializer, :host => "first, second")
|
700
|
+
end
|
701
|
+
|
702
|
+
it "should not check status if there are no queues" do
|
703
|
+
@ha.queue_status([]).should be_true
|
704
|
+
end
|
705
|
+
|
706
|
+
it "should make block call with empty status if there are no queues" do
|
707
|
+
called = 0
|
708
|
+
@ha.queue_status(["my_other_queue"], @timeout) { |status| status.should == {}; called += 1 }.should be_true
|
709
|
+
called.should == 1
|
710
|
+
end
|
711
|
+
|
712
|
+
it "should wait to make callback until the status of all queues is obtained" do
|
713
|
+
@broker1.should_receive(:queue_status).with([@queue_name], Proc).and_return(true).and_yield(@queue_name, 0, 1).once
|
714
|
+
@broker2.should_receive(:queue_status).with([@queue_name], Proc).and_return(true).and_yield(@queue_name, 1, 2).once
|
715
|
+
called = 0
|
716
|
+
@ha.queue_status([@queue_name], @timeout) do |status|
|
717
|
+
status.should == {@queue_name => {@broker1.identity => {:messages => 0, :consumers => 1},
|
718
|
+
@broker2.identity => {:messages => 1, :consumers => 2}}}
|
719
|
+
called += 1
|
720
|
+
end.should be_true
|
721
|
+
called.should == 1
|
722
|
+
end
|
723
|
+
|
724
|
+
it "should account for queues for which status cannot be obtained" do
|
725
|
+
called = 0
|
726
|
+
@broker1.should_receive(:queue_status).with([@queue_name], Proc).and_return(false).once
|
727
|
+
@broker2.should_receive(:queue_status).with([@queue_name], Proc).and_return(true).and_yield(@queue_name, 1, 2).once
|
728
|
+
@ha.queue_status([@queue_name], @timeout) do |status|
|
729
|
+
status.should == {@queue_name => {@broker2.identity => {:messages => 1, :consumers => 2}}}
|
730
|
+
called += 1
|
731
|
+
end.should be_true
|
732
|
+
called.should == 1
|
733
|
+
end
|
734
|
+
|
735
|
+
end # checking status
|
736
|
+
|
682
737
|
context "publishing" do
|
683
738
|
|
684
739
|
before(:each) do
|
@@ -987,24 +1042,39 @@ describe RightAMQP::HABrokerClient do
|
|
987
1042
|
@broker3.should_receive(:failed?).and_return(false).by_default
|
988
1043
|
end
|
989
1044
|
|
990
|
-
|
991
|
-
|
992
|
-
aliases = []
|
993
|
-
res = ha.__send__(:each_usable) { |b| aliases << b.alias }
|
994
|
-
aliases.should == ["b0", "b1", "b2"]
|
995
|
-
res.size.should == 3
|
996
|
-
res[0].alias.should == "b0"
|
997
|
-
res[1].alias.should == "b1"
|
998
|
-
res[2].alias.should == "b2"
|
1045
|
+
[:usable, :connected].each do |status|
|
1046
|
+
status_query = "#{status}?".to_sym
|
999
1047
|
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1048
|
+
it "should give access to or list #{status} brokers" do
|
1049
|
+
ha = RightAMQP::HABrokerClient.new(@serializer, :host => "first, second, third")
|
1050
|
+
aliases = []
|
1051
|
+
res = ha.__send__(:each, status) { |b| aliases << b.alias }
|
1052
|
+
aliases.should == ["b0", "b1", "b2"]
|
1053
|
+
res.size.should == 3
|
1054
|
+
res[0].alias.should == "b0"
|
1055
|
+
res[1].alias.should == "b1"
|
1056
|
+
res[2].alias.should == "b2"
|
1057
|
+
|
1058
|
+
@broker1.should_receive(status_query).and_return(true)
|
1059
|
+
@broker2.should_receive(status_query).and_return(false)
|
1060
|
+
@broker3.should_receive(status_query).and_return(false)
|
1061
|
+
aliases = []
|
1062
|
+
res = ha.__send__(:each, status) { |b| aliases << b.alias }
|
1063
|
+
aliases.should == ["b0"]
|
1064
|
+
res.size.should == 1
|
1065
|
+
res[0].alias.should == "b0"
|
1066
|
+
end
|
1067
|
+
|
1068
|
+
it "should give access to each selected #{status} broker" do
|
1069
|
+
ha = RightAMQP::HABrokerClient.new(@serializer, :host => "first, second, third")
|
1070
|
+
@broker2.should_receive(status_query).and_return(true)
|
1071
|
+
@broker3.should_receive(status_query).and_return(false)
|
1072
|
+
aliases = []
|
1073
|
+
res = ha.__send__(:each, status, [@identity2, @identity3]) { |b| aliases << b.alias }
|
1074
|
+
aliases.should == ["b1"]
|
1075
|
+
res.size.should == 1
|
1076
|
+
res[0].alias.should == "b1"
|
1077
|
+
end
|
1008
1078
|
end
|
1009
1079
|
|
1010
1080
|
it "should give list of unusable brokers" do
|
@@ -1015,17 +1085,6 @@ describe RightAMQP::HABrokerClient do
|
|
1015
1085
|
ha.unusable.should == [@identity2, @identity3]
|
1016
1086
|
end
|
1017
1087
|
|
1018
|
-
it "should give access to each selected usable broker" do
|
1019
|
-
ha = RightAMQP::HABrokerClient.new(@serializer, :host => "first, second, third")
|
1020
|
-
@broker2.should_receive(:usable?).and_return(true)
|
1021
|
-
@broker3.should_receive(:usable?).and_return(false)
|
1022
|
-
aliases = []
|
1023
|
-
res = ha.__send__(:each_usable, [@identity2, @identity3]) { |b| aliases << b.alias }
|
1024
|
-
aliases.should == ["b1"]
|
1025
|
-
res.size.should == 1
|
1026
|
-
res[0].alias.should == "b1"
|
1027
|
-
end
|
1028
|
-
|
1029
1088
|
it "should tell whether a broker is connected" do
|
1030
1089
|
ha = RightAMQP::HABrokerClient.new(@serializer, :host => "first, second, third")
|
1031
1090
|
@broker2.should_receive(:connected?).and_return(false)
|
@@ -1233,11 +1292,68 @@ describe RightAMQP::HABrokerClient do
|
|
1233
1292
|
ha.__send__(:update_status, @broker, false)
|
1234
1293
|
@broker.should_receive(:status).and_return(:disconnected)
|
1235
1294
|
@broker.should_receive(:connected?).and_return(false)
|
1295
|
+
@broker.should_receive(:failed?).and_return(false)
|
1236
1296
|
ha.__send__(:update_status, @broker, true)
|
1237
1297
|
called1.should == 1
|
1238
1298
|
called2.should == 2
|
1239
1299
|
end
|
1240
1300
|
|
1301
|
+
it "should provide failed connection status callback when all broker connections fail with :any option" do
|
1302
|
+
ha = RightAMQP::HABrokerClient.new(@serializer, :host => "first, second")
|
1303
|
+
connected = disconnected = failed = 0
|
1304
|
+
ha.connection_status(:boundary => :any) do |status|
|
1305
|
+
if status == :connected
|
1306
|
+
connected += 1
|
1307
|
+
elsif status == :disconnected
|
1308
|
+
disconnected += 1
|
1309
|
+
elsif status == :failed
|
1310
|
+
(ha.brokers[0].failed? &&
|
1311
|
+
ha.brokers[1].failed?).should be_true
|
1312
|
+
failed += 1
|
1313
|
+
end
|
1314
|
+
end
|
1315
|
+
@broker2.should_receive(:failed?).and_return(true)
|
1316
|
+
@broker2.should_receive(:connected?).and_return(false)
|
1317
|
+
ha.__send__(:update_status, @broker2, true)
|
1318
|
+
connected.should == 0
|
1319
|
+
disconnected.should == 0
|
1320
|
+
failed.should == 0
|
1321
|
+
@broker1.should_receive(:failed?).and_return(true)
|
1322
|
+
@broker1.should_receive(:connected?).and_return(false)
|
1323
|
+
ha.__send__(:update_status, @broker1, true)
|
1324
|
+
connected.should == 0
|
1325
|
+
disconnected.should == 0
|
1326
|
+
failed.should == 1
|
1327
|
+
end
|
1328
|
+
|
1329
|
+
it "should provide failed connection status callback when all broker connections fail with :all option" do
|
1330
|
+
ha = RightAMQP::HABrokerClient.new(@serializer, :host => "first, second")
|
1331
|
+
connected = disconnected = failed = 0
|
1332
|
+
ha.connection_status(:boundary => :all) do |status|
|
1333
|
+
if status == :connected
|
1334
|
+
connected += 1
|
1335
|
+
elsif status == :disconnected
|
1336
|
+
disconnected += 1
|
1337
|
+
elsif status == :failed
|
1338
|
+
(ha.brokers[0].failed? &&
|
1339
|
+
ha.brokers[1].failed?).should be_true
|
1340
|
+
failed += 1
|
1341
|
+
end
|
1342
|
+
end
|
1343
|
+
@broker2.should_receive(:failed?).and_return(true)
|
1344
|
+
@broker2.should_receive(:connected?).and_return(false)
|
1345
|
+
ha.__send__(:update_status, @broker2, true)
|
1346
|
+
connected.should == 0
|
1347
|
+
disconnected.should == 1
|
1348
|
+
failed.should == 0
|
1349
|
+
@broker1.should_receive(:failed?).and_return(true)
|
1350
|
+
@broker1.should_receive(:connected?).and_return(false)
|
1351
|
+
ha.__send__(:update_status, @broker1, true)
|
1352
|
+
connected.should == 0
|
1353
|
+
disconnected.should == 1
|
1354
|
+
failed.should == 1
|
1355
|
+
end
|
1356
|
+
|
1241
1357
|
it "should provide failed connection status callback when all brokers fail to connect" do
|
1242
1358
|
ha = RightAMQP::HABrokerClient.new(@serializer, :host => "first, second, third")
|
1243
1359
|
connected = disconnected = failed = 0
|
metadata
CHANGED
@@ -1,87 +1,70 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: right_amqp
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 6
|
9
|
-
- 1
|
10
|
-
version: 0.6.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.7.0
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Lee Kirchhoff
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
version_requirements: &id001 !ruby/object:Gem::Requirement
|
12
|
+
date: 2013-08-04 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: right_support
|
16
|
+
requirement: &2157007400 !ruby/object:Gem::Requirement
|
23
17
|
none: false
|
24
|
-
requirements:
|
25
|
-
- -
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
segments:
|
29
|
-
- 1
|
30
|
-
- 2
|
31
|
-
version: "1.2"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.2'
|
32
22
|
- - <
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
|
35
|
-
segments:
|
36
|
-
- 3
|
37
|
-
- 0
|
38
|
-
version: "3.0"
|
39
|
-
requirement: *id001
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '3.0'
|
40
25
|
type: :runtime
|
41
|
-
name: right_support
|
42
26
|
prerelease: false
|
43
|
-
|
44
|
-
|
27
|
+
version_requirements: *2157007400
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: eventmachine
|
30
|
+
requirement: &2156993280 !ruby/object:Gem::Requirement
|
45
31
|
none: false
|
46
|
-
requirements:
|
47
|
-
- -
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
hash: 59
|
50
|
-
segments:
|
51
|
-
- 0
|
52
|
-
- 12
|
53
|
-
- 10
|
32
|
+
requirements:
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
54
35
|
version: 0.12.10
|
55
36
|
- - <
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
|
58
|
-
segments:
|
59
|
-
- 2
|
60
|
-
- 0
|
61
|
-
version: "2.0"
|
62
|
-
requirement: *id002
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '2.0'
|
63
39
|
type: :runtime
|
64
|
-
name: eventmachine
|
65
40
|
prerelease: false
|
66
|
-
|
67
|
-
|
41
|
+
version_requirements: *2156993280
|
42
|
+
description: ! 'RightAMQP provides a high availability client for interfacing with
|
43
|
+
the
|
44
|
+
|
68
45
|
RightScale RabbitMQ broker using the AMQP protocol. The AMQP version on which
|
46
|
+
|
69
47
|
this gem is based is 0.6.7 but beyond that it contains a number of bug fixes and
|
48
|
+
|
70
49
|
enhancements including reconnect, message return, heartbeat, and UTF-8 support.
|
50
|
+
|
71
51
|
The high availability is achieved by maintaining multiple broker connections
|
52
|
+
|
72
53
|
such that failed connections automatically reconnect and only connected
|
54
|
+
|
73
55
|
brokers are used when routing a message. Although the HABrokerClient class
|
56
|
+
|
74
57
|
is the intended primary means for accessing RabbitMQ services with this gem,
|
58
|
+
|
75
59
|
alternatively the underlying AMQP services may be used directly.
|
76
60
|
|
61
|
+
'
|
77
62
|
email: lee@rightscale.com
|
78
63
|
executables: []
|
79
|
-
|
80
64
|
extensions: []
|
81
|
-
|
82
|
-
extra_rdoc_files:
|
65
|
+
extra_rdoc_files:
|
83
66
|
- README.rdoc
|
84
|
-
files:
|
67
|
+
files:
|
85
68
|
- LICENSE
|
86
69
|
- README.rdoc
|
87
70
|
- Rakefile
|
@@ -112,44 +95,35 @@ files:
|
|
112
95
|
- spec/ha_client/ha_broker_client_spec.rb
|
113
96
|
- spec/spec.opts
|
114
97
|
- spec/spec_helper.rb
|
115
|
-
has_rdoc: true
|
116
98
|
homepage: https://github.com/rightscale/right_amqp
|
117
99
|
licenses: []
|
118
|
-
|
119
100
|
post_install_message:
|
120
|
-
rdoc_options:
|
101
|
+
rdoc_options:
|
121
102
|
- --main
|
122
103
|
- README.rdoc
|
123
104
|
- --title
|
124
105
|
- RightAMQP
|
125
|
-
require_paths:
|
106
|
+
require_paths:
|
126
107
|
- lib
|
127
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
109
|
none: false
|
129
|
-
requirements:
|
130
|
-
- -
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
hash: 57
|
133
|
-
segments:
|
134
|
-
- 1
|
135
|
-
- 8
|
136
|
-
- 7
|
110
|
+
requirements:
|
111
|
+
- - ! '>='
|
112
|
+
- !ruby/object:Gem::Version
|
137
113
|
version: 1.8.7
|
138
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
115
|
none: false
|
140
|
-
requirements:
|
141
|
-
- -
|
142
|
-
- !ruby/object:Gem::Version
|
143
|
-
|
144
|
-
segments:
|
116
|
+
requirements:
|
117
|
+
- - ! '>='
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
segments:
|
145
121
|
- 0
|
146
|
-
|
122
|
+
hash: -2424550966493205520
|
147
123
|
requirements: []
|
148
|
-
|
149
124
|
rubyforge_project:
|
150
|
-
rubygems_version: 1.
|
125
|
+
rubygems_version: 1.8.10
|
151
126
|
signing_key:
|
152
127
|
specification_version: 3
|
153
128
|
summary: Client for interfacing to RightScale RabbitMQ broker using AMQP
|
154
129
|
test_files: []
|
155
|
-
|