lib/messaging/client.rb
def open_channel(connection, prefetch = nil)
      res = AMQP::Channel.new(connection) do |channel, open_ok|
        channel.auto_recovery = true
        channel.prefetch(prefetch) if prefetch

        channel.on_error do |ch, error|
          log.error("Channel error #{error.reply_text.inspect}, recovering")

          # Raise erroneous channel calls/conditions
          # rather than endlessly retrying
          if (403..406).include?(error.reply_code)
            raise(MessagingError, "Channel exception: #{error.reply_text.inspect}")
          end
        end

        log.debug("Channel #{channel.id} created")
      end

      register_channel(res)
    end
def open_channel(connection, prefetch = nil)
      res = AMQP::Channel.new(connection) do |channel, open_ok|
        channel.auto_recovery = true
        channel.prefetch(prefetch) if prefetch

        channel.on_error do |ch, error|
          log.error("Channel error #{error.reply_text.inspect}, recovering")

          # Raise erroneous channel calls/conditions
          # rather than endlessly retrying
          if (403..406).include?(error.reply_code)
            raise(MessagingError, "Channel exception: #{error.reply_text.inspect}")
          end
        end

        log.debug("Channel #{channel.id} created")
      end

      register_channel(res)
    end
def open_channel ( connection , prefetch = nil ) res = AMQP :: Channel . new ( connection ) do | channel , open_ok | channel . auto_recovery = true channel . prefetch ( prefetch ) if prefetch channel . on_error do | ch , error | log . error ( "Channel error #{error.reply_text.inspect}, recovering" ) # Raise erroneous channel calls/conditions # rather than endlessly retrying if ( 403 .. 406 ) . include? ( error . reply_code ) raise ( MessagingError , "Channel exception: #{error.reply_text.inspect}" ) end end log . debug ( "Channel #{channel.id} created" ) end register_channel ( res ) end
Open an AMQP::Channel with auto-recovery and error handling.

 @param connection [AMQP::Connection]
 @param prefetch [Integer, nil]
 @return [AMQP::Channel]
 @api public
Open an AMQP :: Channel with auto - recovery and error handling .