class Jackrabbit::Client
Constants
- InvalidExchangeType
Attributes
config[R]
Public Class Methods
new(config = Jackrabbit.config)
click to toggle source
# File lib/jackrabbit/client.rb, line 8 def initialize(config = Jackrabbit.config) @config = config end
Public Instance Methods
bonded_queue(name, options = {}, &block)
click to toggle source
# File lib/jackrabbit/client.rb, line 28 def bonded_queue(name, options = {}, &block) queue_opts, binding_opts, sub_options = split_options(options) queue = self.queue(name, queue_opts) receiver = MessageReceiver.new(channel, &block) queue.bind(exchange, binding_opts) queue.subscribe(sub_options) do |info, message, payload| receiver.handle(info, message, payload) end end
channel()
click to toggle source
# File lib/jackrabbit/client.rb, line 12 def channel @channel ||= connection.create_channel end
exchange()
click to toggle source
# File lib/jackrabbit/client.rb, line 16 def exchange if %w(fanout direct topic).include?(config.exchange_type) @exchange ||= channel.send(config.exchange_type, config.exchange_name, config.exchange_options) else raise InvalidExchangeType, "The exchange type '#{config.exchange_type}' is invalid" end end
publish(message, options = {})
click to toggle source
# File lib/jackrabbit/client.rb, line 24 def publish(message, options = {}) exchange.publish(message, options) end
queue(name, options)
click to toggle source
# File lib/jackrabbit/client.rb, line 41 def queue(name, options) channel.queue(name, options) end
Private Instance Methods
split_options(options)
click to toggle source
# File lib/jackrabbit/client.rb, line 47 def split_options(options) binding_options = options.delete(:binding) || {} sub_options = options.delete(:subscription) || {} return [options, binding_options, sub_options] end