amq-protocol support for RabbitMQ consumer cancelation notification #21

Merged
merged 1 commit into from May 19, 2012
Jump to file or symbol
Failed to load files and symbols.
+23 −0
Split
View
@@ -1613,6 +1613,21 @@ def self.encode(channel, consumer_tag, nowait)
buffer << [bit_buffer].pack(PACK_CHAR)
MethodFrame.new(buffer, channel)
end
+
+ # @return
+ def self.decode(data)
+ offset = 0
+ length = data[offset, 1].unpack(PACK_CHAR).first
+ offset += 1
+ consumer_tag = data[offset, length]
+ offset += length
+ self.new(consumer_tag)
+ end
+
+ attr_reader :consumer_tag
+ def initialize(consumer_tag)
+ @consumer_tag = consumer_tag
+ end
end
class CancelOk < Protocol::Method
@@ -138,6 +138,14 @@ class Basic
method_frame.channel.should == 1
end
end
+
+ describe '.decode' do
+ subject do
+ CancelOk.decode("\x03foo\x01")
+ end
+
+ its(:consumer_tag) { should == 'foo' }
+ end
end
describe CancelOk do