Class: GovukMessageQueueConsumer::JSONProcessor

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

Constant Summary collapse

JSON_FORMAT =
"application/json".freeze

Instance Method Summary collapse

Instance Method Details

#process(message) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/govuk_message_queue_consumer/json_processor.rb', line 5

def process(message)
  if message.headers.content_type == JSON_FORMAT
    message.payload = JSON.parse(message.payload)
  end

  true
rescue JSON::ParserError => e
  GovukError.notify(e) if defined?(GovukError)
  message.discard
  false
end