Sha256: 56581a713c732cdd98d52906cc841fbe52155da15653d0b4a589015f231cff91
Contents?: true
Size: 796 Bytes
Versions: 11
Compression:
Stored size: 796 Bytes
Contents
require_relative 'request' require 'json' class Freddy class Producer CONTENT_TYPE = 'application/json'.freeze def initialize(channel, logger) @channel, @logger = channel, logger @exchange = @channel.default_exchange @topic_exchange = @channel.topic Freddy::FREDDY_TOPIC_EXCHANGE_NAME end def produce(destination, payload, properties={}) @logger.debug "Producing message #{payload.inspect} to #{destination}" properties = properties.merge(routing_key: destination, content_type: CONTENT_TYPE) json_payload = payload.to_json @topic_exchange.publish json_payload, properties.dup @exchange.publish json_payload, properties.dup end def on_return(*args, &block) @exchange.on_return(*args, &block) end end end
Version data entries
11 entries across 11 versions & 1 rubygems