Class: AMQ::Protocol::Basic

### Home Classes Methods

### In Files

- lib/amq/protocol/client.rb

### Parent

AMQ::Protocol::Class

### Namespace

- CLASS AMQ::Protocol::Basic::Ack
- CLASS AMQ::Protocol::Basic::Cancel
- CLASS AMQ::Protocol::Basic::CancelOk
- CLASS AMQ::Protocol::Basic::Consume
- CLASS AMQ::Protocol::Basic::ConsumeOk
- CLASS AMQ::Protocol::Basic::Deliver
- CLASS AMQ::Protocol::Basic::Get
- CLASS AMQ::Protocol::Basic::GetEmpty
- CLASS AMQ::Protocol::Basic::GetOk
- CLASS AMQ::Protocol::Basic::Nack
- CLASS AMQ::Protocol::Basic::Publish
- CLASS AMQ::Protocol::Basic::Qos
- CLASS AMQ::Protocol::Basic::QosOk
- CLASS AMQ::Protocol::Basic::Recover
- CLASS AMQ::Protocol::Basic::RecoverAsync
- CLASS AMQ::Protocol::Basic::RecoverOk
- CLASS AMQ::Protocol::Basic::Reject
- CLASS AMQ::Protocol::Basic::Return

### Methods

- ::decode_properties
- ::encode_app_id
- ::encode_cluster_id
- ::encode_content_encoding
- ::encode_content_type
- ::encode_correlation_id
- ::encode_delivery_mode
- ::encode_expiration
- ::encode_headers
- ::encode_message_id
- ::encode_priority
- ::encode_properties
- ::encode_reply_to
- ::encode_timestamp
- ::encode_type
- ::encode_user_id

### Class/Module Index

Quicksearch

- AMQ
- AMQ::BitSet
- AMQ::Endianness
- AMQ::Hacks
- AMQ::IntAllocator
- AMQ::Pack
- AMQ::Protocol
- AMQ::Protocol::AccessRefused
- AMQ::Protocol::BadResponseError
- AMQ::Protocol::Basic
- AMQ::Protocol::Basic::Ack
- AMQ::Protocol::Basic::Cancel
- AMQ::Protocol::Basic::CancelOk
- AMQ::Protocol::Basic::Consume
- AMQ::Protocol::Basic::ConsumeOk
- AMQ::Protocol::Basic::Deliver
- AMQ::Protocol::Basic::Get
- AMQ::Protocol::Basic::GetEmpty
- AMQ::Protocol::Basic::GetOk
- AMQ::Protocol::Basic::Nack
- AMQ::Protocol::Basic::Publish
- AMQ::Protocol::Basic::Qos
- AMQ::Protocol::Basic::QosOk
- AMQ::Protocol::Basic::Recover
- AMQ::Protocol::Basic::RecoverAsync
- AMQ::Protocol::Basic::RecoverOk
- AMQ::Protocol::Basic::Reject
- AMQ::Protocol::Basic::Return
- AMQ::Protocol::BodyFrame
- AMQ::Protocol::Channel
- AMQ::Protocol::Channel::Close
- AMQ::Protocol::Channel::CloseOk
- AMQ::Protocol::Channel::Flow
- AMQ::Protocol::Channel::FlowOk
- AMQ::Protocol::Channel::Open
- AMQ::Protocol::Channel::OpenOk
- AMQ::Protocol::ChannelError
- AMQ::Protocol::Class
- AMQ::Protocol::CommandInvalid
- AMQ::Protocol::Confirm
- AMQ::Protocol::Confirm::Select
- AMQ::Protocol::Confirm::SelectOk
- AMQ::Protocol::Connection
- AMQ::Protocol::Connection::Blocked
- AMQ::Protocol::Connection::Close
- AMQ::Protocol::Connection::CloseOk
- AMQ::Protocol::Connection::Open
- AMQ::Protocol::Connection::OpenOk
- AMQ::Protocol::Connection::Secure
- AMQ::Protocol::Connection::SecureOk
- AMQ::Protocol::Connection::Start
- AMQ::Protocol::Connection::StartOk
- AMQ::Protocol::Connection::Tune
- AMQ::Protocol::Connection::TuneOk
- AMQ::Protocol::Connection::Unblocked
- AMQ::Protocol::ConnectionForced
- AMQ::Protocol::ContentTooLarge
- AMQ::Protocol::EmptyResponseError
- AMQ::Protocol::Error
- AMQ::Protocol::Exchange
- AMQ::Protocol::Exchange::Bind
- AMQ::Protocol::Exchange::BindOk
- AMQ::Protocol::Exchange::Declare
- AMQ::Protocol::Exchange::DeclareOk
- AMQ::Protocol::Exchange::Delete
- AMQ::Protocol::Exchange::DeleteOk
- AMQ::Protocol::Exchange::Unbind
- AMQ::Protocol::Exchange::UnbindOk
- AMQ::Protocol::Float32Bit
- AMQ::Protocol::Frame
- AMQ::Protocol::FrameError
- AMQ::Protocol::FrameSubclass
- AMQ::Protocol::FrameTypeError
- AMQ::Protocol::HardError
- AMQ::Protocol::HeaderFrame
- AMQ::Protocol::HeartbeatFrame
- AMQ::Protocol::InternalError
- AMQ::Protocol::InvalidPath
- AMQ::Protocol::Method
- AMQ::Protocol::MethodFrame
- AMQ::Protocol::NoConsumers
- AMQ::Protocol::NoRoute
- AMQ::Protocol::NotAllowed
- AMQ::Protocol::NotFound
- AMQ::Protocol::NotImplemented
- AMQ::Protocol::PreconditionFailed
- AMQ::Protocol::Queue
- AMQ::Protocol::Queue::Bind
- AMQ::Protocol::Queue::BindOk
- AMQ::Protocol::Queue::Declare
- AMQ::Protocol::Queue::DeclareOk
- AMQ::Protocol::Queue::Delete
- AMQ::Protocol::Queue::DeleteOk
- AMQ::Protocol::Queue::Purge
- AMQ::Protocol::Queue::PurgeOk
- AMQ::Protocol::Queue::Unbind
- AMQ::Protocol::Queue::UnbindOk
- AMQ::Protocol::ResourceError
- AMQ::Protocol::ResourceLocked
- AMQ::Protocol::SoftError
- AMQ::Protocol::SyntaxError
- AMQ::Protocol::Table
- AMQ::Protocol::Table::InvalidTableError
- AMQ::Protocol::TableValueDecoder
- AMQ::Protocol::TableValueEncoder
- AMQ::Protocol::Tx
- AMQ::Protocol::Tx::Commit
- AMQ::Protocol::Tx::CommitOk
- AMQ::Protocol::Tx::Rollback
- AMQ::Protocol::Tx::RollbackOk
- AMQ::Protocol::Tx::Select
- AMQ::Protocol::Tx::SelectOk
- AMQ::Protocol::TypeConstants
- AMQ::Protocol::UnexpectedFrame
- AMQ::URI

No matching classes.

# AMQ::Protocol::Basic

### Constants

DECODE_PROPERTIES

  THIS DECODES ONLY FLAGS

DECODE_PROPERTIES_KEYS

  Hash doesn't give any guarantees on keys order, we will do it in a straightforward way

DECODE_PROPERTIES_TYPE
PROPERTIES

### Public Class Methods

decode_properties(data) click to toggle source

    # File lib/amq/protocol/client.rb, line 1496
    def self.decode_properties(data)
      offset, data_length, properties = 0, data.bytesize, {}

      compressed_index = data[offset, 2].unpack(PACK_UINT16)[0]
      offset += 2
      while data_length > offset
        DECODE_PROPERTIES_KEYS.each do |key|
          next unless compressed_index >= key
          compressed_index -= key
          name = DECODE_PROPERTIES[key] || raise(RuntimeError.new("No property found for index #{index.inspect}!"))
          case DECODE_PROPERTIES_TYPE[key]
          when :shortstr
            size = data[offset, 1].unpack(PACK_CHAR)[0]
            offset += 1
            result = data[offset, size]
          when :octet
            size = 1
            result = data[offset, size].unpack(PACK_CHAR).first
          when :timestamp
            size = 8
            result = Time.at(data[offset, size].unpack(PACK_UINT32_X2).last)
          when :table
            size = 4 + data[offset, 4].unpack(PACK_UINT32)[0]
            result = Table.decode(data[offset, size])
          end
          properties[name] = result
          offset += size
        end
      end

      properties
    end

encode_app_id(value) click to toggle source

1 << 3

    # File lib/amq/protocol/client.rb, line 1409
    def self.encode_app_id(value)
      buffer = ''
      buffer << value.to_s.bytesize.chr
      buffer << value.to_s
      [12, 0x0008, buffer]
    end

encode_cluster_id(value) click to toggle source

1 << 2

    # File lib/amq/protocol/client.rb, line 1417
    def self.encode_cluster_id(value)
      buffer = ''
      buffer << value.to_s.bytesize.chr
      buffer << value.to_s
      [13, 0x0004, buffer]
    end

encode_content_encoding(value) click to toggle source

1 << 14

    # File lib/amq/protocol/client.rb, line 1325
    def self.encode_content_encoding(value)
      buffer = ''
      buffer << value.to_s.bytesize.chr
      buffer << value.to_s
      [1, 0x4000, buffer]
    end

encode_content_type(value) click to toggle source

1 << 15

    # File lib/amq/protocol/client.rb, line 1317
    def self.encode_content_type(value)
      buffer = ''
      buffer << value.to_s.bytesize.chr
      buffer << value.to_s
      [0, 0x8000, buffer]
    end

encode_correlation_id(value) click to toggle source

1 << 10

    # File lib/amq/protocol/client.rb, line 1354
    def self.encode_correlation_id(value)
      buffer = ''
      buffer << value.to_s.bytesize.chr
      buffer << value.to_s
      [5, 0x0400, buffer]
    end

encode_delivery_mode(value) click to toggle source

1 << 12

    # File lib/amq/protocol/client.rb, line 1340
    def self.encode_delivery_mode(value)
      buffer = ''
      buffer << [value].pack(PACK_CHAR)
      [3, 0x1000, buffer]
    end

encode_expiration(value) click to toggle source

1 << 8

    # File lib/amq/protocol/client.rb, line 1370
    def self.encode_expiration(value)
      buffer = ''
      buffer << value.to_s.bytesize.chr
      buffer << value.to_s
      [7, 0x0100, buffer]
    end

encode_headers(value) click to toggle source

1 << 13

    # File lib/amq/protocol/client.rb, line 1333
    def self.encode_headers(value)
      buffer = ''
      buffer << AMQ::Protocol::Table.encode(value)
      [2, 0x2000, buffer]
    end

encode_message_id(value) click to toggle source

1 << 7

    # File lib/amq/protocol/client.rb, line 1378
    def self.encode_message_id(value)
      buffer = ''
      buffer << value.to_s.bytesize.chr
      buffer << value.to_s
      [8, 0x0080, buffer]
    end

encode_priority(value) click to toggle source

1 << 11

    # File lib/amq/protocol/client.rb, line 1347
    def self.encode_priority(value)
      buffer = ''
      buffer << [value].pack(PACK_CHAR)
      [4, 0x0800, buffer]
    end

encode_properties(body_size, properties) click to toggle source

    # File lib/amq/protocol/client.rb, line 1426
    def self.encode_properties(body_size, properties)
      pieces, flags = [], 0

      properties.reject {|key, value| value.nil?}.each do |key, value|
        i, f, result = self.__send__(:"encode_#{key}", value)
        flags |= f
        pieces[i] = result
      end

      # result = [60, 0, body_size, flags].pack('n2Qn')
      result = [60, 0].pack(PACK_UINT16_X2)
      result += AMQ::Pack.pack_uint64_big_endian(body_size)
      result += [flags].pack(PACK_UINT16)
      result + pieces.join(EMPTY_STRING)
    end

encode_reply_to(value) click to toggle source

1 << 9

    # File lib/amq/protocol/client.rb, line 1362
    def self.encode_reply_to(value)
      buffer = ''
      buffer << value.to_s.bytesize.chr
      buffer << value.to_s
      [6, 0x0200, buffer]
    end

encode_timestamp(value) click to toggle source

1 << 6

    # File lib/amq/protocol/client.rb, line 1386
    def self.encode_timestamp(value)
      buffer = ''
      buffer << AMQ::Pack.pack_uint64_big_endian(value)
      [9, 0x0040, buffer]
    end

encode_type(value) click to toggle source

1 << 5

    # File lib/amq/protocol/client.rb, line 1393
    def self.encode_type(value)
      buffer = ''
      buffer << value.to_s.bytesize.chr
      buffer << value.to_s
      [10, 0x0020, buffer]
    end

encode_user_id(value) click to toggle source

1 << 4

    # File lib/amq/protocol/client.rb, line 1401
    def self.encode_user_id(value)
      buffer = ''
      buffer << value.to_s.bytesize.chr
      buffer << value.to_s
      [11, 0x0010, buffer]
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.