right_amqp 0.6.0 → 0.6.1

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.
@@ -20,6 +20,8 @@ documentation.
20
20
  Also use the built-in issues tracker (https://github.com/rightscale/right_amqp/issues)
21
21
  to report issues.
22
22
 
23
+ Maintained by the RightScale Teal Team
24
+
23
25
  == Interface
24
26
 
25
27
  The focus here is on the interface provided by the RightAMQP::HABrokerClient class
@@ -112,4 +112,8 @@ module AMQP
112
112
  yield
113
113
  end
114
114
  end
115
+
116
+ def self.connected?
117
+ !!@conn
118
+ end
115
119
  end
@@ -264,6 +264,9 @@ 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
267
270
  rescue Exception => e
268
271
  header.ack if options[:ack]
269
272
  logger.exception("Failed setting up to receive message from queue #{queue.inspect} " +
@@ -621,6 +624,9 @@ module RightAMQP
621
624
  header.ack
622
625
  end
623
626
  true
627
+ rescue SystemExit
628
+ # Do not want to track exit exception that could occur during serialization
629
+ raise
624
630
  rescue Exception => e
625
631
  header.ack if options[:ack]
626
632
  logger.exception("Failed receiving message from queue #{queue.inspect} on broker #{@alias}", e, :trace)
@@ -646,7 +652,7 @@ module RightAMQP
646
652
  def unserialize(queue, message, options = {})
647
653
  begin
648
654
  received_at = Time.now.to_f
649
- packet = @serializer.load(message)
655
+ packet = @serializer.method(:load).arity.abs > 1 ? @serializer.load(message, queue) : @serializer.load(message)
650
656
  if options.key?(packet.class)
651
657
  unless options[:no_log] && logger.level != :debug
652
658
  re = "RE-" if packet.respond_to?(:tries) && !packet.tries.empty?
@@ -660,6 +666,9 @@ module RightAMQP
660
666
  logger.error("Received invalid #{category}packet type from queue #{queue} on broker #{@alias}: #{packet.class}\n" + caller.join("\n"))
661
667
  nil
662
668
  end
669
+ rescue SystemExit
670
+ # Do not want to track exit exception that could occur during serialization
671
+ raise
663
672
  rescue Exception => e
664
673
  # TODO Taking advantage of Serializer knowledge here even though out of scope
665
674
  trace = e.class.name =~ /SerializationError/ ? :caller : :trace
@@ -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.6.0'
28
- spec.date = '2012-12-10'
27
+ spec.version = '0.6.1'
28
+ spec.date = '2013-07-23'
29
29
  spec.authors = ['Lee Kirchhoff']
30
30
  spec.email = 'lee@rightscale.com'
31
31
  spec.homepage = 'https://github.com/rightscale/right_amqp'
@@ -38,6 +38,8 @@ describe RightAMQP::BrokerClient do
38
38
  @serializer = flexmock("serializer")
39
39
  @serializer.should_receive(:dump).and_return(@message).by_default
40
40
  @serializer.should_receive(:load).with(@message).and_return(@packet).by_default
41
+ @load = flexmock("load method", :arity => 1).by_default
42
+ @serializer.should_receive(:method).with(:load).and_return(@load).by_default
41
43
  @exceptions = flexmock("exceptions")
42
44
  @exceptions.should_receive(:track).never.by_default
43
45
  @non_deliveries = flexmock("non-deliveries")
@@ -371,6 +373,14 @@ describe RightAMQP::BrokerClient do
371
373
  broker.__send__(:unserialize, "queue", @message, RequestMock => nil).should == @packet
372
374
  end
373
375
 
376
+ it "should pass queue to serializer load method if arity is greater than 1" do
377
+ @load.should_receive(:arity).and_return(2).once
378
+ @serializer.should_receive(:method).with(:load).and_return(@load).once
379
+ @serializer.should_receive(:load).with(@message, "queue").and_return(@packet).once
380
+ broker = RightAMQP::BrokerClient.new(@identity, @address, @serializer, @exceptions, @non_deliveries, @options)
381
+ broker.__send__(:unserialize, "queue", @message, RequestMock => nil).should == @packet
382
+ end
383
+
374
384
  it "should log an error if the message is not of the right type and return nil" do
375
385
  @logger.should_receive(:error).with(/Received invalid.*packet type/).once
376
386
  broker = RightAMQP::BrokerClient.new(@identity, @address, @serializer, @exceptions, @non_deliveries, @options)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_amqp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 0
10
- version: 0.6.0
9
+ - 1
10
+ version: 0.6.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Lee Kirchhoff
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-12-10 00:00:00 -08:00
18
+ date: 2013-07-23 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -37,9 +37,9 @@ dependencies:
37
37
  - 0
38
38
  version: "3.0"
39
39
  requirement: *id001
40
+ type: :runtime
40
41
  name: right_support
41
42
  prerelease: false
42
- type: :runtime
43
43
  - !ruby/object:Gem::Dependency
44
44
  version_requirements: &id002 !ruby/object:Gem::Requirement
45
45
  none: false
@@ -60,9 +60,9 @@ dependencies:
60
60
  - 0
61
61
  version: "2.0"
62
62
  requirement: *id002
63
+ type: :runtime
63
64
  name: eventmachine
64
65
  prerelease: false
65
- type: :runtime
66
66
  description: |
67
67
  RightAMQP provides a high availability client for interfacing with the
68
68
  RightScale RabbitMQ broker using the AMQP protocol. The AMQP version on which