bunny for rabbitmq

http://rdoc.info/github/ruby-amqp/bunny/Bunny/Queue

 

Class: Bunny::Queue

Inherits:
Object show all
Defined in:
lib/bunny/queue.rb

Overview

Represents AMQP 0.9.1 queue.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Queue) initialize(channel_or_connection, name = AMQ::Protocol::EMPTY_STRING, opts = {})

Returns a new instance of Queue

Options Hash (opts):

  • :durable (Boolean) — default: false

    Should this queue be durable?

  • :auto_delete (Boolean) — default: false

    Should this queue be automatically deleted when the last consumer disconnects?

  • :exclusive (Boolean) — default: false

    Should this queue be exclusive (only can be used by this connection, removed when the connection is closed)?

  • :arguments (Boolean) — default: {}

    Additional optional arguments (typically used by RabbitMQ extensions and plugins)

See Also:

[View source] [View on GitHub]

Instance Attribute Details

- (Bunny::Channel) channel (readonly)

[View on GitHub]

- (String) name (readonly)

[View on GitHub]

- (Hash) options (readonly)

[View on GitHub]

Instance Method Details

- (Hash) arguments

Returns Additional optional arguments (typically used by RabbitMQ extensions and plugins)

 
[View source] [View on GitHub]

- (Boolean) auto_delete?

Returns true if this queue was declared as automatically deleted (deleted as soon as last consumer unbinds).

[View source] [View on GitHub]

- (Object) bind(exchange, opts = {})

Binds queue to an exchange

Options Hash (opts):

  • :routing_key (String)

    Routing key

  • :arguments (Hash) — default: {}

    Additional optional binding arguments

See Also:

[View source] [View on GitHub]

- (Integer) consumer_count

[View source] [View on GitHub]

- (Object) delete(opts = {})

Deletes the queue

Options Hash (opts):

  • if_unused (Boolean) — default: false

    Should this queue be deleted only if it has no consumers?

  • if_empty (Boolean) — default: false

    Should this queue be deleted only if it has no messages?

See Also:

[View source] [View on GitHub]

- (Boolean) durable?

Returns true if this queue was declared as durable (will survive broker restart).

[View source] [View on GitHub]

- (Boolean) exclusive?

Returns true if this queue was declared as exclusive (limited to just one consumer)

[View source] [View on GitHub]

- (Integer) message_count

[View source] [View on GitHub]

- (Array) pop(opts = {:manual_ack => false}, &block) Also known as: get

Returns Triple of delivery info, message properties and message content. If the queue is empty, all three will be nils.

Examples:

conn = Bunny.new
conn.start

ch   = conn.create_channel
q = ch.queue("test1")
x = ch.default_exchange
x.publish("Hello, everybody!", :routing_key => 'test1')

delivery_info, properties, payload = q.pop

puts "This is the message: " + payload + "\n\n"
conn.close

Options Hash (opts):

  • :ack (Boolean) — default: false

    [DEPRECATED] Use :manual_ack instead

  • :manual_ack (Boolean) — default: false

    Will the message be acknowledged manually?

See Also:

[View source] [View on GitHub]

- (Object) publish(payload, opts = {})

Publishes a message to the queue via default exchange. Takes the same arguments as Exchange#publish

[View source] [View on GitHub]

- (Object) purge(opts = {})

Purges a queue (removes all messages from it)

[View source] [View on GitHub]

- (Boolean) server_named?

Returns true if this queue was declared as server named.

[View source] [View on GitHub]

- (Hash) status

Returns A hash with information about the number of queue messages and consumers

[View source] [View on GitHub]

- (Object) subscribe(opts = { :consumer_tag => @channel.generate_consumer_tag, :manual_ack => false, :exclusive => false, :block => false, :on_cancellation => nil }, &block)

Adds a consumer to the queue (subscribes for message deliveries).

Options Hash (opts):

  • :ack (Boolean) — default: false

    [DEPRECATED] Use :manual_ack instead

  • :manual_ack (Boolean) — default: false

    Will this consumer use manual acknowledgements?

  • :exclusive (Boolean) — default: false

    Should this consumer be exclusive for this queue?

  • :block (Boolean) — default: false

    Should the call block calling thread?

  • :on_cancellation (#call)

    Block to execute when this consumer is cancelled remotely (e.g. via the RabbitMQ Management plugin)

  • :consumer_tag (String)

    Unique consumer identifier. It is usually recommended to let Bunny generate it for you.

  • :arguments (Hash) — default: {}

    Additional (optional) arguments, typically used by RabbitMQ extensions

See Also:

[View source] [View on GitHub]

- (Object) subscribe_with(consumer, opts = {:block => false})

Adds a consumer object to the queue (subscribes for message deliveries).

Options Hash (opts):

  • block (Boolean) — default: false

    Should the call block calling thread?

See Also:

[View source] [View on GitHub]

- (Object) unbind(exchange, opts = {})

Unbinds queue from an exchange

Options Hash (opts):

  • :routing_key (String)

    Routing key

  • :arguments (Hash) — default: {}

    Additional optional binding arguments

See Also:

posted on 2014-09-19 18:10  qinyan20  阅读(301)  评论(0编辑  收藏  举报