class Queight::Exchange
Public Class Methods
new(type, name, message_options = {})
click to toggle source
# File lib/queight/exchange.rb, line 3 def initialize(type, name, message_options = {}) @type = type @name = name @message_options = { :content_type => "application/json", :persistent => true, }.merge(message_options) end
Public Instance Methods
bind(channel, queue)
click to toggle source
# File lib/queight/exchange.rb, line 24 def bind(channel, queue) if queue.routing_patterns.any? queue.routing_patterns.each do |routing_pattern| queue.queue(channel).bind( exchange(channel), :routing_key => routing_pattern ) end else queue.queue(channel).bind(exchange(channel)) end end
delete(channel)
click to toggle source
# File lib/queight/exchange.rb, line 20 def delete(channel) channel.exchange(@name, exchange_options).delete end
exchange(channel)
click to toggle source
# File lib/queight/exchange.rb, line 16 def exchange(channel) channel.exchange(@name, exchange_options) end
publish(channel, message, routing_key)
click to toggle source
# File lib/queight/exchange.rb, line 12 def publish(channel, message, routing_key) exchange(channel).publish(message, message_options_for(routing_key)) end
Private Instance Methods
exchange_options()
click to toggle source
# File lib/queight/exchange.rb, line 39 def exchange_options { :auto_delete => false, :durable => true, :type => @type, } end
message_options_for(routing_key)
click to toggle source
# File lib/queight/exchange.rb, line 47 def message_options_for(routing_key) @message_options.merge(:routing_key => routing_key) end