class Freddy::Producers::ReplyProducer

Constants

CONTENT_TYPE

Public Class Methods

new(channel, logger) click to toggle source
# File lib/freddy/producers/reply_producer.rb, line 8
def initialize(channel, logger)
  @logger = logger
  @exchange = channel.default_exchange
end

Public Instance Methods

produce(routing_key, payload, properties) click to toggle source
# File lib/freddy/producers/reply_producer.rb, line 13
def produce(routing_key, payload, properties)
  span = Tracing.span_for_produce(
    @exchange,
    routing_key,
    payload,
    correlation_id: properties[:correlation_id]
  )

  properties = properties.merge(
    routing_key: routing_key,
    content_type: CONTENT_TYPE
  )
  Tracing.inject_tracing_information_to_properties!(properties, span)

  @exchange.publish Payload.dump(payload), properties
ensure
  # We won't wait for a reply. Just finish the span immediately.
  span.finish
end