Class: GovukMessageQueueConsumer::Message

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

Overview

Client code will receive an instance of this

Direct Known Subclasses

MockMessage

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload, headers, delivery_info) ⇒ Message

Returns a new instance of Message.



6
7
8
9
10
11
# File 'lib/govuk_message_queue_consumer/message.rb', line 6

def initialize(payload, headers, delivery_info)
  @payload = payload
  @headers = headers
  @delivery_info = delivery_info
  @status = :status
end

Instance Attribute Details

#delivery_infoObject

Returns the value of attribute delivery_info.



4
5
6
# File 'lib/govuk_message_queue_consumer/message.rb', line 4

def delivery_info
  @delivery_info
end

#headersObject

Returns the value of attribute headers.



4
5
6
# File 'lib/govuk_message_queue_consumer/message.rb', line 4

def headers
  @headers
end

#payloadObject

Returns the value of attribute payload.



4
5
6
# File 'lib/govuk_message_queue_consumer/message.rb', line 4

def payload
  @payload
end

#statusObject

Returns the value of attribute status.



4
5
6
# File 'lib/govuk_message_queue_consumer/message.rb', line 4

def status
  @status
end

Instance Method Details

#ackObject



13
14
15
16
# File 'lib/govuk_message_queue_consumer/message.rb', line 13

def ack
  @delivery_info.channel.ack(@delivery_info.delivery_tag)
  @status = :acked
end

#discardObject



23
24
25
26
# File 'lib/govuk_message_queue_consumer/message.rb', line 23

def discard
  @delivery_info.channel.reject(@delivery_info.delivery_tag, false)
  @status = :discarded
end

#retryObject



18
19
20
21
# File 'lib/govuk_message_queue_consumer/message.rb', line 18

def retry
  @delivery_info.channel.reject(@delivery_info.delivery_tag, true)
  @status = :retried
end