Class: Postman::Message

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

Overview

A message takes a rabbitMQ message, and handles its acknowledgement or rejection.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(postman, delivery_info, metadata, payload) ⇒ Message

Returns a new instance of Message


41
42
43
44
45
46
# File 'lib/postman/message.rb', line 41

def initialize(postman, delivery_info, , payload)
  @postman = postman
  @delivery_info = delivery_info
  @metadata = 
  @payload = payload
end

Instance Attribute Details

#delivery_infoObject (readonly)

Returns the value of attribute delivery_info


32
33
34
# File 'lib/postman/message.rb', line 32

def delivery_info
  @delivery_info
end

#metadataObject (readonly)

Returns the value of attribute metadata


32
33
34
# File 'lib/postman/message.rb', line 32

def 
  @metadata
end

#payloadObject (readonly)

Returns the value of attribute payload


32
33
34
# File 'lib/postman/message.rb', line 32

def payload
  @payload
end

#postmanObject (readonly)

Returns the value of attribute postman


32
33
34
# File 'lib/postman/message.rb', line 32

def postman
  @postman
end

Instance Method Details

#loggerObject


37
38
39
# File 'lib/postman/message.rb', line 37

def logger
  Rails.logger
end

#processObject


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/postman/message.rb', line 48

def process
  debug 'Started message process'
  debug payload

  begin
    broadcast_payload
    ack
  rescue Postman::ConnectionMissing => e
    # We have some temporary database issues. Requeue the message and pause
    # until the issue is resolved.
    requeue(e)
    postman.pause!
  rescue StandardError => e
    deadletter(e)
  end

  debug 'Finished message process'
end