Class: AMQP::Header

Inherits:
Object
  • Object
show all
Defined in:
lib/amqp/header.rb

Overview

Message metadata (aka envelope).

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Header) initialize(channel, method, attributes)

Returns a new instance of Header



27
28
29
# File 'lib/amqp/header.rb', line 27

def initialize(channel, method, attributes)
  @channel, @method, @attributes = channel, method, attributes
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(meth, *args, &blk)

Returns AMQP message attributes.



115
116
117
118
119
120
121
# File 'lib/amqp/header.rb', line 115

def method_missing(meth, *args, &blk)
  if @attributes && args.empty? && blk.nil? && @attributes.has_key?(meth)
    @attributes[meth]
  else
    @method.__send__(meth, *args, &blk)
  end
end

Instance Attribute Details

- (Hash) attributes (readonly)

AMQP message attributes

Returns:

  • (Hash)


24
25
26
# File 'lib/amqp/header.rb', line 24

def attributes
  @attributes
end

- (AMQP::Channel) channel (readonly)

Returns:



13
14
15
# File 'lib/amqp/header.rb', line 13

def channel
  @channel
end

- (AMQ::Protocol::Method) method (readonly)

AMQP method frame this header is associated with. Carries additional information that varies between AMQP methods.

Returns:

  • (AMQ::Protocol::Method)


20
21
22
# File 'lib/amqp/header.rb', line 20

def method
  @method
end

Instance Method Details

- (Object) ack(multiple = false)

Acknowledges the receipt of this message with the server.

Parameters:

  • multiple (Boolean) (defaults to: false)

    Whether or not to acknowledge multiple messages



34
35
36
# File 'lib/amqp/header.rb', line 34

def ack(multiple = false)
  @channel.acknowledge(@method.delivery_tag, multiple)
end

- (Object) consumer_tag

delivery_tag



55
56
57
# File 'lib/amqp/header.rb', line 55

def consumer_tag
  @method.consumer_tag
end

- (Object) content_type

delivery_mode



84
85
86
# File 'lib/amqp/header.rb', line 84

def content_type
  @attributes[:content_type]
end

- (Object) correlation_id

reply_to



104
105
106
# File 'lib/amqp/header.rb', line 104

def correlation_id
  @attributes[:correlation_id]
end

- (Object) delivery_mode

headers



80
81
82
# File 'lib/amqp/header.rb', line 80

def delivery_mode
  @attributes[:delivery_mode]
end

- (Object) delivery_tag

to_hash



51
52
53
# File 'lib/amqp/header.rb', line 51

def delivery_tag
  @method.delivery_tag
end

- (Object) exchange

redelivered?



67
68
69
# File 'lib/amqp/header.rb', line 67

def exchange
  @method.exchange
end

- (Object) header

Deprecated.


72
73
74
# File 'lib/amqp/header.rb', line 72

def header
  @attributes
end

- (Object) headers

header



76
77
78
# File 'lib/amqp/header.rb', line 76

def headers
  @attributes[:headers]
end

- (Object) message_id

correlation_id



108
109
110
# File 'lib/amqp/header.rb', line 108

def message_id
  @attributes[:message_id]
end

- (Object) priority

type



96
97
98
# File 'lib/amqp/header.rb', line 96

def priority
  @attributes[:priority]
end

- (Object) redelivered

consumer_tag



59
60
61
# File 'lib/amqp/header.rb', line 59

def redelivered
  @method.redelivered
end

- (Boolean) redelivered?

redelivered

Returns:

  • (Boolean)


63
64
65
# File 'lib/amqp/header.rb', line 63

def redelivered?
  @method.redelivered
end

- (Object) reject(opts = {})

Reject this message.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :requeue (Hash) — default: false

    Whether message should be requeued.



41
42
43
# File 'lib/amqp/header.rb', line 41

def reject(opts = {})
  @channel.reject(@method.delivery_tag, opts.fetch(:requeue, false))
end

- (Object) reply_to

priority



100
101
102
# File 'lib/amqp/header.rb', line 100

def reply_to
  @attributes[:reply_to]
end

- (Object) timestamp

content_type



88
89
90
# File 'lib/amqp/header.rb', line 88

def timestamp
  @attributes[:timestamp]
end

- (Hash) to_hash

Returns AMQP message header w/o method-specific information.

Returns:

  • (Hash)

    AMQP message header w/o method-specific information.



47
48
49
# File 'lib/amqp/header.rb', line 47

def to_hash
  @attributes
end

- (Object) type

timestamp



92
93
94
# File 'lib/amqp/header.rb', line 92

def type
  @attributes[:type]
end