Class: GovukMessageQueueConsumer::Message
- Inherits:
-
Object
- Object
- GovukMessageQueueConsumer::Message
- Defined in:
- lib/govuk_message_queue_consumer/message.rb
Overview
Client code will receive an instance of this
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#delivery_info ⇒ Object
readonly
Returns the value of attribute delivery_info.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Instance Method Summary collapse
- #ack ⇒ Object
- #body_data ⇒ Object
- #discard ⇒ Object
-
#initialize(delivery_info, headers, payload) ⇒ Message
constructor
A new instance of Message.
- #retry ⇒ Object
Constructor Details
#initialize(delivery_info, headers, payload) ⇒ Message
Returns a new instance of Message.
6 7 8 9 10 |
# File 'lib/govuk_message_queue_consumer/message.rb', line 6 def initialize(delivery_info, headers, payload) @delivery_info = delivery_info @headers = headers @body = payload end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
12 13 14 |
# File 'lib/govuk_message_queue_consumer/message.rb', line 12 def body @body end |
#delivery_info ⇒ Object (readonly)
Returns the value of attribute delivery_info.
12 13 14 |
# File 'lib/govuk_message_queue_consumer/message.rb', line 12 def delivery_info @delivery_info end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
12 13 14 |
# File 'lib/govuk_message_queue_consumer/message.rb', line 12 def headers @headers end |
Instance Method Details
#ack ⇒ Object
18 19 20 |
# File 'lib/govuk_message_queue_consumer/message.rb', line 18 def ack @delivery_info.channel.ack(@delivery_info.delivery_tag) end |
#body_data ⇒ Object
14 15 16 |
# File 'lib/govuk_message_queue_consumer/message.rb', line 14 def body_data @body_data ||= JSON.parse(@body) end |
#discard ⇒ Object
26 27 28 |
# File 'lib/govuk_message_queue_consumer/message.rb', line 26 def discard @delivery_info.channel.reject(@delivery_info.delivery_tag, false) end |
#retry ⇒ Object
22 23 24 |
# File 'lib/govuk_message_queue_consumer/message.rb', line 22 def retry @delivery_info.channel.reject(@delivery_info.delivery_tag, true) end |