# File lib/amqp/exchange.rb, line 476 def publish(payload, options = {}, &block) opts = @default_publish_options.merge(options) @channel.once_open do properties = @default_headers.merge(options) properties[:delivery_mode] = properties.delete(:persistent) ? 2 : 1 super(payload.to_s, opts[:key] || opts[:routing_key] || @default_routing_key, properties, opts[:mandatory], opts[:immediate]) # don't pass block to AMQ::Client::Exchange#publish because it will be executed # immediately and we want to do it later. See ruby-amqp/amqp/#67 MK. EventMachine.next_tick(&block) if block end self end