class Freddy::Producers::SendAndForgetProducer
Constants
- CONTENT_TYPE
Public Class Methods
Source
# File lib/freddy/producers/send_and_forget_producer.rb, line 8 def initialize(channel, logger) @logger = logger @exchange = channel.default_exchange @topic_exchange = channel.topic Freddy::FREDDY_TOPIC_EXCHANGE_NAME end
Public Instance Methods
Source
# File lib/freddy/producers/send_and_forget_producer.rb, line 14 def produce(routing_key, payload, properties) span = Tracing.span_for_produce(@topic_exchange, routing_key, payload) properties = properties.merge( routing_key: routing_key, content_type: CONTENT_TYPE ) Tracing.inject_tracing_information_to_properties!(properties, span) json_payload = Freddy::Encoding.compress( Payload.dump(payload), properties[:content_encoding] ) # Connection adapters handle thread safety for #publish themselves. No # need to lock these. @topic_exchange.publish json_payload, properties.dup @exchange.publish json_payload, properties.dup ensure # We don't know how many listeners there are and we do not know when # this message gets processed. Instead we close the span immediately. span.finish end