Sha256: a00ec11f9f75387e8ce009b337a49d1585b0c9edaeb1c1a081ecc49cfcc32abe
Contents?: true
Size: 1.21 KB
Versions: 9
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true class Freddy module Producers class SendAndForgetProducer CONTENT_TYPE = 'application/json' def initialize(channel, logger) @logger = logger @exchange = channel.default_exchange @topic_exchange = channel.topic Freddy::FREDDY_TOPIC_EXCHANGE_NAME end 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 end end end
Version data entries
9 entries across 9 versions & 1 rubygems