Class: Freddy::Producers::ReplyProducer

Inherits:
Object
  • Object
show all
Defined in:
lib/freddy/producers/reply_producer.rb

Constant Summary collapse

CONTENT_TYPE =
'application/json'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(channel, logger) ⇒ ReplyProducer

Returns a new instance of ReplyProducer.



6
7
8
9
# File 'lib/freddy/producers/reply_producer.rb', line 6

def initialize(channel, logger)
  @logger = logger
  @exchange = channel.default_exchange
end

Instance Method Details

#produce(destination, payload, properties) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/freddy/producers/reply_producer.rb', line 11

def produce(destination, payload, properties)
  @logger.debug "Sending message #{payload.inspect} to #{destination}"

  properties = properties.merge(
    routing_key: destination, content_type: CONTENT_TYPE
  )

  @exchange.publish Payload.dump(payload), properties
end