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)


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

def body
  @body
end

#channelConnection::Channel (readonly)

The channel the message was deliviered to

Returns:



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

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



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

def consumer_tag
  @consumer_tag
end

#delivery_tagInteger (readonly)

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

Returns:

  • (Integer)


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

def delivery_tag
  @delivery_tag
end

#exchangeString (readonly)

Name of the exchange the message was published to

Returns:

  • (String)


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

def exchange
  @exchange
end

#exchange_nameString (readonly)

Deprecated.

Returns:

  • (String)

See Also:



78
79
80
# File 'lib/amqp/client/message.rb', line 78

def exchange_name
  @exchange
end

#propertiesProperties

Message properties

Returns:



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

def properties
  @properties
end

#redeliveredBoolean (readonly)

True if the message have been delivered before

Returns:

  • (Boolean)


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

def redelivered
  @redelivered
end

#routing_keyString (readonly)

The routing key the message was published with

Returns:

  • (String)


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

def routing_key
  @routing_key
end

Instance Method Details

#acknil

Acknowledge the message

Returns:

  • (nil)


55
56
57
58
59
60
61
# File 'lib/amqp/client/message.rb', line 55

def ack
  return if @ack_or_reject_sent

  @channel.basic_ack(@delivery_tag)
  @ack_or_reject_sent = true
  nil
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)


66
67
68
69
70
71
72
# File 'lib/amqp/client/message.rb', line 66

def reject(requeue: false)
  return if @ack_or_reject_sent

  @channel.basic_reject(@delivery_tag, requeue:)
  @ack_or_reject_sent = true
  nil
end