class AMQP::Client::Queue

Queue abstraction

Public Class Methods

new(client, name) click to toggle source

Should only be initialized from the Client @api private

# File lib/amqp/client/queue.rb, line 9
def initialize(client, name)
  @client = client
  @name = name
end

Public Instance Methods

bind(exchange, binding_key, arguments: {}) click to toggle source

Bind the queue to an exchange @param exchange [String] Name of the exchange to bind to @param binding_key [String] Binding key on which messages that match might be routed (depending on exchange type) @param arguments [Hash] Message headers to match on (only relevant for header exchanges) @return [self]

# File lib/amqp/client/queue.rb, line 42
def bind(exchange, binding_key, arguments: {})
  @client.bind(@name, exchange, binding_key, arguments: arguments)
  self
end
delete() click to toggle source

Delete the queue @return [nil]

# File lib/amqp/client/queue.rb, line 66
def delete
  @client.delete_queue(@name)
  nil
end
publish(body, **properties) click to toggle source

Publish to the queue, wait for confirm @param (see Client#publish) @option (see Client#publish) @raise (see Client#publish) @return [self]

# File lib/amqp/client/queue.rb, line 19
def publish(body, **properties)
  @client.publish(body, "", @name, **properties)
  self
end
purge() click to toggle source

Purge/empty the queue @return [self]

# File lib/amqp/client/queue.rb, line 59
def purge
  @client.purge(@name)
  self
end
subscribe(no_ack: false, prefetch: 1, worker_threads: 1, arguments: {}, &blk) click to toggle source

Subscribe/consume from the queue @param no_ack [Boolean] When false messages have to be manually acknowledged (or rejected) @param prefetch [Integer] Specify how many messages to prefetch for consumers with no_ack is false @param worker_threads [Integer] Number of threads processing messages,

0 means that the thread calling this method will be blocked

@param arguments [Hash] Custom arguments to the consumer @yield [Message] Delivered message from the queue @return [self]

# File lib/amqp/client/queue.rb, line 32
def subscribe(no_ack: false, prefetch: 1, worker_threads: 1, arguments: {}, &blk)
  @client.subscribe(@name, no_ack: no_ack, prefetch: prefetch, worker_threads: worker_threads, arguments: arguments, &blk)
  self
end
unbind(exchange, binding_key, arguments: {}) click to toggle source

Unbind the queue from an exchange @param exchange [String] Name of the exchange to unbind from @param binding_key [String] Binding key which the queue is bound to the exchange with @param arguments [Hash] Arguments matching the binding that's being removed @return [self]

# File lib/amqp/client/queue.rb, line 52
def unbind(exchange, binding_key, arguments: {})
  @client.unbind(@name, exchange, binding_key, arguments: arguments)
  self
end