lib/bunny/channel.rb in bunny-1.7.1 vs lib/bunny/channel.rb in bunny-2.0.0.rc1

- old
+ new

@@ -244,11 +244,19 @@ # @api public def closed? @status == :closed end + def to_s + oid = ("0x%x" % (self.object_id << 1)) + "<#{self.class.name}:#{oid} number=#{@channel.id} @open=#{open?} connection=#{@connection.to_s}>" + end + def inspect + to_s + end + # # @group Backwards compatibility with 0.8.0 # # @return [Integer] Channel id @@ -613,10 +621,13 @@ raise_if_continuation_resulted_in_a_channel_error! @last_basic_get_response end + # prefetch_count is of type short in the protocol. MK. + MAX_PREFETCH_COUNT = (2 ** 16) - 1 + # Controls message delivery rate using basic.qos AMQP 0.9.1 method. # # @param [Integer] prefetch_count How many messages can consumers on this channel be given at a time # (before they have to acknowledge or reject one of the earlier received messages) # @param [Boolean] global (false) Ignored, as it is not supported by RabbitMQ @@ -624,9 +635,10 @@ # @see Bunny::Channel#prefetch # @see http://rubybunny.info/articles/queues.html Queues and Consumers guide # @api public def basic_qos(count, global = false) raise ArgumentError.new("prefetch count must be a positive integer, given: #{prefetch_count}") if count < 0 + raise ArgumentError.new("prefetch count must be no greater than #{MAX_PREFETCH_COUNT}, given: #{prefetch_count}") if count > MAX_PREFETCH_COUNT raise_if_no_longer_open! @connection.send_frame(AMQ::Protocol::Basic::Qos.encode(@id, 0, count, global)) Bunny::Timeout.timeout(wait_on_continuations_timeout, ClientTimeout) do