Class: AMQP::Client::Message

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

Overview

A message delivered from the broker

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bodyString

The message body

Returns:

  • (String)


50
51
52
# File 'lib/amqp/client/message.rb', line 50

def body
  @body
end

#channelConnection::Channel (readonly)

The channel the message was deliviered to

Returns:



21
22
23
# File 'lib/amqp/client/message.rb', line 21

def channel
  @channel
end

#consumer_tagString? (readonly)

The tag of the consumer the message was deliviered to

Returns:

  • (String)
  • (nil)

    If the message was polled and not deliviered to a consumer



26
27
28
# File 'lib/amqp/client/message.rb', line 26

def consumer_tag
  @consumer_tag
end

#delivery_tagInteger (readonly)

The delivery tag of the message, used for acknowledge or reject the message

Returns:

  • (Integer)


30
31
32
# File 'lib/amqp/client/message.rb', line 30

def delivery_tag
  @delivery_tag
end

#exchangeString (readonly)

Name of the exchange the message was published to

Returns:

  • (String)


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

def exchange
  @exchange
end

#exchange_nameString (readonly)

Deprecated.

Returns:

  • (String)

See Also:



69
70
71
# File 'lib/amqp/client/message.rb', line 69

def exchange_name
  @exchange
end

#propertiesProperties

Message properties

Returns:



46
47
48
# File 'lib/amqp/client/message.rb', line 46

def properties
  @properties
end

#redeliveredBoolean (readonly)

True if the message have been delivered before

Returns:

  • (Boolean)


42
43
44
# File 'lib/amqp/client/message.rb', line 42

def redelivered
  @redelivered
end

#routing_keyString (readonly)

The routing key the message was published with

Returns:

  • (String)


38
39
40
# File 'lib/amqp/client/message.rb', line 38

def routing_key
  @routing_key
end

Instance Method Details

#acknil

Acknowledge the message

Returns:

  • (nil)


54
55
56
# File 'lib/amqp/client/message.rb', line 54

def ack
  @channel.basic_ack(@delivery_tag)
end

#reject(requeue: false) ⇒ nil

Reject the message

Parameters:

  • requeue (Boolean) (defaults to: false)

    If true the message will be put back into the queue again, ready to be redelivered

Returns:

  • (nil)


61
62
63
# File 'lib/amqp/client/message.rb', line 61

def reject(requeue: false)
  @channel.basic_reject(@delivery_tag, requeue: requeue)
end