Class: GorgonAMQ::Protocol::Basic::Publish

Inherits:
Method
  • Object
show all
Defined in:
lib/gorgon_amq-protocol/lib/gorgon_amq/protocol/client.rb

Class Method Summary collapse

Methods inherited from Method

encode_body, index, inherited, instantiate, method_id, methods, name, split_headers

Class Method Details

.encode(channel, payload, user_headers, exchange, routing_key, mandatory, immediate, frame_size) ⇒ Object

u’ticket = 0’, u’exchange = EMPTY_STRING’, u’routing_key = EMPTY_STRING’, u’mandatory = false’, u’immediate = false’, ‘user_headers = nil’, ‘payload = “”’, ‘frame_size = nil’

Returns:



1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
# File 'lib/gorgon_amq-protocol/lib/gorgon_amq/protocol/client.rb', line 1722

def self.encode(channel, payload, user_headers, exchange, routing_key, mandatory, immediate, frame_size)
  ticket = 0
  buffer = @packed_indexes.dup
  buffer << [ticket].pack(PACK_UINT16)
  buffer << exchange.to_s.bytesize.chr
  buffer << exchange.to_s
  buffer << routing_key.to_s.bytesize.chr
  buffer << routing_key.to_s
  bit_buffer = 0
  bit_buffer = bit_buffer | (1 << 0) if mandatory
  bit_buffer = bit_buffer | (1 << 1) if immediate
  buffer << [bit_buffer].pack(PACK_CHAR)
  frames = [MethodFrame.new(buffer, channel)]
  properties, headers = self.split_headers(user_headers)
  if properties.nil? or properties.empty?
    raise RuntimeError.new("Properties can not be empty!")
  end
  properties_payload = Basic.encode_properties(payload.bytesize, properties)
  frames << HeaderFrame.new(properties_payload, channel)
  frames += self.encode_body(payload, channel, frame_size)
  frames
end

.has_content?Boolean

Returns:

  • (Boolean)


1716
1717
1718
# File 'lib/gorgon_amq-protocol/lib/gorgon_amq/protocol/client.rb', line 1716

def self.has_content?
  true
end