class RabbitmqClient::MessagePublisher
ExchangeRegistry
is a store for all managed exchanges and their details
Public Class Methods
new(data, exchange, channel, options)
click to toggle source
# File lib/rabbitmq_client/message_publisher.rb, line 15 def initialize(data, exchange, channel, options) @data = data.to_json @exchange = exchange @channel = channel @options = { headers: {} }.merge(options) @options[:headers][:tags] = TagsFilter.tags end
Public Instance Methods
publish()
click to toggle source
# File lib/rabbitmq_client/message_publisher.rb, line 23 def publish exchange = @exchange.create(@channel) notify('publishing_message') exchange.publish(@data, **@options) notify('published_message') end
wait_for_confirms()
click to toggle source
# File lib/rabbitmq_client/message_publisher.rb, line 31 def wait_for_confirms notify('confirming_message') if @channel.wait_for_confirms notify('message_confirmed') return end raise ConfirmationFailed.new(@exchange.name, @channel.nacked_set, @channel.unconfirmed_set) end
Private Instance Methods
message_payload()
click to toggle source
# File lib/rabbitmq_client/message_publisher.rb, line 50 def message_payload { exchange: @exchange.name, message_id: @options[:message_id] } end
notify(event)
click to toggle source
# File lib/rabbitmq_client/message_publisher.rb, line 43 def notify(event) ActiveSupport::Notifications.instrument( "#{event}.rabbitmq_client", message_payload ) end