Class: AMQP::Header
- Inherits:
-
Object
- Object
- AMQP::Header
- Defined in:
- lib/amqp/header.rb
Overview
Message metadata (aka envelope).
Instance Attribute Summary collapse
-
#attributes ⇒ Hash
readonly
AMQP message attributes.
- #channel ⇒ AMQP::Channel readonly
-
#method ⇒ AMQ::Protocol::Method
readonly
AMQP method frame this header is associated with.
Instance Method Summary collapse
-
#ack(multiple = false) ⇒ Object
Acknowledges the receipt of this message with the server.
-
#consumer_tag ⇒ Object
delivery_tag.
-
#content_type ⇒ Object
delivery_mode.
-
#correlation_id ⇒ Object
reply_to.
-
#delivery_mode ⇒ Object
headers.
-
#delivery_tag ⇒ Object
to_hash.
-
#exchange ⇒ Object
redelivered?.
- #header ⇒ Object deprecated Deprecated.
-
#headers ⇒ Object
header.
-
#initialize(channel, method, attributes) ⇒ Header
constructor
A new instance of Header.
-
#message_id ⇒ Object
correlation_id.
-
#method_missing(meth, *args, &blk) ⇒ Object
Returns AMQP message attributes.
-
#priority ⇒ Object
type.
-
#redelivered ⇒ Object
consumer_tag.
-
#redelivered? ⇒ Boolean
redelivered.
-
#reject(opts = {}) ⇒ Object
Reject this message.
-
#reply_to ⇒ Object
priority.
-
#timestamp ⇒ Object
content_type.
-
#to_hash ⇒ Hash
AMQP message header w/o method-specific information.
-
#type ⇒ Object
timestamp.
Constructor Details
#initialize(channel, method, attributes) ⇒ Header
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
#method_missing(meth, *args, &blk) ⇒ Object
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
#attributes ⇒ Hash (readonly)
AMQP message attributes
24 25 26 |
# File 'lib/amqp/header.rb', line 24 def attributes @attributes end |
#channel ⇒ AMQP::Channel (readonly)
13 14 15 |
# File 'lib/amqp/header.rb', line 13 def channel @channel end |
#method ⇒ AMQ::Protocol::Method (readonly)
AMQP method frame this header is associated with. Carries additional information that varies between AMQP methods.
20 21 22 |
# File 'lib/amqp/header.rb', line 20 def method @method end |
Instance Method Details
#ack(multiple = false) ⇒ Object
Acknowledges the receipt of this message with the server.
34 35 36 |
# File 'lib/amqp/header.rb', line 34 def ack(multiple = false) @channel.acknowledge(@method.delivery_tag, multiple) end |
#consumer_tag ⇒ Object
delivery_tag
55 56 57 |
# File 'lib/amqp/header.rb', line 55 def consumer_tag @method.consumer_tag end |
#content_type ⇒ Object
delivery_mode
84 85 86 |
# File 'lib/amqp/header.rb', line 84 def content_type @attributes[:content_type] end |
#correlation_id ⇒ Object
reply_to
104 105 106 |
# File 'lib/amqp/header.rb', line 104 def correlation_id @attributes[:correlation_id] end |
#delivery_mode ⇒ Object
headers
80 81 82 |
# File 'lib/amqp/header.rb', line 80 def delivery_mode @attributes[:delivery_mode] end |
#delivery_tag ⇒ Object
to_hash
51 52 53 |
# File 'lib/amqp/header.rb', line 51 def delivery_tag @method.delivery_tag end |
#exchange ⇒ Object
redelivered?
67 68 69 |
# File 'lib/amqp/header.rb', line 67 def exchange @method.exchange end |
#header ⇒ Object
72 73 74 |
# File 'lib/amqp/header.rb', line 72 def header @attributes end |
#headers ⇒ Object
header
76 77 78 |
# File 'lib/amqp/header.rb', line 76 def headers @attributes[:headers] end |
#message_id ⇒ Object
correlation_id
108 109 110 |
# File 'lib/amqp/header.rb', line 108 def @attributes[:message_id] end |
#priority ⇒ Object
type
96 97 98 |
# File 'lib/amqp/header.rb', line 96 def priority @attributes[:priority] end |
#redelivered ⇒ Object
consumer_tag
59 60 61 |
# File 'lib/amqp/header.rb', line 59 def redelivered @method.redelivered end |
#redelivered? ⇒ Boolean
redelivered
63 64 65 |
# File 'lib/amqp/header.rb', line 63 def redelivered? @method.redelivered end |
#reject(opts = {}) ⇒ Object
Reject this message.
41 42 43 |
# File 'lib/amqp/header.rb', line 41 def reject(opts = {}) @channel.reject(@method.delivery_tag, opts.fetch(:requeue, false)) end |
#reply_to ⇒ Object
priority
100 101 102 |
# File 'lib/amqp/header.rb', line 100 def reply_to @attributes[:reply_to] end |
#timestamp ⇒ Object
content_type
88 89 90 |
# File 'lib/amqp/header.rb', line 88 def @attributes[:timestamp] end |
#to_hash ⇒ Hash
Returns AMQP message header w/o method-specific information.
47 48 49 |
# File 'lib/amqp/header.rb', line 47 def to_hash @attributes end |
#type ⇒ Object
timestamp
92 93 94 |
# File 'lib/amqp/header.rb', line 92 def type @attributes[:type] end |