Module: AMQP::Boilerplate::Producer::InstanceMethods

Defined in:
lib/amqp/boilerplate/producer.rb

Instance Method Summary collapse

Instance Method Details

#publish(&block) ⇒ void

This method returns an undefined value.

Publishes a message to the exchange

See Also:

  • Exchange#publish


95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/amqp/boilerplate/producer.rb', line 95

def publish(&block)
  block ||= lambda {
    AMQP::Boilerplate.logger.debug "[#{self.class}] Message was published"
  }

  message = send(self.class.amqp_boilerplate_message.to_sym)
  if message
    AMQP::Boilerplate.logger.debug "[#{self.class}] Publishing message:\n#{message}"
    exchange.publish(message, self.class.amqp_boilerplate_options, &block)
  else
    AMQP::Boilerplate.logger.debug "[#{self.class}] Not publishing nil message"
  end
end