Module: Bunny

Defined in:
lib/bunny.rb,
lib/bunny/queue.rb,
lib/bunny/socket.rb,
lib/bunny/socket.rb,
lib/bunny/framing.rb,
lib/bunny/session.rb,
lib/bunny/channel.rb,
lib/bunny/version.rb,
lib/bunny/timeout.rb,
lib/bunny/exchange.rb,
lib/bunny/consumer.rb,
lib/bunny/test_kit.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/cruby/socket.rb,
lib/bunny/jruby/socket.rb,
lib/bunny/delivery_info.rb,
lib/bunny/heartbeat_sender.rb,
lib/bunny/cruby/ssl_socket.rb,
lib/bunny/jruby/ssl_socket.rb,
lib/bunny/consumer_work_pool.rb,
lib/bunny/message_properties.rb,
lib/bunny/concurrent/condition.rb,
lib/bunny/channel_id_allocator.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/authentication/credentials_encoder.rb,
lib/bunny/concurrent/synchronized_sorted_set.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.

Defined Under Namespace

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

Constant Summary

PROTOCOL_VERSION =

AMQP protocol version Bunny implements

AMQ::Protocol::PROTOCOL_VERSION
SocketImpl =
Socket
Client =

backwards compatibility

Session
VERSION =

Returns Version of the library

Returns:

  • (String)

    Version of the library

"2.6.4"
Timeout =
::Timeout
SSLSocketImpl =
SSLSocket

Class Method Summary collapse

Class Method Details

.new(connection_string_or_opts = ENV['RABBITMQ_URL'], opts = {}, &block) ⇒ Bunny::Session

Instantiates a new connection. The actual 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 = ENV['RABBITMQ_URL'], 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

.protocol_versionString

Returns AMQP protocol version Bunny implements

Returns:

  • (String)

    AMQP protocol version Bunny implements



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

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

.run(connection_string_or_opts = ENV['RABBITMQ_URL'], opts = {}, &block) ⇒ Object

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 = ENV['RABBITMQ_URL'], 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

.versionString

Returns Bunny version

Returns:

  • (String)

    Bunny version



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

def self.version
  VERSION
end