Class: Appfuel::Service::MsgRequest

Inherits:
Request
  • Object
show all
Defined in:
lib/appfuel/service/msg_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg, delivery_info, properties) ⇒ Object

metadata properties

headers:        message headers
  action_route [String]
reply_to:       name of rpc response queue
correlation_id: id used in rpc to match response

Parameters:

  • msg

    String serialized message from rabbitmq

  • delivery_info

    Hash info used to acknowledge messages

  • properties

    Object properties of the messages



17
18
19
20
21
22
23
24
# File 'lib/appfuel/service/msg_request.rb', line 17

def initialize(msg, delivery_info, properties)
  inputs = validate_inputs(msg)
  action_route    = properties.headers['action_route'].to_s
  @properties     = properties
  @delivery_info  = delivery_info

  super(action_route, inputs)
end

Instance Attribute Details

#delivery_infoObject (readonly)

Returns the value of attribute delivery_info.



4
5
6
# File 'lib/appfuel/service/msg_request.rb', line 4

def delivery_info
  @delivery_info
end

#propertiesObject (readonly)

Returns the value of attribute properties.



4
5
6
# File 'lib/appfuel/service/msg_request.rb', line 4

def properties
  @properties
end

Instance Method Details

#action_route?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/appfuel/service/msg_request.rb', line 43

def action_route?
  !action_route.empty?
end

#correlation_idObject



39
40
41
# File 'lib/appfuel/service/msg_request.rb', line 39

def correlation_id
  properties.correlation_id
end

#reply_toObject



35
36
37
# File 'lib/appfuel/service/msg_request.rb', line 35

def reply_to
  properties.reply_to
end

#rpc?Boolean

Rpc requires a reply queue to respond to and a correlation_id to identify that response in the queue. When these two things exist then the request is consided to be an rpc

Returns:

  • (Boolean)


31
32
33
# File 'lib/appfuel/service/msg_request.rb', line 31

def rpc?
  !reply_to.nil? && !correlation_id.nil?
end