Module: Bunny

Defined in:
lib/bunny.rb,
lib/bunny/queue.rb,
lib/bunny/socket.rb,
lib/bunny/socket.rb,
lib/bunny/timeout.rb,
lib/bunny/session.rb,
lib/bunny/channel.rb,
lib/bunny/version.rb,
lib/bunny/framing.rb,
lib/bunny/test_kit.rb,
lib/bunny/exchange.rb,
lib/bunny/consumer.rb,
lib/bunny/transport.rb,
lib/bunny/ssl_socket.rb,
lib/bunny/ssl_socket.rb,
lib/bunny/exceptions.rb,
lib/bunny/return_info.rb,
lib/bunny/reader_loop.rb,
lib/bunny/get_response.rb,
lib/bunny/system_timer.rb,
lib/bunny/cruby/socket.rb,
lib/bunny/jruby/socket.rb,
lib/bunny/compatibility.rb,
lib/bunny/delivery_info.rb,
lib/bunny/jruby/ssl_socket.rb,
lib/bunny/cruby/ssl_socket.rb,
lib/bunny/heartbeat_sender.rb,
lib/bunny/message_properties.rb,
lib/bunny/consumer_work_pool.rb,
lib/bunny/channel_id_allocator.rb,
lib/bunny/concurrent/condition.rb,
lib/bunny/versioned_delivery_tag.rb,
lib/bunny/consumer_tag_generator.rb,
lib/bunny/concurrent/atomic_fixnum.rb,
lib/bunny/concurrent/continuation_queue.rb,
lib/bunny/concurrent/synchronized_sorted_set.rb,
lib/bunny/authentication/credentials_encoder.rb,
lib/bunny/concurrent/linked_continuation_queue.rb,
lib/bunny/authentication/plain_mechanism_encoder.rb,
lib/bunny/authentication/external_mechanism_encoder.rb

Overview

Bunny is a RabbitMQ client that focuses on ease of use.

See Also:

Defined Under Namespace

Modules: Authentication, JRuby Classes: AccessRefused, AuthenticationFailureError, BadLengthError, Channel, ChannelAlreadyClosed, ChannelError, ChannelIdAllocator, ChannelLevelException, ClientTimeout, CommandInvalid, ConnectionClosedError, ConnectionForced, ConnectionLevelException, ConnectionTimeout, Consumer, ConsumerTagGenerator, DeliveryInfo, Exception, Exchange, ForcedChannelCloseError, ForcedConnectionCloseError, FrameError, GetResponse, InconsistentDataError, InternalError, MessageProperties, NetworkFailure, NoFinalOctetError, NotAllowedError, NotFound, PossibleAuthenticationFailureError, PreconditionFailed, Queue, ResourceError, ResourceLocked, ReturnInfo, Session, ShutdownSignal, SystemTimer, TCPConnectionFailed, TestKit, UnexpectedFrame

Constant Summary

PROTOCOL_VERSION =

AMQP protocol version Bunny implements

AMQ::Protocol::PROTOCOL_VERSION
SocketImpl =
Socket
Timeout =

Unifies Ruby standard library's Timeout (which is not accurate on Ruby 1.8) and SystemTimer (the gem)

if RUBY_VERSION < "1.9"
  begin
    require "bunny/system_timer"
    Bunny::SystemTimer
  rescue LoadError
    Timeout
  end
else
  Timeout
end
Client =

backwards compatibility

Session
VERSION =
"1.5.0.pre"
SSLSocketImpl =
SSLSocket

Class Method Summary (collapse)

Class Method Details

+ (Bunny::Session) new(connection_string_or_opts = {}, opts = {}, &block)

Instantiates a new connection. The actual connection network connection is started with Bunny::Session#start



61
62
63
64
65
66
67
68
69
70
# File 'lib/bunny.rb', line 61

def self.new(connection_string_or_opts = {}, opts = {}, &block)
  if connection_string_or_opts.respond_to?(:keys) && opts.empty?
    opts = connection_string_or_opts
  end

  conn = Session.new(connection_string_or_opts, opts)
  @default_connection ||= conn

  conn
end

+ (String) protocol_version



49
50
51
# File 'lib/bunny.rb', line 49

def self.protocol_version
  AMQ::Protocol::PROTOCOL_VERSION
end

+ (Object) run(connection_string_or_opts = {}, opts = {}, &block)

Raises:

  • (ArgumentError)


73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/bunny.rb', line 73

def self.run(connection_string_or_opts = {}, opts = {}, &block)
  raise ArgumentError, 'Bunny#run requires a block' unless block

  client = Session.new(connection_string_or_opts, opts)

  begin
    client.start
    block.call(client)
  ensure
    client.stop
  end

  # backwards compatibility
  :run_ok
end

+ (String) version



44
45
46
# File 'lib/bunny.rb', line 44

def self.version
  VERSION
end