Method: AMQP::Exchange#delete

Defined in:
lib/amqp/exchange.rb

#delete(opts = {}, &block) ⇒ NilClass

This method deletes an exchange. When an exchange is deleted all queue bindings on the exchange are deleted, too. Further attempts to publish messages to a deleted exchange will result in a channel-level exception.

Examples:

Deleting an exchange


exchange = AMQP::Channel.direct("search.indexing")
exchange.delete

Parameters:

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

    a customizable set of options

Options Hash (opts):

  • :nowait (Boolean) — default: false

    If set, the server will not respond to the method. The client should not wait for a reply method. If the server could not complete the method it will raise a channel or connection exception.

  • :if_unused (Boolean) — default: false

    If set, the server will only delete the exchange if it has no queue bindings. If the exchange has queue bindings the server does not delete it but raises a channel exception instead.

Returns:

  • (NilClass)

    nil



562
563
564
565
566
567
568
569
# File 'lib/amqp/exchange.rb', line 562

def delete(opts = {}, &block)
  @channel.once_open do
    exchange_delete(opts.fetch(:if_unused, false), opts.fetch(:nowait, false), &block)
  end

  # backwards compatibility
  nil
end