module Vx::Common::AMQP::Consumer::Publish
Public Instance Methods
publish(message, options = nil)
click to toggle source
# File lib/vx/common/amqp/consumer/publish.rb, line 8 def publish(message, options = nil) session.open options ||= {} options[:routing_key] = routing_key if routing_key && !options.key?(:routing_key) options[:headers] = headers if headers && !options.key?(:headers) options[:content_type] ||= content_type || config.content_type options[:message_id] ||= SecureRandom.uuid x = declare_exchange instrumentation = { payload: message, exchange: x.name, consumer: consumer_name, consumer_id: consumer_id, properties: options, } with_pub_middlewares instrumentation do instrument("process_publishing.consumer.amqp", instrumentation) do m = serialize_message message, options[:content_type] x.publish m, options end end self end
Also aliased as: real_publish
serialize_message(message, content_type)
click to toggle source
# File lib/vx/common/amqp/consumer/publish.rb, line 37 def serialize_message(message, content_type) Common::AMQP::Formatter.pack(content_type, message) end
with_pub_middlewares(env, &block)
click to toggle source
# File lib/vx/common/amqp/consumer/publish.rb, line 41 def with_pub_middlewares(env, &block) Common::AMQP.config.builders[:pub].to_app(block).call(env) end