Class Bunny::Client09
In: lib/bunny/client09.rb
Parent: Qrack::Client

DESCRIPTION:

The Client class provides the major Bunny API methods.

Methods

Public Class methods

DESCRIPTION:

Sets up a Bunny::Client object ready for connection to a broker/server. Client.status is set to :not_connected.

OPTIONS:

  • :host => ‘hostname’ (default = ‘localhost’)
  • :port => portno (default = 5672 or 5671 if :ssl set to true)
  • :vhost => ‘vhostname’ (default = ’/’)
  • :user => ‘username’ (default = ‘guest’)
  • :pass => ‘password’ (default = ‘guest’)
  • :ssl => true or false (default = false) - If set to true, ssl encryption will be used and port will default to 5671.
  • :verify_ssl => true or false (default = true) - If ssl is enabled, this will cause OpenSSL to validate the server certificate unless this parameter is set to false.
  • :logfile => ‘logfilepath’ (default = nil)
  • :logging => true or false (default) - If set to true, session information is sent to STDOUT if :logfile has not been specified. Otherwise, session information is written to :logfile.
  • :frame_max => maximum frame size in bytes (default = 131072)
  • :channel_max => maximum number of channels (default = 0 no maximum)
  • :heartbeat => number of seconds (default = 0 no heartbeat)
  • :connect_timeout => number of seconds before Qrack::ConnectionTimeout is raised (default = 5)

Public Instance methods

DESCRIPTION:

Checks response from AMQP methods and takes appropriate action

DESCRIPTION:

Declares an exchange to the broker/server. If the exchange does not exist, a new one is created using the arguments passed in. If the exchange already exists, a reference to it is created, provided that the arguments passed in do not conflict with the existing attributes of the exchange. If an error occurs a Bunny::ProtocolError is raised.

OPTIONS:

  • :type => one of :direct (default), :fanout, :topic, :headers
  • :passive => true or false - If set to true, the server will not create the exchange. The client can use this to check whether an exchange exists without modifying the server state.
  • :durable => true or false (default) - If set to true when creating a new exchange, the exchange will be marked as durable. Durable exchanges remain active when a server restarts. Non-durable exchanges (transient exchanges) are purged if/when a server restarts.
  • :auto_delete => true or false (default) - If set to true, the exchange is deleted when all queues have finished using it.
  • :nowait => true or false (default) - Ignored by Bunny, always false.

RETURNS:

Exchange

DESCRIPTION:

Requests a specific quality of service. The QoS can be specified for the current channel or for all channels on the connection. The particular properties and semantics of a QoS method always depend on the content class semantics. Though the QoS method could in principle apply to both peers, it is currently meaningful only for the server.

Options:

  • :prefetch_size => size in no. of octets (default = 0) - The client can request that

messages be sent in advance so that when the client finishes processing a message, the following message is already held locally, rather than needing to be sent down the channel. Prefetching gives a performance improvement. This field specifies the prefetch window size in octets. The server will send a message in advance if it is equal to or smaller in size than the available prefetch size (and also falls into other prefetch limits). May be set to zero, meaning "no specific limit", although other prefetch limits may still apply. The prefetch-size is ignored if the no-ack option is set.

  • :prefetch_count => no. messages (default = 1) - Specifies a prefetch window in terms

of whole messages. This field may be used in combination with the prefetch-size field; a message will only be sent in advance if both prefetch windows (and those at the channel and connection level) allow it. The prefetch-count is ignored if the no-ack option is set.

  • :global => true or false (default) - By default the QoS settings apply to the current channel only. If set to

true, they are applied to the entire connection.

RETURNS:

:qos_ok if successful.

DESCRIPTION:

Declares a queue to the broker/server. If the queue does not exist, a new one is created using the arguments passed in. If the queue already exists, a reference to it is created, provided that the arguments passed in do not conflict with the existing attributes of the queue. If an error occurs a Bunny::ProtocolError is raised.

OPTIONS:

  • :passive => true or false (default) - If set to true, the server will not create the queue. The client can use this to check whether a queue exists without modifying the server state.
  • :durable => true or false (default) - If set to true when creating a new queue, the queue will be marked as durable. Durable queues remain active when a server restarts. Non-durable queues (transient queues) are purged if/when a server restarts. Note that durable queues do not necessarily hold persistent messages, although it does not make sense to send persistent messages to a transient queue.
  • :exclusive => true or false (default) - If set to true, requests an exclusive queue. Exclusive queues may only be consumed from by the current connection. Setting the ‘exclusive’ flag always implies ‘auto-delete’.
  • :auto_delete => true or false (default) - If set to true, the queue is deleted when all consumers have finished using it. Last consumer can be cancelled either explicitly or because its channel is closed. If there has never been a consumer on the queue, it is not deleted.
  • :nowait => true or false (default) - Ignored by Bunny, always false.

RETURNS:

Queue

DESCRIPTION:

Asks the broker to redeliver all unacknowledged messages on a specified channel. Zero or more messages may be redelivered.

Options:

  • :requeue => true or false (default) - If set to false, the message will be

redelivered to the original recipient. If set to true, the server will attempt to requeue the message, potentially then delivering it to an alternative subscriber.

start()

Alias for start_session

DESCRIPTION:

Opens a communication channel and starts a connection. If an error occurs, a Bunny::ProtocolError is raised. If successful, Client.status is set to :connected.

RETURNS:

:connected if successful.

DESCRIPTION:

This method commits all messages published and acknowledged in the current transaction. A new transaction starts immediately after a commit.

RETURNS:

:commit_ok if successful.

DESCRIPTION:

This method abandons all messages published and acknowledged in the current transaction. A new transaction starts immediately after a rollback.

RETURNS:

:rollback_ok if successful.

DESCRIPTION:

This method sets the channel to use standard transactions. The client must use this method at least once on a channel before using the Commit or Rollback methods.

RETURNS:

:select_ok if successful.

[Validate]