Method: Bunny::Exchange#initialize

Defined in:
lib/bunny/exchange.rb

#initialize(channel, type, name, opts = {}) ⇒ Exchange

Returns a new instance of Exchange.

Parameters:

  • channel (Bunny::Channel)

    Channel this exchange will use.

  • type (Symbol, String)

    Exchange type

  • name (String)

    Exchange name

  • opts (Hash) (defaults to: {})

    Exchange properties

Options Hash (opts):

  • :durable (Boolean) — default: false

    Should this exchange be durable?

  • :auto_delete (Boolean) — default: false

    Should this exchange be automatically deleted when it is no longer used?

  • :arguments (Boolean) — default: {}

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

See Also:



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/bunny/exchange.rb', line 76

def initialize(channel, type, name, opts = {})
  @channel          = channel
  @name             = name
  @type             = type
  @options          = self.class.add_default_options(name, opts)

  @durable          = @options[:durable]
  @auto_delete      = @options[:auto_delete]
  @internal         = @options[:internal]
  @arguments        = @options[:arguments]

  @bindings         = Set.new

  declare! unless opts[:no_declare] || predeclared? || (@name == AMQ::Protocol::EMPTY_STRING)

  @channel.register_exchange(self)
end